diff options
Diffstat (limited to 'plans/so/integration-etsi-testing/so-simulators/aai-simulator')
3 files changed, 41 insertions, 11 deletions
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CustomerCacheServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CustomerCacheServiceProviderImpl.java index 1d12a94d..5c022c95 100644 --- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CustomerCacheServiceProviderImpl.java +++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CustomerCacheServiceProviderImpl.java @@ -101,16 +101,20 @@ public class CustomerCacheServiceProviderImpl extends AbstractCacheServiceProvid if (serviceSubscription.isPresent()) { LOGGER.info("Found service subscription ..."); - final List<ServiceInstance> serviceInstancesList = serviceSubscription.get().getServiceInstances() - .getServiceInstance().stream() - .filter(serviceInstance -> serviceInstanceName.equals(serviceInstance.getServiceInstanceName())) - .collect(Collectors.toList()); - if (serviceInstancesList != null && !serviceInstancesList.isEmpty()) { - LOGGER.info("Found {} service instances ", serviceInstancesList.size()); - final ServiceInstances serviceInstances = new ServiceInstances(); - serviceInstances.getServiceInstance().addAll(serviceInstancesList); - return Optional.of(serviceInstances); - + final ServiceInstances serviceInstances = serviceSubscription.get().getServiceInstances(); + if (serviceInstances != null) { + final List<ServiceInstance> serviceInstancesList = + serviceInstances.getServiceInstance().stream() + .filter(serviceInstance -> serviceInstanceName + .equals(serviceInstance.getServiceInstanceName())) + .collect(Collectors.toList()); + if (serviceInstancesList != null && !serviceInstancesList.isEmpty()) { + LOGGER.info("Found {} service instances ", serviceInstancesList.size()); + final ServiceInstances result = new ServiceInstances(); + result.getServiceInstance().addAll(serviceInstancesList); + return Optional.of(result); + + } } } } diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/resources/application.yaml b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/resources/application.yaml index 25be8dab..de819447 100644 --- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/resources/application.yaml +++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/resources/application.yaml @@ -13,4 +13,8 @@ spring: - username: aai #password: aai.onap.org:demo123456! password: $2a$04$crRntT01fAF4kb48mxlvgu68/silcLg.czC1LxQsKTdWuDBPpO3YO + role: VID + - username: aai@aai.onap.org + #password: demo123456! + password: $2a$04$06VCpDvW5ztE7WOvhhvAtOx7JHLghECyZIzOShIbXLWpnshMva8T6 role: VID
\ No newline at end of file diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/BusinessControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/BusinessControllerTest.java index ef49716a..e7d07859 100644 --- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/BusinessControllerTest.java +++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/BusinessControllerTest.java @@ -192,7 +192,7 @@ public class BusinessControllerTest { invokeHttpPut(url, getServiceInstance()); final String serviceInstanceUrl = getCustomerEndPointUrl() + SERVICE_SUBSCRIPTIONS_URL + SERVICE_INSTANCES_URL - + "?service-instance-name=" + SERVICE_NAME; + + "?depth=2&service-instance-name=" + SERVICE_NAME; final ResponseEntity<ServiceInstances> actual = restTemplate.exchange(serviceInstanceUrl, HttpMethod.GET, new HttpEntity<>(getHttpHeaders()), ServiceInstances.class); @@ -208,6 +208,28 @@ public class BusinessControllerTest { } @Test + public void test_getSericeInstance_usingServiceInstanceName_returnRequestErrorIfnoServiceInstanceFound() + throws Exception { + + + final ResponseEntity<Void> response = invokeHttpPut(getCustomerEndPointUrl(), getCustomer()); + + assertEquals(HttpStatus.ACCEPTED, response.getStatusCode()); + + final String serviceInstanceUrl = getCustomerEndPointUrl() + SERVICE_SUBSCRIPTIONS_URL + SERVICE_INSTANCES_URL + + "?depth=2&service-instance-name=" + SERVICE_NAME; + + final ResponseEntity<RequestError> actual = restTemplate.exchange(serviceInstanceUrl, HttpMethod.GET, + new HttpEntity<>(getHttpHeaders()), RequestError.class); + + assertEquals(HttpStatus.NOT_FOUND, actual.getStatusCode()); + assertTrue(actual.hasBody()); + + assertNotNull(actual.getBody().getServiceException()); + + } + + @Test public void test_getSericeInstance_usingServiceInstanceId_ableToRetrieveServiceInstanceFromCache() throws Exception { |