diff options
author | Wojciech Sliwka <wojciech.sliwka@nokia.com> | 2019-06-25 11:42:46 +0200 |
---|---|---|
committer | Wojciech Sliwka <wojciech.sliwka@nokia.com> | 2019-07-01 09:24:34 +0200 |
commit | 4751c29632d2f32abba85dd91296fb91672a2f59 (patch) | |
tree | 970fcde9591168089bda86ee2a5453c5eb693f03 /vid-app-common/src/test | |
parent | 72b3fb69e548cf665204ec025d2778dcf3ce0216 (diff) |
Extend probe mechanism
Fixes from latest review.
Introduce probe interface.
ResponseWithRequestInfo is not used - it belongs to aai package and requires javax.ws.rs.core.Response.
Fallback in aai client will be removed as soon as sdc provides https support (hopefully in El Alto).
Change-Id: I4527d447a273328d38ff2ef7f9d2a93453cec9f2
Issue-ID: VID-490
Signed-off-by: Wojciech Sliwka <wojciech.sliwka@nokia.com>
Diffstat (limited to 'vid-app-common/src/test')
6 files changed, 16 insertions, 16 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java index b98e20010..fdeeb0076 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java @@ -146,8 +146,8 @@ public class AaiClientTest { new AaiResponseWithRequestInfo<>( HttpMethod.GET, "url", new AaiResponse<>(subscribers, null, 200), "rawData")); - Mockito.when(aaiClientMock.probeAaiGetAllSubscribers()).thenCallRealMethod(); - ExternalComponentStatus result = aaiClientMock.probeAaiGetAllSubscribers(); + Mockito.when(aaiClientMock.probeComponent()).thenCallRealMethod(); + ExternalComponentStatus result = aaiClientMock.probeComponent(); assertThat(statusDataReflected(result),is(statusDataReflected(expectedStatus))); assertThat(requestMetadataReflected(result.getMetadata()),is(requestMetadataReflected(expectedStatus.getMetadata()))); } @@ -278,8 +278,8 @@ public class AaiClientTest { } private ExternalComponentStatus callProbeAaiGetAllSubscribersAndAssertNotAvailable() { - Mockito.when(aaiClientMock.probeAaiGetAllSubscribers()).thenCallRealMethod(); - ExternalComponentStatus result = aaiClientMock.probeAaiGetAllSubscribers(); + Mockito.when(aaiClientMock.probeComponent()).thenCallRealMethod(); + ExternalComponentStatus result = aaiClientMock.probeComponent(); assertFalse(result.isAvailable()); return result; } diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientTest.java index da937cade..a1b750e53 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientTest.java @@ -102,7 +102,7 @@ public class AaiOverTLSClientTest { when(response.isSuccessful()).thenReturn(true); - ExternalComponentStatus externalComponentStatus = aaiRestClient.probeGetAllSubscribers(); + ExternalComponentStatus externalComponentStatus = aaiRestClient.probeComponent(); assertThat(externalComponentStatus.isAvailable()).isTrue(); assertThat(externalComponentStatus.getComponent()).isEqualTo(ExternalComponentStatus.Component.AAI); @@ -114,7 +114,7 @@ public class AaiOverTLSClientTest { when(syncRestClient.get(contains(SUBSCRIBERS), eq(getHeaders()), eq(Collections.emptyMap()), eq(SubscriberList.class))).thenThrow(new RuntimeException("call failed")); - ExternalComponentStatus externalComponentStatus = aaiRestClient.probeGetAllSubscribers(); + ExternalComponentStatus externalComponentStatus = aaiRestClient.probeComponent(); assertThat(externalComponentStatus.isAvailable()).isFalse(); assertThat(externalComponentStatus.getComponent()).isEqualTo(ExternalComponentStatus.Component.AAI); diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/LocalWebConfig.java b/vid-app-common/src/test/java/org/onap/vid/controller/LocalWebConfig.java index 6a49396ed..7e50c8959 100644 --- a/vid-app-common/src/test/java/org/onap/vid/controller/LocalWebConfig.java +++ b/vid-app-common/src/test/java/org/onap/vid/controller/LocalWebConfig.java @@ -60,8 +60,8 @@ public class LocalWebConfig { @Bean - public VidService vidService(AsdcClient asdcClient, FeatureManager featureManager) { - return new VidServiceImpl(asdcClient, featureManager); + public VidService vidService(AsdcClient asdcClient, ToscaParserImpl2 toscaParserImpl2,FeatureManager featureManager) { + return new VidServiceImpl(asdcClient,toscaParserImpl2, featureManager); } @Bean diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java index 8681ecbce..a7fa8cd13 100644 --- a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java @@ -1398,7 +1398,7 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests { given(msoInterface.getOrchestrationRequest(anyString(),anyString(), anyString(),any(RestObject.class),anyBoolean())).willReturn(wrapper); - ExternalComponentStatus externalComponentStatus = msoBusinessLogic.probeGetOrchestrationRequests(); + ExternalComponentStatus externalComponentStatus = msoBusinessLogic.probeComponent(); assertThat(externalComponentStatus.isAvailable()).isTrue(); assertThat(externalComponentStatus.getComponent()).isEqualTo(ExternalComponentStatus.Component.MSO); diff --git a/vid-app-common/src/test/java/org/onap/vid/services/SchedulerServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/SchedulerServiceImplTest.java index b959fa6af..fd562ace1 100644 --- a/vid-app-common/src/test/java/org/onap/vid/services/SchedulerServiceImplTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/services/SchedulerServiceImplTest.java @@ -123,7 +123,7 @@ public class SchedulerServiceImplTest extends AbstractTestNGSpringContextTests { restObjectWithRequestInfo ); - final ExternalComponentStatus schedulerStatus = schedulerService.probeGetSchedulerChangeManagements(); + final ExternalComponentStatus schedulerStatus = schedulerService.probeComponent(); assertSchedulerStatus(schedulerStatus, true); assertMetadata(schedulerStatus, 200, startsWith(responseString.substring(0, 400)), "my pretty url", equalTo("OK")); @@ -142,7 +142,7 @@ public class SchedulerServiceImplTest extends AbstractTestNGSpringContextTests { restObjectWithRequestInfo ); - final ExternalComponentStatus schedulerStatus = schedulerService.probeGetSchedulerChangeManagements(); + final ExternalComponentStatus schedulerStatus = schedulerService.probeComponent(); assertSchedulerStatus(schedulerStatus, true); @@ -160,7 +160,7 @@ public class SchedulerServiceImplTest extends AbstractTestNGSpringContextTests { when(changeManagementService.getSchedulerChangeManagementsWithRequestInfo()).thenThrow(new ExceptionWithRequestInfo(HttpMethod.GET, "my pretty url", responseString, 200, new JsonParseException(null, "Unrecognized token"))); - final ExternalComponentStatus schedulerStatus = schedulerService.probeGetSchedulerChangeManagements(); + final ExternalComponentStatus schedulerStatus = schedulerService.probeComponent(); assertSchedulerStatus(schedulerStatus, false); @@ -172,7 +172,7 @@ public class SchedulerServiceImplTest extends AbstractTestNGSpringContextTests { when(changeManagementService.getSchedulerChangeManagementsWithRequestInfo()).thenThrow( new GenericUncheckedException(new NotFoundException("Get with status = 400"))); - final ExternalComponentStatus schedulerStatus = schedulerService.probeGetSchedulerChangeManagements(); + final ExternalComponentStatus schedulerStatus = schedulerService.probeComponent(); assertThat(schedulerStatus.isAvailable(), is(false)); assertThat(schedulerStatus.getComponent(), is(SCHEDULER)); diff --git a/vid-app-common/src/test/java/org/onap/vid/services/VidServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/VidServiceImplTest.java index 3cd3aa8a6..4f7faab99 100644 --- a/vid-app-common/src/test/java/org/onap/vid/services/VidServiceImplTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/services/VidServiceImplTest.java @@ -93,7 +93,7 @@ public class VidServiceImplTest { public void initMocks() throws AsdcCatalogException, SdcToscaParserException, IllegalAccessException { MockitoAnnotations.initMocks(this); - vidService = new VidServiceImpl(asdcClientMock, featureManager); + vidService = new VidServiceImpl(asdcClientMock, toscaParserMock, featureManager); FieldUtils.writeField(vidService, "toscaParser", toscaParserMock, true); when(featureManager.isActive(Features.FLAG_SERVICE_MODEL_CACHE)).thenReturn(true); @@ -157,7 +157,7 @@ public class VidServiceImplTest { when(httpResponse.getBody()).thenReturn("sampleBody"); - ExternalComponentStatus externalComponentStatus = vidService.probeSDCConnection(); + ExternalComponentStatus externalComponentStatus = vidService.probeComponent(); assertThat(externalComponentStatus.isAvailable(), is(true)); assertThat(externalComponentStatus.getComponent(), is(ExternalComponentStatus.Component.SDC)); @@ -169,7 +169,7 @@ public class VidServiceImplTest { public void shouldProperlyHandleNotWorkingSDCConnection(){ when(asdcClientMock.checkSDCConnectivity()).thenThrow(new RuntimeException("not working")); - ExternalComponentStatus externalComponentStatus = vidService.probeSDCConnection(); + ExternalComponentStatus externalComponentStatus = vidService.probeComponent(); assertThat(externalComponentStatus.isAvailable(), is(false)); assertThat(externalComponentStatus.getMetadata().getDescription(),containsString("not working")); |