aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorakanshad <akansha.dua@amdocs.com>2019-03-14 18:19:26 +0530
committerakanshad <akansha.dua@amdocs.com>2019-03-15 17:05:41 +0530
commit61bc7f0724de5df59d70ec32c8f11f62e7c42feb (patch)
tree12f157c4794083f7f9a38495f03f0de91ff77a6c /src/test
parent6df9f124121aa094bc69fddbe6840b278bdfc8e1 (diff)
Service Catalog - json schema reference
Issue-ID: EXTAPI-105 Change-Id: I4877636508135a2f7a77dab86dbe6a126070e9ff Signed-off-by: akanshad <akansha.dua@amdocs.com>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessorTest.java81
-rw-r--r--src/test/resources/karatetest/features/00--ServiceCatalog.feature17
2 files changed, 82 insertions, 16 deletions
diff --git a/src/test/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessorTest.java b/src/test/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessorTest.java
index 8849607..68a955f 100644
--- a/src/test/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessorTest.java
+++ b/src/test/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessorTest.java
@@ -20,26 +20,35 @@ import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.onap.nbi.exceptions.TechnicalException;
import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+@RunWith(SpringRunner.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
+@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
+@ActiveProfiles("test")
public class ToscaInfosProcessorTest {
+ @Autowired
+ ToscaInfosProcessor toscaInfosProcessor;
final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); // jackson databind
- ToscaInfosProcessor toscaInfosProcessor = new ToscaInfosProcessor();
-
-
@Test
public void buildResponseWithSdcToscaParser() {
ClassLoader classLoader = getClass().getClassLoader();
Path path = new File(
- classLoader.getResource("toscafile/service-Sdwanvpninfraservice-csar.csar").getFile())
+ classLoader.getResource("toscafile/service-Sdwanvpninfraservice-csar.csar").getFile())
.toPath().toAbsolutePath();
List<LinkedHashMap> resources = new ArrayList<>();
LinkedHashMap resource1 = new LinkedHashMap();
@@ -55,22 +64,22 @@ public class ToscaInfosProcessorTest {
toscaInfosProcessor.buildResponseWithSdcToscaParser(path, response);
} catch (SdcToscaParserException e) {
throw new TechnicalException("unable to build response from tosca csar using sdc-parser : "
- + path.toString() + " " + e.getMessage());
+ + path.toString() + " " + e.getMessage());
}
resources = (List<LinkedHashMap>) response.get("resourceSpecification");
List<LinkedHashMap> serviceSpecCharacteristic = new ArrayList<>();
serviceSpecCharacteristic = (List<LinkedHashMap>) response.get("serviceSpecCharacteristic");
assertThat(serviceSpecCharacteristic.get(0).get("name"))
- .isEqualTo("sdwanconnectivity0_topology");
+ .isEqualTo("sdwanconnectivity0_topology");
assertThat(serviceSpecCharacteristic.get(1).get("valueType")).isEqualTo("string");
assertThat(serviceSpecCharacteristic.get(0).get("required")).isEqualTo(true);
assertThat(serviceSpecCharacteristic.get(1).get("name")).isEqualTo("sdwanconnectivity0_name");
assertThat(serviceSpecCharacteristic.get(1).get("valueType")).isEqualTo("string");
assertThat(serviceSpecCharacteristic.get(1).get("required")).isEqualTo(true);
assertThat(resources.get(0).get("modelCustomizationId"))
- .isEqualTo("94ec574b-2306-4cbd-8214-09662b040f73");
+ .isEqualTo("94ec574b-2306-4cbd-8214-09662b040f73");
assertThat(resources.get(1).get("modelCustomizationId"))
- .isEqualTo("a7baba5d-6ac3-42b5-b47d-070841303ab1");
+ .isEqualTo("a7baba5d-6ac3-42b5-b47d-070841303ab1");
}
@@ -79,7 +88,7 @@ public class ToscaInfosProcessorTest {
ClassLoader classLoader = getClass().getClassLoader();
Path path = new File(
- classLoader.getResource("toscafile/service-Sotnvpninfraservice-csar.csar").getFile())
+ classLoader.getResource("toscafile/service-Sotnvpninfraservice-csar.csar").getFile())
.toPath().toAbsolutePath();
List<LinkedHashMap> resources = new ArrayList<>();
LinkedHashMap resource1 = new LinkedHashMap();
@@ -95,15 +104,15 @@ public class ToscaInfosProcessorTest {
toscaInfosProcessor.buildResponseWithSdcToscaParser(path, response);
} catch (SdcToscaParserException e) {
throw new TechnicalException("unable to build response from tosca csar using sdc-parser : "
- + path.toString() + " " + e.getMessage());
+ + path.toString() + " " + e.getMessage());
}
resources = (List<LinkedHashMap>) response.get("resourceSpecification");
List<LinkedHashMap> serviceSpecCharacteristic = new ArrayList<>();
serviceSpecCharacteristic = (List<LinkedHashMap>) response.get("serviceSpecCharacteristic");
assertThat(resources.get(0).get("modelCustomizationId"))
- .isEqualTo("b44071c8-04fd-4d6b-b6af-772cbfaa1129");
+ .isEqualTo("b44071c8-04fd-4d6b-b6af-772cbfaa1129");
assertThat(resources.get(1).get("modelCustomizationId"))
- .isEqualTo("c3612284-6c67-4d8c-8b41-b699cc90e76d");
+ .isEqualTo("c3612284-6c67-4d8c-8b41-b699cc90e76d");
assertThat(serviceSpecCharacteristic.get(12).get("serviceSpecCharacteristicValue")).isNull();
assertThat(serviceSpecCharacteristic.get(13).get("serviceSpecCharacteristicValue")).isNotNull();
}
@@ -113,7 +122,7 @@ public class ToscaInfosProcessorTest {
ClassLoader classLoader = getClass().getClassLoader();
Path path = new File(
- classLoader.getResource("toscafile/service-Sdwanvpninfraservice-csar.csar").getFile())
+ classLoader.getResource("toscafile/service-Sdwanvpninfraservice-csar.csar").getFile())
.toPath().toAbsolutePath();
List<LinkedHashMap> resources = new ArrayList<>();
LinkedHashMap resource1 = new LinkedHashMap();
@@ -129,13 +138,13 @@ public class ToscaInfosProcessorTest {
toscaInfosProcessor.buildResponseWithSdcToscaParser(path, response);
} catch (SdcToscaParserException e) {
throw new TechnicalException("unable to build response from tosca csar using sdc-parser : "
- + path.toString() + " " + e.getMessage());
+ + path.toString() + " " + e.getMessage());
}
resources = (List<LinkedHashMap>) response.get("resourceSpecification");
List<LinkedHashMap> serviceSpecCharacteristic = new ArrayList<>();
serviceSpecCharacteristic = (List<LinkedHashMap>) response.get("serviceSpecCharacteristic");
assertThat(serviceSpecCharacteristic.get(0).get("name"))
- .isEqualTo("sdwanconnectivity0_topology");
+ .isEqualTo("sdwanconnectivity0_topology");
assertThat(serviceSpecCharacteristic.get(1).get("valueType")).isEqualTo("string");
assertThat(serviceSpecCharacteristic.get(0).get("required")).isEqualTo(true);
assertThat(serviceSpecCharacteristic.get(1).get("name")).isEqualTo("sdwanconnectivity0_name");
@@ -146,4 +155,46 @@ public class ToscaInfosProcessorTest {
assertThat(resources.get(1).get("modelCustomizationId")).isNull();
}
+
+ @Test
+ public void testBuildAndSaveResponseWithSdcToscaParser() {
+
+ ClassLoader classLoader = getClass().getClassLoader();
+ Path path = new File(classLoader.getResource("toscafile/service-Sotnvpninfraservice-csar.csar").getFile()).toPath().toAbsolutePath();
+
+ LinkedHashMap response = new LinkedHashMap();
+ response.put("version", "1.0");
+ response.put("name", "Service_vMME");
+ response.put("description", "some service characteristics schema");
+ response.put("id", "7f5e5139-768d-4410-a871-c41430785214");
+
+ List<LinkedHashMap> resources = new ArrayList<>();
+ LinkedHashMap resource1 = new LinkedHashMap();
+ resource1.put("id", "7baa7742-3a13-4288-8330-868015adc340");
+ resources.add(resource1);
+ LinkedHashMap resource2 = new LinkedHashMap();
+ resource2.put("id", "81b9430b-8abe-45d6-8bf9-f41a8f5c735f");
+ resources.add(resource2);
+
+ response.put("resourceSpecification", resources);
+
+ LinkedHashMap serviceSpecCharacteristicValue = new LinkedHashMap();
+ serviceSpecCharacteristicValue.put("valueType","Object");
+ serviceSpecCharacteristicValue.put("@schemaLocation","/serviceSpecification/7f5e5139-768d-4410-a871-c41430785214/specificationInputSchema");
+ serviceSpecCharacteristicValue.put("@type","Service_vMME_ServiceCharacteristic");
+
+ LinkedHashMap serviceSpecCharacteristic = new LinkedHashMap();
+ serviceSpecCharacteristic.put("name","Service_vMME_ServiceCharacteristics");
+ serviceSpecCharacteristic.put("description", "This object describes all the inputs needed from the client to interact with the Service_vMME Service Topology");
+ serviceSpecCharacteristic.put("valueType","Object");
+ serviceSpecCharacteristic.put("@type","ONAPServiceCharacteristic");
+ serviceSpecCharacteristic.put("@schemaLocation","null");
+ serviceSpecCharacteristic.put("serviceSpecCharacteristicValue",serviceSpecCharacteristicValue);
+ try {
+ toscaInfosProcessor.buildAndSaveResponseWithSdcToscaParser(path, response);
+ } catch (SdcToscaParserException ex) {
+ throw new TechnicalException("unable to build response " + ex.getMessage());
+ }
+ assertThat(response.get("serviceSpecCharacteristic")).isEqualTo(serviceSpecCharacteristic);
+ }
}
diff --git a/src/test/resources/karatetest/features/00--ServiceCatalog.feature b/src/test/resources/karatetest/features/00--ServiceCatalog.feature
index 2a40526..27807ac 100644
--- a/src/test/resources/karatetest/features/00--ServiceCatalog.feature
+++ b/src/test/resources/karatetest/features/00--ServiceCatalog.feature
@@ -23,7 +23,22 @@ Given path 'serviceSpecification','462f84e5-f0e5-44c5-ab95-38fb4bf77064'
When method get
Then status 200
And match $ contains { id : '462f84e5-f0e5-44c5-ab95-38fb4bf77064' , name : 'vFW' , invariantUUID : 'b58a118e-eeb9-4f6e-bdca-e292f84d17df' , toscaModelURL : '/sdc/v1/catalog/services/462f84e5-f0e5-44c5-ab95-38fb4bf77064/toscaModel' , distributionStatus : 'DISTRIBUTED' , version : '2.0' , lifecycleStatus : 'CERTIFIED' , @type : 'ONAPservice' , attachment : '#array' , relatedParty : '#notnull' , resourceSpecification : '#array' }
-And match $.serviceSpecCharacteristic[0] contains { name : 'sdwanconnectivity0_topology', description : 'full mesh, hub-spoke', valueType : 'string', required : '#boolean', serviceSpecCharacteristicValue : '#null' }
+And match $.serviceSpecCharacteristic contains
+"""
+{
+ name : 'vFW_ServiceCharacteristics',
+ description : 'This object describes all the inputs needed from the client to interact with the vFW Service Topology',
+ valueType : 'Object',
+ @type : 'ONAPServiceCharacteristic',
+ @schemaLocation : 'null',
+ serviceSpecCharacteristicValue :
+ {
+ valueType : 'Object',
+ @schemaLocation : '/serviceSpecification/462f84e5-f0e5-44c5-ab95-38fb4bf77064/specificationInputSchema',
+ @type : 'vFW_ServiceCharacteristic',
+ }
+}
+"""
Scenario: findServiceCatalog
Given path 'serviceSpecification'