aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-ve-vnfm-adapter/src/test/java
diff options
context:
space:
mode:
authorPiotr Borelowski <p.borelowski@partner.samsung.com>2020-02-06 17:22:57 +0100
committerPiotr Borelowski <p.borelowski@partner.samsung.com>2020-02-10 15:39:08 +0100
commit9a13ad8797811159adea21e1d9eb819445fbf492 (patch)
tree801f569867468e12eb888a24ab9631110a76e2f0 /adapters/mso-ve-vnfm-adapter/src/test/java
parent14661c9bd3569905b6b4b041be796231c45c8a93 (diff)
Added Basic Authorization in sending Subscription to VNFM
Ve-Vnfm (SOL002) Adapter project Issue-ID: SO-2574 Signed-off-by: Piotr Borelowski <p.borelowski@partner.samsung.com> Change-Id: I819e95c4e212695bc38ab5b7d221be712f87320e
Diffstat (limited to 'adapters/mso-ve-vnfm-adapter/src/test/java')
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/StartupServiceTest.java33
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/subscription/SubscribeSenderTest.java8
2 files changed, 27 insertions, 14 deletions
diff --git a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/StartupServiceTest.java b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/StartupServiceTest.java
index 8c480d0415..0f9c23e261 100644
--- a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/StartupServiceTest.java
+++ b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/StartupServiceTest.java
@@ -21,11 +21,14 @@
package org.onap.so.adapters.vevnfm.service;
import static org.mockito.Mockito.*;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.aai.domain.yang.EsrSystemInfo;
import org.onap.so.adapters.vevnfm.aai.AaiConnection;
import org.onap.so.adapters.vevnfm.exception.VeVnfmException;
@@ -41,38 +44,46 @@ public class StartupServiceTest {
@InjectMocks
private StartupService startupService;
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
@Test
public void testSuccess() throws Exception {
// given
- final String endpoint = "lh";
-
- when(aaiConnection.receiveVnfm()).thenReturn(endpoint);
- when(subscriberService.subscribe(endpoint)).thenReturn(true);
+ final EsrSystemInfo info = new EsrSystemInfo();
+ info.setServiceUrl("lh");
+ when(aaiConnection.receiveVnfm()).thenReturn(info);
+ when(subscriberService.subscribe(info)).thenReturn(true);
// when
startupService.run();
// then
verify(aaiConnection, times(1)).receiveVnfm();
- verify(subscriberService, times(1)).subscribe(endpoint);
+ verify(subscriberService, times(1)).subscribe(info);
}
- @Test(expected = VeVnfmException.class)
+ @Test
public void testFailureAai() throws Exception {
// given
- when(aaiConnection.receiveVnfm()).thenReturn(null);
+ final EsrSystemInfo info = new EsrSystemInfo();
+ when(aaiConnection.receiveVnfm()).thenReturn(info);
+
+ thrown.expect(VeVnfmException.class);
// when
startupService.run();
}
- @Test(expected = VeVnfmException.class)
+ @Test
public void testFailureSubscriber() throws Exception {
// given
- final String endpoint = "lh";
+ final EsrSystemInfo info = new EsrSystemInfo();
+ info.setServiceUrl("lh");
+ when(aaiConnection.receiveVnfm()).thenReturn(info);
+ when(subscriberService.subscribe(info)).thenReturn(false);
- when(aaiConnection.receiveVnfm()).thenReturn(endpoint);
- when(subscriberService.subscribe(endpoint)).thenReturn(false);
+ thrown.expect(VeVnfmException.class);
// when
startupService.run();
diff --git a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/subscription/SubscribeSenderTest.java b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/subscription/SubscribeSenderTest.java
index 62a624a983..d1fda0eee6 100644
--- a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/subscription/SubscribeSenderTest.java
+++ b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/subscription/SubscribeSenderTest.java
@@ -31,6 +31,7 @@ import org.hamcrest.CoreMatchers;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.onap.aai.domain.yang.EsrSystemInfo;
import org.onap.so.adapters.vevnfm.configuration.StartupConfiguration;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest;
import org.springframework.beans.factory.annotation.Autowired;
@@ -79,16 +80,17 @@ public class SubscribeSenderTest {
@Test
public void testSuccess() {
// given
- final String endpoint = "lh";
+ final EsrSystemInfo info = new EsrSystemInfo();
+ info.setServiceUrl("lh");
final LccnSubscriptionRequest request = new LccnSubscriptionRequest();
- mockRestServer.expect(once(), requestTo(SLASH + endpoint + vnfmSubscription))
+ mockRestServer.expect(once(), requestTo(SLASH + info.getServiceUrl() + vnfmSubscription))
.andExpect(header(CONTENT_TYPE, CoreMatchers.containsString(MediaType.APPLICATION_JSON_VALUE)))
.andExpect(method(HttpMethod.POST)).andExpect(content().json(GSON.toJson(request)))
.andRespond(withStatus(HttpStatus.CREATED).body(MINIMAL_JSON_CONTENT));
// when
- final boolean done = sender.send(endpoint, request);
+ final boolean done = sender.send(info, request);
// then
assertTrue(done);