diff options
Diffstat (limited to 'src/test/java/org/onap/nbi/apis/servicecatalog')
-rw-r--r-- | src/test/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessorTest.java | 53 |
1 files changed, 29 insertions, 24 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 68a955f..0043a8a 100644 --- a/src/test/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessorTest.java +++ b/src/test/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessorTest.java @@ -23,13 +23,13 @@ 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; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; @RunWith(SpringRunner.class) @@ -48,7 +48,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(); @@ -64,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"); } @@ -88,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(); @@ -104,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(); } @@ -122,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(); @@ -138,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"); @@ -160,7 +160,9 @@ public class ToscaInfosProcessorTest { public void testBuildAndSaveResponseWithSdcToscaParser() { ClassLoader classLoader = getClass().getClassLoader(); - Path path = new File(classLoader.getResource("toscafile/service-Sotnvpninfraservice-csar.csar").getFile()).toPath().toAbsolutePath(); + Path path = new File( + classLoader.getResource("toscafile/service-Sotnvpninfraservice-csar.csar").getFile()) + .toPath().toAbsolutePath(); LinkedHashMap response = new LinkedHashMap(); response.put("version", "1.0"); @@ -179,17 +181,20 @@ public class ToscaInfosProcessorTest { 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"); + 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); + 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"); + // using object to match examples in specifications + serviceSpecCharacteristic.put("valueType", "object"); + serviceSpecCharacteristic.put("@type", "ONAPServiceCharacteristic"); + serviceSpecCharacteristic.put("@schemaLocation", "null"); + serviceSpecCharacteristic.put("serviceSpecCharacteristicValue", serviceSpecCharacteristicValue); try { toscaInfosProcessor.buildAndSaveResponseWithSdcToscaParser(path, response); } catch (SdcToscaParserException ex) { |