diff options
Diffstat (limited to 'adapters/mso-ve-vnfm-adapter/src/test')
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); |