diff options
author | romaingimbert <romain.gimbert@orange.com> | 2018-08-03 10:04:46 +0200 |
---|---|---|
committer | romaingimbert <romain.gimbert@orange.com> | 2018-08-03 10:04:46 +0200 |
commit | 9e34db4166287c48d8aaccc680eee0f0d5714f8b (patch) | |
tree | 58a3552e3c1e44f5e0217b5876da83ff710fdff2 /src/test/java | |
parent | 048e7e70e305279fc9cdcba4ae70d116f1f1c8b6 (diff) |
rollback EXTAPI-108 call tosca
Change-Id: Icfe3594f7b34b7dabdc7941ce5fff3b52fd4703f
Issue-ID: EXTAPI-108
Signed-off-by: romaingimbert <romain.gimbert@orange.com>
Diffstat (limited to 'src/test/java')
-rw-r--r-- | src/test/java/org/onap/nbi/apis/ApiTest.java | 16 | ||||
-rw-r--r-- | src/test/java/org/onap/nbi/apis/assertions/ServiceCatalogAssertions.java | 67 |
2 files changed, 74 insertions, 9 deletions
diff --git a/src/test/java/org/onap/nbi/apis/ApiTest.java b/src/test/java/org/onap/nbi/apis/ApiTest.java index 78d5b2a..5e07486 100644 --- a/src/test/java/org/onap/nbi/apis/ApiTest.java +++ b/src/test/java/org/onap/nbi/apis/ApiTest.java @@ -136,15 +136,25 @@ public class ApiTest { @Test - public void testServiceCatalogGetResource() throws Exception { + @Ignore + public void testServiceResourceGetCatalog() throws Exception { - ResponseEntity<Object> resource = serviceSpecificationResource - .getServiceSpecification("1e3feeb0-8e36-46c6-862c-236d9c626439", null); + ResponseEntity<Object> resource = + serviceSpecificationResource.getServiceSpecification("1e3feeb0-8e36-46c6-862c-236d9c626439", null); ServiceCatalogAssertions.assertGetServiceCatalog(resource); } @Test + public void testServiceCatalogGetResourceWithoutTosca() throws Exception { + + ResponseEntity<Object> resource = serviceSpecificationResource + .getServiceSpecification("1e3feeb0-8e36-46c6-862c-236d9c626439_withoutTosca", null); + ServiceCatalogAssertions.assertGetServiceCatalogWithoutTosca(resource); + + } + + @Test public void testServiceCatalogFind() throws Exception { ResponseEntity<Object> resource = serviceSpecificationResource.findServiceSpecification(null); diff --git a/src/test/java/org/onap/nbi/apis/assertions/ServiceCatalogAssertions.java b/src/test/java/org/onap/nbi/apis/assertions/ServiceCatalogAssertions.java index 8e527c8..3789c8f 100644 --- a/src/test/java/org/onap/nbi/apis/assertions/ServiceCatalogAssertions.java +++ b/src/test/java/org/onap/nbi/apis/assertions/ServiceCatalogAssertions.java @@ -54,16 +54,71 @@ public class ServiceCatalogAssertions { assertThat(resource1.get("@type")).isEqualTo("ONAPresource"); assertThat(resource1.get("modelCustomizationName")).isEqualTo("vFW-vSINK 0"); - LinkedHashMap serviceSpecCharacteristic = (LinkedHashMap) service.get("serviceSpecCharacteristic"); - assertThat(serviceSpecCharacteristic.get("valueType")).isEqualTo("complex"); - assertThat(serviceSpecCharacteristic.get("@type")).isEqualTo("serviceSpecInputSchema"); - String serviceSpecInputSchema=serviceSpecCharacteristic.get("serviceSpecInputSchema").toString(); - String serviceSpecInputSchemaUrl= serviceSpecInputSchema.substring(serviceSpecInputSchema.indexOf("/nbi"),serviceSpecInputSchema.length()); - assertThat(serviceSpecInputSchemaUrl).isEqualTo("/nbi/api/v1/serviceSpecification/1e3feeb0-8e36-46c6-862c-236d9c626439/serviceSpecInputSchema"); + assertThat(((ArrayList) service.get("serviceSpecCharacteristic")).size()).isEqualTo(4); + ArrayList serviceSPecCharacteristics = (ArrayList) service.get("serviceSpecCharacteristic"); + for (Object serviceSPecCharacteristic : serviceSPecCharacteristics) { + LinkedHashMap serviceSPecCharacteristicMap = (LinkedHashMap) serviceSPecCharacteristic; + if (serviceSPecCharacteristicMap.get("name").toString().equals("cpus")) { + assertThat(serviceSPecCharacteristicMap.get("valueType")).isEqualTo("integer"); + assertThat(serviceSPecCharacteristicMap.get("@type")).isEqualTo("ONAPserviceCharacteristic"); + ArrayList serviceSpecCharacteristicValues = + (ArrayList) serviceSPecCharacteristicMap.get("serviceSpecCharacteristicValue"); + for (Object serviceSpecCharacteristicValue : serviceSpecCharacteristicValues) { + LinkedHashMap serviceSpecCharacteristicValueMap = (LinkedHashMap) serviceSpecCharacteristicValue; + if (serviceSpecCharacteristicValueMap.get("value").toString().equals("2")) { + assertThat(serviceSpecCharacteristicValueMap.get("isDefault")).isEqualTo(true); + assertThat(serviceSpecCharacteristicValueMap.get("valueType")).isEqualTo("integer"); + } else { + assertThat(serviceSpecCharacteristicValueMap.get("isDefault")).isEqualTo(false); + assertThat(serviceSpecCharacteristicValueMap.get("valueType")).isEqualTo("integer"); + } + } + } + } } + + + public static void assertGetServiceCatalogWithoutTosca(ResponseEntity<Object> resource) { + assertThat(resource.getStatusCode()).isEqualTo(HttpStatus.PARTIAL_CONTENT); + LinkedHashMap service = (LinkedHashMap) resource.getBody(); + assertThat(service.get("id")).isEqualTo("1e3feeb0-8e36-46c6-862c-236d9c626439"); + assertThat(service.get("name")).isEqualTo("vFW"); + assertThat(service.get("invariantUUID")).isEqualTo("b58a118e-eeb9-4f6e-bdca-e292f84d17df"); + assertThat(service.get("toscaModelURL")) + .isEqualTo("/sdc/v1/catalog/services/1e3feeb0-8e36-46c6-862c-236d9c626439toto/toscaModel"); + assertThat(service.get("distributionStatus")).isEqualTo("DISTRIBUTED"); + assertThat(service.get("version")).isEqualTo("2.0"); + assertThat(service.get("lifecycleStatus")).isEqualTo("CERTIFIED"); + assertThat(service.get("@type")).isEqualTo("ONAPservice"); + assertThat(((ArrayList) service.get("attachment")).size()).isEqualTo(5); + LinkedHashMap relatedParty = (LinkedHashMap) service.get("relatedParty"); + assertThat(relatedParty.get("name")).isEqualTo("Joni Mitchell"); + assertThat(relatedParty.get("role")).isEqualTo("lastUpdater"); + + + assertThat(((ArrayList) service.get("resourceSpecification")).size()).isEqualTo(2); + LinkedHashMap resource1 = (LinkedHashMap) ((ArrayList) service.get("resourceSpecification")).get(0); + assertThat(resource1.get("name")).isEqualTo("vFW-vSINK"); + assertThat(resource1.get("resourceInstanceName")).isEqualTo("vFW-vSINK 0"); + assertThat(resource1.get("resourceType")).isEqualTo("VF"); + assertThat(resource1.get("resourceInvariantUUID")).isEqualTo("18b90934-aa82-456f-938e-e74a07a426f3"); + assertThat(resource1.get("@type")).isEqualTo("ONAPresource"); + assertThat(resource1.get("modelCustomizationName")).isEqualTo("vFW-vSINK 0"); + assertThat(service.get("serviceSpecCharacteristic")).isNull(); + } + + + + + + + + + + public static void assertFindServiceCatalog(ResponseEntity<Object> resource) { assertThat(resource.getStatusCode()).isEqualTo(HttpStatus.OK); ArrayList body = (ArrayList) resource.getBody(); |