aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraosull01 <adrian.osullivan@huawei.com>2019-03-05 10:43:15 +0000
committeraosull01 <adrian.osullivan@huawei.com>2019-03-05 11:13:55 +0000
commitc28c83fbe81f11ba5b636da29f969b72d58df9b5 (patch)
tree5da61d9ecf8ed91b01b8898428769bf862bbc9f4
parent54f4f123ca4fd37ded22dc7887a4bb7bb468f01b (diff)
Use SDC Tosca Jar to extract and parse SDC CSAR
Change-Id: I0e8261ed338eaafa35bb663f95a19fe97be57652 Issue-ID: EXTAPI-205 Signed-off-by: aosull01 <adrian.osullivan@huawei.com>
-rw-r--r--src/main/java/org/onap/nbi/apis/servicecatalog/ServiceSpecificationService.java94
-rw-r--r--src/main/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessor.java373
-rw-r--r--src/test/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessorTest.java360
-rw-r--r--src/test/resources/__files/toscafile/service-Sdwanvpninfraservice-csar.csarbin0 -> 33640 bytes
-rw-r--r--src/test/resources/karatetest/features/00--ServiceCatalog.feature7
-rw-r--r--src/test/resources/mappings/sdc_get_462f84e5-f0e5-44c5-ab95-38fb4bf77064_toscafile.json10
-rw-r--r--src/test/resources/mappings/sdc_get_462f84e5-f0e5-44c5-ab95-38fb4bf77064_withTosca.json213
7 files changed, 467 insertions, 590 deletions
diff --git a/src/main/java/org/onap/nbi/apis/servicecatalog/ServiceSpecificationService.java b/src/main/java/org/onap/nbi/apis/servicecatalog/ServiceSpecificationService.java
index 228e12d..5e3e4cf 100644
--- a/src/main/java/org/onap/nbi/apis/servicecatalog/ServiceSpecificationService.java
+++ b/src/main/java/org/onap/nbi/apis/servicecatalog/ServiceSpecificationService.java
@@ -1,27 +1,30 @@
/**
- * Copyright (c) 2018 Orange
+ * Copyright (c) 2018 Orange
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
*/
package org.onap.nbi.apis.servicecatalog;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import org.apache.commons.io.FileUtils;
import org.onap.nbi.apis.servicecatalog.jolt.FindServiceSpecJsonTransformer;
import org.onap.nbi.apis.servicecatalog.jolt.GetServiceSpecJsonTransformer;
import org.onap.nbi.apis.serviceorder.ServiceCatalogUrl;
+import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -32,45 +35,56 @@ import org.springframework.util.MultiValueMap;
@Service
public class ServiceSpecificationService {
- @Autowired
- SdcClient sdcClient;
+ @Autowired
+ SdcClient sdcClient;
- @Autowired
- GetServiceSpecJsonTransformer getServiceSpecJsonTransformer;
+ @Autowired
+ GetServiceSpecJsonTransformer getServiceSpecJsonTransformer;
- @Autowired
- FindServiceSpecJsonTransformer findServiceSpecJsonTransformer;
+ @Autowired
+ FindServiceSpecJsonTransformer findServiceSpecJsonTransformer;
- @Autowired
- ToscaInfosProcessor toscaInfosProcessor;
+ @Autowired
+ ToscaInfosProcessor toscaInfosProcessor;
- @Autowired
- private ServiceCatalogUrl serviceCatalogUrl;
+ @Autowired
+ private ServiceCatalogUrl serviceCatalogUrl;
- private static final Logger LOGGER = LoggerFactory.getLogger(ServiceSpecificationService.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(ServiceSpecificationService.class);
- public Map get(String serviceSpecId) {
- Map sdcResponse = sdcClient.callGet(serviceSpecId);
- LinkedHashMap serviceCatalogResponse = (LinkedHashMap) getServiceSpecJsonTransformer.transform(sdcResponse);
- Map toscaInfosTopologyTemplate = toscaInfosProcessor.getToscaInfos(serviceCatalogResponse);
- if (toscaInfosTopologyTemplate != null) {
- LOGGER.debug("tosca file found, retrieving informations");
- toscaInfosProcessor.buildResponseWithToscaInfos(toscaInfosTopologyTemplate, serviceCatalogResponse);
- } else {
- LOGGER.debug("no tosca file found, partial response");
- }
- return serviceCatalogResponse;
+ public Map get(String serviceSpecId) {
+ Map sdcResponse = sdcClient.callGet(serviceSpecId);
+ LinkedHashMap serviceCatalogResponse =
+ (LinkedHashMap) getServiceSpecJsonTransformer.transform(sdcResponse);
+ String toscaModelUrl = (String) sdcResponse.get("toscaModelURL");
+ String serviceId = (String) sdcResponse.get("id");
+ File toscaFile = sdcClient.callGetWithAttachment(toscaModelUrl);
+ Path pathToToscaCsar = toscaFile.toPath().toAbsolutePath();
+ try {
+ toscaInfosProcessor.buildResponseWithSdcToscaParser(pathToToscaCsar, serviceCatalogResponse);
+ } catch (SdcToscaParserException e) {
+ LOGGER.debug("unable to build response from tosca csar using sdc-parser, partial response : "
+ + pathToToscaCsar.toString() + " " + e.getMessage());
}
+ try {
+ if (toscaFile != null) {
+ LOGGER.debug("deleting tosca archive : " + toscaFile.getName());
+ FileUtils.forceDelete(toscaFile);
+ }
+ } catch (IOException e) {
+ LOGGER.error("unable to delete temp directory tosca file for id : " + serviceId, e);
+ }
+ return serviceCatalogResponse;
+ }
- public List<LinkedHashMap> find(MultiValueMap<String, String> parametersMap) {
- List<LinkedHashMap> sdcResponse = sdcClient.callFind(parametersMap);
- List<LinkedHashMap> serviceCatalogResponse = new ArrayList<>();
- if(!CollectionUtils.isEmpty(sdcResponse)){
- serviceCatalogResponse =
- findServiceSpecJsonTransformer.transform(sdcResponse);
- }
- return serviceCatalogResponse;
+ public List<LinkedHashMap> find(MultiValueMap<String, String> parametersMap) {
+ List<LinkedHashMap> sdcResponse = sdcClient.callFind(parametersMap);
+ List<LinkedHashMap> serviceCatalogResponse = new ArrayList<>();
+ if (!CollectionUtils.isEmpty(sdcResponse)) {
+ serviceCatalogResponse = findServiceSpecJsonTransformer.transform(sdcResponse);
}
+ return serviceCatalogResponse;
+ }
}
diff --git a/src/main/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessor.java b/src/main/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessor.java
index 99a1657..fff4444 100644
--- a/src/main/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessor.java
+++ b/src/main/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessor.java
@@ -13,24 +13,11 @@
*/
package org.onap.nbi.apis.servicecatalog;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
import java.nio.file.Path;
-import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-import org.apache.commons.io.FileUtils;
-import org.onap.nbi.exceptions.TechnicalException;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
@@ -40,313 +27,83 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
@Service
public class ToscaInfosProcessor {
- @Autowired
- SdcClient sdcClient;
-
- final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); // jackson databind
-
- private static final Logger LOGGER = LoggerFactory.getLogger(ToscaInfosProcessor.class);
-
- public void buildResponseWithToscaInfos(Map toscaInfosTopologyTemplate,
- Map serviceCatalogResponse) {
- if (toscaInfosTopologyTemplate.get("inputs") != null) {
- ArrayList serviceSpecCharacteristic = new ArrayList();
- LinkedHashMap toscaInfos = (LinkedHashMap) toscaInfosTopologyTemplate.get("inputs");
- Set<Entry<String, LinkedHashMap>> stringLinkedHashMapEntry = (Set<Entry<String, LinkedHashMap>>) toscaInfos
- .entrySet();
-
- for (Map.Entry<String,LinkedHashMap> key :stringLinkedHashMapEntry) {
- String keyString = key.getKey();
- LinkedHashMap inputParameter = key.getValue();
- LinkedHashMap mapParameter = new LinkedHashMap();
- String parameterType = (String) inputParameter.get("type");
- mapParameter.put("name", keyString);
- mapParameter.put("description", inputParameter.get("description"));
- mapParameter.put("valueType", parameterType);
- mapParameter.put("@type", "ONAPserviceCharacteristic");
- mapParameter.put("required", inputParameter.get("required"));
- mapParameter.put("status", inputParameter.get("status"));
- List<LinkedHashMap> serviceSpecCharacteristicValues =
- buildServiceSpecCharacteristicsValues(inputParameter, parameterType);
- mapParameter.put("serviceSpecCharacteristicValue", serviceSpecCharacteristicValues);
- serviceSpecCharacteristic.add(mapParameter);
- }
-
- serviceCatalogResponse.put("serviceSpecCharacteristic", serviceSpecCharacteristic);
- }
- LinkedHashMap nodeTemplate = (LinkedHashMap) toscaInfosTopologyTemplate.get("node_templates");
-
- List<LinkedHashMap> resourceSpecifications =
- (List<LinkedHashMap>) serviceCatalogResponse.get("resourceSpecification");
- for (LinkedHashMap resourceSpecification : resourceSpecifications) {
- if(resourceSpecification.get("id")!=null){
- String id = (String) resourceSpecification.get("id");
- LOGGER.debug("get tosca infos for service id: {}", id);
- LinkedHashMap toscaInfosFromResourceId = getToscaInfosFromResourceUUID(nodeTemplate, id);
- if (toscaInfosFromResourceId != null && toscaInfosFromResourceId.get("customizationUUID")!=null) {
- resourceSpecification.put("modelCustomizationId", toscaInfosFromResourceId.get("customizationUUID"));
- }
- }
- }
- }
-
- public void buildResponseWithSdcToscaParser(Path path, Map serviceCatalogResponse) throws SdcToscaParserException {
-
- SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();
- ISdcCsarHelper sdcCsarHelper = factory.getSdcCsarHelper(path.toFile().getAbsolutePath(),false);
- List<Input> inputs = sdcCsarHelper.getServiceInputs();
- if(inputs != null && inputs.size() > 0) {
- ArrayList serviceSpecCharacteristic = new ArrayList();
- for(Input input : inputs) {
- LinkedHashMap mapParameter = new LinkedHashMap();
- mapParameter.put("name", input.getName());
- mapParameter.put("description", input.getDescription());
- mapParameter.put("valueType", input.getType());
- mapParameter.put("@type", "ONAPserviceCharacteristic");
- mapParameter.put("required", input.isRequired());
- mapParameter.put("status", null);
- mapParameter.put("serviceSpecCharacteristicValue", null);
- // If this Input has a default value, then put it in serviceSpecCharacteristicValue
- if (input.getDefault() != null)
- {
- List<LinkedHashMap> serviceSpecCharacteristicValues =
- buildServiceSpecCharacteristicsValuesFromSdc(input);
- mapParameter.put("serviceSpecCharacteristicValue", serviceSpecCharacteristicValues);
- }
- serviceSpecCharacteristic.add(mapParameter);
- }
- serviceCatalogResponse.put("serviceSpecCharacteristic", serviceSpecCharacteristic);
- }
- List<NodeTemplate> nodeTemplates = sdcCsarHelper.getServiceNodeTemplates();
-
- List<LinkedHashMap> resourceSpecifications =
- (List<LinkedHashMap>) serviceCatalogResponse.get("resourceSpecification");
- for (LinkedHashMap resourceSpecification : resourceSpecifications) {
- if(resourceSpecification.get("id")!=null){
- String id = (String) resourceSpecification.get("id");
- LOGGER.debug("get tosca infos for service id: {}", id);
- NodeTemplate nodeTemplate = null;
- for(NodeTemplate node : nodeTemplates) {
- if(node.getMetaData().getValue("UUID").equals(id)) {
- nodeTemplate = node;
- break;
- }
- }
- if(nodeTemplate == null)
- continue;
- resourceSpecification.put("modelCustomizationId", sdcCsarHelper.getNodeTemplateCustomizationUuid(nodeTemplate));
- }
+ @Autowired
+ SdcClient sdcClient;
+
+ final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); // jackson databind
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ToscaInfosProcessor.class);
+
+
+
+ public void buildResponseWithSdcToscaParser(Path path, Map serviceCatalogResponse)
+ throws SdcToscaParserException {
+
+ SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();
+ ISdcCsarHelper sdcCsarHelper = factory.getSdcCsarHelper(path.toFile().getAbsolutePath(), false);
+ List<Input> inputs = sdcCsarHelper.getServiceInputs();
+ if (inputs != null && inputs.size() > 0) {
+ ArrayList serviceSpecCharacteristic = new ArrayList();
+ for (Input input : inputs) {
+ LinkedHashMap mapParameter = new LinkedHashMap();
+ mapParameter.put("name", input.getName());
+ mapParameter.put("description", input.getDescription());
+ mapParameter.put("valueType", input.getType());
+ mapParameter.put("@type", "ONAPserviceCharacteristic");
+ mapParameter.put("required", input.isRequired());
+ mapParameter.put("status", null);
+ mapParameter.put("serviceSpecCharacteristicValue", null);
+ // If this Input has a default value, then put it in serviceSpecCharacteristicValue
+ if (input.getDefault() != null) {
+ List<LinkedHashMap> serviceSpecCharacteristicValues =
+ buildServiceSpecCharacteristicsValuesFromSdc(input);
+ mapParameter.put("serviceSpecCharacteristicValue", serviceSpecCharacteristicValues);
}
+ serviceSpecCharacteristic.add(mapParameter);
+ }
+ serviceCatalogResponse.put("serviceSpecCharacteristic", serviceSpecCharacteristic);
}
-
-
- private List<LinkedHashMap> buildServiceSpecCharacteristicsValuesFromSdc(Input input) {
-
- List<LinkedHashMap> serviceSpecCharacteristicValues = new ArrayList<>();
- LinkedHashMap serviceSpecCharacteristicValue = new LinkedHashMap();
-
- serviceSpecCharacteristicValue.put("isDefault", true);
- serviceSpecCharacteristicValue.put("value", input.getDefault());
- serviceSpecCharacteristicValue.put("valueType", input.getType());
- serviceSpecCharacteristicValues.add(serviceSpecCharacteristicValue);
-
- return serviceSpecCharacteristicValues;
- }
-
- private List<LinkedHashMap> buildServiceSpecCharacteristicsValues(LinkedHashMap parameter, String parameterType) {
- List<LinkedHashMap> serviceSpecCharacteristicValues = new ArrayList<>();
- if (!"map".equalsIgnoreCase(parameterType) && !"list".equalsIgnoreCase(parameterType)) {
- LOGGER.debug("get tosca infos for serviceSpecCharacteristicValues of type map or string : {}", parameter);
- Object aDefault = parameter.get("default");
- if (parameter.get("entry_schema") != null) {
- ArrayList entrySchema = (ArrayList) parameter.get("entry_schema");
- if (!CollectionUtils.isEmpty(entrySchema)) {
- buildCharacteristicValuesFormShema(parameterType, serviceSpecCharacteristicValues, aDefault,
- entrySchema);
- }
- }
- }
- return serviceSpecCharacteristicValues;
- }
-
- private void buildCharacteristicValuesFormShema(String parameterType,
- List<LinkedHashMap> serviceSpecCharacteristicValues, Object aDefault, ArrayList entrySchema) {
- LinkedHashMap constraints = (LinkedHashMap) entrySchema.get(0);
- if (constraints != null) {
- ArrayList constraintsList = (ArrayList) constraints.get("constraints");
- if (!CollectionUtils.isEmpty(constraintsList)) {
- LinkedHashMap valuesMap = (LinkedHashMap) constraintsList.get(0);
- if (valuesMap != null) {
- List<Object> values = (List<Object>) valuesMap.get("valid_values");
- for (Object value : values) {
- String stringValue = value.toString();
- LinkedHashMap serviceSpecCharacteristicValue = new LinkedHashMap();
- serviceSpecCharacteristicValue.put("isDefault",
- aDefault != null && aDefault.toString().equals(stringValue));
- serviceSpecCharacteristicValue.put("value", stringValue);
- serviceSpecCharacteristicValue.put("valueType", parameterType);
- serviceSpecCharacteristicValues.add(serviceSpecCharacteristicValue);
- }
- }
- }
+ List<NodeTemplate> nodeTemplates = sdcCsarHelper.getServiceNodeTemplates();
+
+ List<LinkedHashMap> resourceSpecifications =
+ (List<LinkedHashMap>) serviceCatalogResponse.get("resourceSpecification");
+ for (LinkedHashMap resourceSpecification : resourceSpecifications) {
+ if (resourceSpecification.get("id") != null) {
+ String id = (String) resourceSpecification.get("id");
+ LOGGER.debug("get tosca infos for service id: {}", id);
+ NodeTemplate nodeTemplate = null;
+ for (NodeTemplate node : nodeTemplates) {
+ if (node.getMetaData().getValue("UUID").equals(id)) {
+ nodeTemplate = node;
+ break;
+ }
}
+ if (nodeTemplate == null)
+ continue;
+ resourceSpecification.put("modelCustomizationId",
+ sdcCsarHelper.getNodeTemplateCustomizationUuid(nodeTemplate));
+ }
}
+ }
- private LinkedHashMap getToscaInfosFromResourceUUID(LinkedHashMap nodeTemplates, String name) {
- if(nodeTemplates!=null) {
- for (Object nodeTemplateObject : nodeTemplates.values()) {
- LinkedHashMap nodeTemplate = (LinkedHashMap) nodeTemplateObject;
- LinkedHashMap metadata = (LinkedHashMap) nodeTemplate.get("metadata");
- if(metadata.get("UUID")!=null && metadata.get("type")!=null) {
- String metadataUUID = (String) metadata.get("UUID");
- String metadataType = (String) metadata.get("type");
- if ("VF".equalsIgnoreCase(metadataType) && name!=null && name.equalsIgnoreCase(metadataUUID)) {
- return metadata;
- }
- }
- }
- }
- return null;
- }
-
+ private List<LinkedHashMap> buildServiceSpecCharacteristicsValuesFromSdc(Input input) {
- public Map getToscaInfos(Map sdcResponse) {
+ List<LinkedHashMap> serviceSpecCharacteristicValues = new ArrayList<>();
+ LinkedHashMap serviceSpecCharacteristicValue = new LinkedHashMap();
- LinkedHashMap topologyTemplate = null;
-
- String toscaModelUrl = (String) sdcResponse.get("toscaModelURL");
- String serviceId = (String) sdcResponse.get("id");
- File toscaFile = sdcClient.callGetWithAttachment(toscaModelUrl);
- Timestamp timestamp = new Timestamp(System.currentTimeMillis());
- String tempFolderName = serviceId + timestamp;
- File folderTemp = null;
-
- try {
- unZipArchive(toscaFile.getName(), tempFolderName);
- folderTemp = new File(tempFolderName);
- LOGGER.debug("temp folder for tosca files : " + folderTemp.getName());
-
- LinkedHashMap toscaMetaFileHashMap = parseToscaFile(tempFolderName + "/TOSCA-Metadata/TOSCA.meta");
- topologyTemplate = getToscaTopologyTemplateNode(tempFolderName, toscaMetaFileHashMap);
- return topologyTemplate;
- } catch (TechnicalException e) {
- LOGGER.error("unable to parse tosca file for id : " + serviceId, e);
- return topologyTemplate;
- }
- finally {
- deleteTempFiles(serviceId, toscaFile, folderTemp);
- }
-
- }
-
- private LinkedHashMap getToscaTopologyTemplateNode(String tempFolderName,LinkedHashMap toscaMetaFileHashMap) {
- LinkedHashMap topologyTemplate = null;
- if (toscaMetaFileHashMap.get("Entry-Definitions") != null) {
- String toscaFilePath = (String) toscaMetaFileHashMap.get("Entry-Definitions");
- LinkedHashMap toscaFileHashMap = parseToscaFile(tempFolderName + "/" + toscaFilePath);
- if (toscaFileHashMap.get("topology_template") != null) {
- topologyTemplate = (LinkedHashMap) toscaFileHashMap.get("topology_template");
- } else {
- LOGGER.error("no Entry-Definitions node in TOSCA.meta");
- }
- } else {
- LOGGER.error("no topology_template node in tosca file");
- }
- return topologyTemplate;
- }
-
-
- private void deleteTempFiles(String serviceId, File toscaFile, File folderTemp) {
- try {
- if(folderTemp!=null){
- LOGGER.debug("deleting temp folder for tosca files : " + folderTemp.getName());
- FileUtils.deleteDirectory(folderTemp);
- }
- LOGGER.debug("deleting tosca archive : " + toscaFile.getName());
- FileUtils.forceDelete(toscaFile);
- } catch (IOException e) {
- LOGGER.error("unable to delete temp directory tosca file for id : " + serviceId, e);
- }
- }
-
- private LinkedHashMap parseToscaFile(String fileName) {
-
- File toscaFile = new File(fileName);
- if (!toscaFile.exists()) {
- throw new TechnicalException("unable to find file : " + fileName);
- }
- try {
- return (LinkedHashMap) mapper.readValue(toscaFile, Object.class);
- } catch (IOException e) {
- LOGGER.warn("unable to parse tosca file : " + fileName, e);
- throw new TechnicalException("Unable to parse tosca file : " + fileName);
-
- } catch (NullPointerException e) {
- LOGGER.warn("unable to find tosca file : " + fileName, e);
- throw new TechnicalException("unable to find tosca file : " + fileName);
- }
- }
-
-
- /**
- * Unzip it
- *
- * @param zipFile input zip file
- * @param outputFolder zip file output folder
- */
- private void unZipArchive(String zipFile, String outputFolder) {
-
- byte[] buffer = new byte[1024];
-
- try {
-
- // create output directory is not exists
- File folder = new File(outputFolder);
- if (!folder.exists()) {
- folder.mkdir();
- }
-
- // get the zip file content
- try (ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFile))) {
- // get the zipped file list entry
- ZipEntry ze = zis.getNextEntry();
-
- while (ze != null) {
-
- String fileName = ze.getName();
- File newFile = new File(outputFolder + File.separator + fileName);
-
- LOGGER.debug("File to unzip : " + newFile.getAbsoluteFile());
-
- // create all non exists folders
- // else you will hit FileNotFoundException for compressed folder
- new File(newFile.getParent()).mkdirs();
-
- try (FileOutputStream fos = new FileOutputStream(newFile)) {
-
- int len;
- while ((len = zis.read(buffer)) > 0) {
- fos.write(buffer, 0, len);
- }
- }
- ze = zis.getNextEntry();
- }
- zis.closeEntry();
- }
-
- LOGGER.debug("Done");
-
- } catch (IOException ex) {
- LOGGER.error("Error while unzipping ToscaModel archive from ONAP", ex);
- throw new TechnicalException("Error while unzipping ToscaModel archive from ONAP");
- }
- }
+ serviceSpecCharacteristicValue.put("isDefault", true);
+ serviceSpecCharacteristicValue.put("value", input.getDefault());
+ serviceSpecCharacteristicValue.put("valueType", input.getType());
+ serviceSpecCharacteristicValues.add(serviceSpecCharacteristicValue);
+ return serviceSpecCharacteristicValues;
+ }
}
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 3a770ae..8849607 100644
--- a/src/test/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessorTest.java
+++ b/src/test/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessorTest.java
@@ -1,273 +1,149 @@
/**
* Copyright (c) 2018 Orange
*
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
*/
package org.onap.nbi.apis.servicecatalog;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertNull;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import java.io.File;
-import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
-
-import org.assertj.core.api.AbstractBooleanAssert;
import org.junit.Test;
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;
public class ToscaInfosProcessorTest {
- final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); // jackson databind
-
- ToscaInfosProcessor toscaInfosProcessor = new ToscaInfosProcessor();
-
-
- private LinkedHashMap parseToscaFile(String fileName) {
-
- File toscaFile = new File(fileName);
- if (!toscaFile.exists()) {
- throw new TechnicalException("unable to find file : " + fileName);
- }
- try {
- return (LinkedHashMap) mapper.readValue(toscaFile, Object.class);
- } catch (IOException e) {
- throw new TechnicalException("Unable to parse tosca file : " + fileName);
+ final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); // jackson databind
- } catch (NullPointerException e) {
- throw new TechnicalException("unable to find tosca file : " + fileName);
- }
- }
-
-
- @Test
- public void buildResponseWithToscaInfos() {
-
- ClassLoader classLoader = getClass().getClassLoader();
- File file = new File(classLoader.getResource("toscafile/service-TestNetwork-template.yml").getFile());
- List<LinkedHashMap> resources = new ArrayList<>();
- LinkedHashMap resource1 = new LinkedHashMap();
- resource1.put("id", "e2b12ac6-cbb6-4517-9c58-b846d1f68caf");
- resources.add(resource1);
- LinkedHashMap toscaFile = parseToscaFile(file.getPath());
- LinkedHashMap response = new LinkedHashMap();
- response.put("resourceSpecification", resources);
- toscaInfosProcessor.buildResponseWithToscaInfos((LinkedHashMap) toscaFile.get("topology_template"), response);
-
- resources = (List<LinkedHashMap>) response.get("resourceSpecification");
- assertNull(resources.get(0).get("modelCustomizationId"));
- assertNull(resources.get(0).get("modelCustomizationName"));
+ ToscaInfosProcessor toscaInfosProcessor = new ToscaInfosProcessor();
- }
-
- @Test
- public void buildResponseWithSdcToscaParser() {
-
- ClassLoader classLoader = getClass().getClassLoader();
- Path path = new File(classLoader.getResource("toscafile/service-Sdwanvpninfraservice-csar.csar").getFile()).toPath().toAbsolutePath();
- 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);
- LinkedHashMap response = new LinkedHashMap();
- response.put("resourceSpecification", resources);
- try {
- toscaInfosProcessor.buildResponseWithSdcToscaParser(path, response);
- }
- catch(SdcToscaParserException e) {
- throw new TechnicalException("unable to build response from tosca csar using sdc-parser : " + 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");
- 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");
- assertThat(resources.get(1).get("modelCustomizationId")).isEqualTo("a7baba5d-6ac3-42b5-b47d-070841303ab1");
-
- }
- @Test
- public void buildResponseWithSdcToscaParserWithDefaultInputs() {
+ @Test
+ public void buildResponseWithSdcToscaParser() {
- ClassLoader classLoader = getClass().getClassLoader();
- Path path = new File(classLoader.getResource("toscafile/service-Sotnvpninfraservice-csar.csar").getFile()).toPath().toAbsolutePath();
- List<LinkedHashMap> resources = new ArrayList<>();
- LinkedHashMap resource1 = new LinkedHashMap();
- resource1.put("id", "218df3c3-50dd-4c26-9e36-4771387bb771");
- resources.add(resource1);
- LinkedHashMap resource2 = new LinkedHashMap();
- resource2.put("id", "81b9430b-8abe-45d6-8bf9-f41a8f5c735f");
- resources.add(resource2);
- LinkedHashMap response = new LinkedHashMap();
- response.put("resourceSpecification", resources);
+ ClassLoader classLoader = getClass().getClassLoader();
+ Path path = new File(
+ classLoader.getResource("toscafile/service-Sdwanvpninfraservice-csar.csar").getFile())
+ .toPath().toAbsolutePath();
+ 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);
+ LinkedHashMap response = new LinkedHashMap();
+ response.put("resourceSpecification", resources);
- try {
- toscaInfosProcessor.buildResponseWithSdcToscaParser(path, response);
- }
- catch(SdcToscaParserException e) {
- throw new TechnicalException("unable to build response from tosca csar using sdc-parser : " + 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");
- assertThat(resources.get(1).get("modelCustomizationId")).isEqualTo("c3612284-6c67-4d8c-8b41-b699cc90e76d");
- assertThat(serviceSpecCharacteristic.get(12).get("serviceSpecCharacteristicValue")).isNull();
- assertThat(serviceSpecCharacteristic.get(13).get("serviceSpecCharacteristicValue")).isNotNull();
+ try {
+ toscaInfosProcessor.buildResponseWithSdcToscaParser(path, response);
+ } catch (SdcToscaParserException e) {
+ throw new TechnicalException("unable to build response from tosca csar using sdc-parser : "
+ + path.toString() + " " + e.getMessage());
}
-
- @Test
- public void buildResponseWithSdcToscaParserwithMetaDataMisMatch() {
-
- ClassLoader classLoader = getClass().getClassLoader();
- Path path = new File(classLoader.getResource("toscafile/service-Sdwanvpninfraservice-csar.csar").getFile()).toPath().toAbsolutePath();
- List<LinkedHashMap> resources = new ArrayList<>();
- LinkedHashMap resource1 = new LinkedHashMap();
- resource1.put("id", "some bad resource id no in TOSCA CSAR");
- resources.add(resource1);
- LinkedHashMap resource2 = new LinkedHashMap();
- resource2.put("id", "some bad resource id no in TOSCA CSAR");
- resources.add(resource2);
- LinkedHashMap response = new LinkedHashMap();
- response.put("resourceSpecification", resources);
-
- try {
- toscaInfosProcessor.buildResponseWithSdcToscaParser(path, response);
- }
- catch(SdcToscaParserException e) {
- throw new TechnicalException("unable to build response from tosca csar using sdc-parser : " + 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");
- 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);
- // Check that resources cannot be found in the TOSCA template
- assertThat(resources.get(0).get("modelCustomizationId")).isNull();
- assertThat(resources.get(1).get("modelCustomizationId")).isNull();
-
+ 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");
+ 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");
+ assertThat(resources.get(1).get("modelCustomizationId"))
+ .isEqualTo("a7baba5d-6ac3-42b5-b47d-070841303ab1");
+
+ }
+
+ @Test
+ public void buildResponseWithSdcToscaParserWithDefaultInputs() {
+
+ ClassLoader classLoader = getClass().getClassLoader();
+ Path path = new File(
+ classLoader.getResource("toscafile/service-Sotnvpninfraservice-csar.csar").getFile())
+ .toPath().toAbsolutePath();
+ List<LinkedHashMap> resources = new ArrayList<>();
+ LinkedHashMap resource1 = new LinkedHashMap();
+ resource1.put("id", "218df3c3-50dd-4c26-9e36-4771387bb771");
+ resources.add(resource1);
+ LinkedHashMap resource2 = new LinkedHashMap();
+ resource2.put("id", "81b9430b-8abe-45d6-8bf9-f41a8f5c735f");
+ resources.add(resource2);
+ LinkedHashMap response = new LinkedHashMap();
+ response.put("resourceSpecification", resources);
+
+ try {
+ toscaInfosProcessor.buildResponseWithSdcToscaParser(path, response);
+ } catch (SdcToscaParserException e) {
+ throw new TechnicalException("unable to build response from tosca csar using sdc-parser : "
+ + path.toString() + " " + e.getMessage());
}
- @Test
- public void buildResponseWithToscaInfosOk() {
-
- ClassLoader classLoader = getClass().getClassLoader();
- File file = new File(classLoader.getResource("toscafile/service-VfwService2vfBased-template.yml").getFile());
- List<LinkedHashMap> resources = new ArrayList<>();
- LinkedHashMap resource1 = new LinkedHashMap();
- resource1.put("id", "e2b12ac6-cbb6-4517-9c58-b846d1f68caf");
- resources.add(resource1);
- LinkedHashMap toscaFile = parseToscaFile(file.getPath());
- LinkedHashMap response = new LinkedHashMap();
- response.put("resourceSpecification", resources);
- toscaInfosProcessor.buildResponseWithToscaInfos((LinkedHashMap) toscaFile.get("topology_template"), response);
-
- ArrayList toscaInfos = (ArrayList) response.get("serviceSpecCharacteristic");
- assertThat(toscaInfos.size()).isEqualTo(4);
-
- for (Object toscaInfo : toscaInfos) {
- LinkedHashMap info = (LinkedHashMap) toscaInfo;
- if (((String) info.get("name")).equalsIgnoreCase("fortigate_image_url")) {
- assertThat(info.get("name")).isEqualTo("fortigate_image_url");
- assertThat(info.get("description")).isNull();
- assertThat(info.get("valueType")).isEqualTo("string");
- assertThat(info.get("@type")).isEqualTo("ONAPserviceCharacteristic");
- assertThat(info.get("required")).isEqualTo(false);
- assertThat(info.get("status")).isNull();
- assertThat(((ArrayList) info.get("serviceSpecCharacteristicValue")).size()).isEqualTo(0);
-
- }
-
- if (((String) info.get("name")).equalsIgnoreCase("flavor")) {
- assertThat(info.get("name")).isEqualTo("flavor");
- assertThat(info.get("description")).isNull();
- assertThat(info.get("valueType")).isEqualTo("string");
- assertThat(info.get("@type")).isEqualTo("ONAPserviceCharacteristic");
- assertThat(info.get("required")).isNull();
- assertThat(info.get("status")).isNull();
- assertThat(((ArrayList) info.get("serviceSpecCharacteristicValue")).size()).isEqualTo(0);
-
- }
-
- if (((String) info.get("name")).equalsIgnoreCase("external_network_name")) {
- assertThat(info.get("name")).isEqualTo("external_network_name");
- assertThat(info.get("description")).isNull();
- assertThat(info.get("valueType")).isEqualTo("string");
- assertThat(info.get("@type")).isEqualTo("ONAPserviceCharacteristic");
- assertThat(info.get("required")).isNull();
- assertThat(info.get("status")).isEqualTo("inactive");
- ;
- assertThat(((ArrayList) info.get("serviceSpecCharacteristicValue")).size()).isEqualTo(0);
-
- }
-
- if (((String) info.get("name")).equalsIgnoreCase("cpus")) {
- assertThat(info.get("name")).isEqualTo("cpus");
- assertThat(info.get("description")).isEqualTo("Number of CPUs for the server.");
- assertThat(info.get("valueType")).isEqualTo("integer");
- assertThat(info.get("@type")).isEqualTo("ONAPserviceCharacteristic");
- assertThat(info.get("required")).isNull();
- assertThat(info.get("status")).isNull();
- ;
- assertThat(((ArrayList) info.get("serviceSpecCharacteristicValue")).size()).isEqualTo(4);
- ArrayList serviceSpecCharacteristicValues = (ArrayList) info.get("serviceSpecCharacteristicValue");
-
- for (Object serviceSpecCharacteristicValue : serviceSpecCharacteristicValues) {
- LinkedHashMap serviceSpecValue = (LinkedHashMap) serviceSpecCharacteristicValue;
- if (((String) serviceSpecValue.get("value")).equalsIgnoreCase("1")) {
- assertThat(serviceSpecValue.get("isDefault")).isEqualTo(false);
- assertThat(serviceSpecValue.get("value")).isEqualTo("1");
- assertThat(serviceSpecValue.get("valueType")).isEqualTo("integer");
- }
- if (((String) serviceSpecValue.get("value")).equalsIgnoreCase("2")) {
- assertThat(serviceSpecValue.get("isDefault")).isEqualTo(true);
- assertThat(serviceSpecValue.get("value")).isEqualTo("2");
- assertThat(serviceSpecValue.get("valueType")).isEqualTo("integer");
- }
- if (((String) serviceSpecValue.get("value")).equalsIgnoreCase("3")) {
- assertThat(serviceSpecValue.get("isDefault")).isEqualTo(false);
- assertThat(serviceSpecValue.get("value")).isEqualTo("3");
- assertThat(serviceSpecValue.get("valueType")).isEqualTo("integer");
- }
- if (((String) serviceSpecValue.get("value")).equalsIgnoreCase("4")) {
- assertThat(serviceSpecValue.get("isDefault")).isEqualTo(false);
- assertThat(serviceSpecValue.get("value")).isEqualTo("4");
- assertThat(serviceSpecValue.get("valueType")).isEqualTo("integer");
- }
-
- }
-
-
- }
-
- }
-
-
+ 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");
+ assertThat(resources.get(1).get("modelCustomizationId"))
+ .isEqualTo("c3612284-6c67-4d8c-8b41-b699cc90e76d");
+ assertThat(serviceSpecCharacteristic.get(12).get("serviceSpecCharacteristicValue")).isNull();
+ assertThat(serviceSpecCharacteristic.get(13).get("serviceSpecCharacteristicValue")).isNotNull();
+ }
+
+ @Test
+ public void buildResponseWithSdcToscaParserwithMetaDataMisMatch() {
+
+ ClassLoader classLoader = getClass().getClassLoader();
+ Path path = new File(
+ classLoader.getResource("toscafile/service-Sdwanvpninfraservice-csar.csar").getFile())
+ .toPath().toAbsolutePath();
+ List<LinkedHashMap> resources = new ArrayList<>();
+ LinkedHashMap resource1 = new LinkedHashMap();
+ resource1.put("id", "some bad resource id no in TOSCA CSAR");
+ resources.add(resource1);
+ LinkedHashMap resource2 = new LinkedHashMap();
+ resource2.put("id", "some bad resource id no in TOSCA CSAR");
+ resources.add(resource2);
+ LinkedHashMap response = new LinkedHashMap();
+ response.put("resourceSpecification", resources);
+
+ try {
+ toscaInfosProcessor.buildResponseWithSdcToscaParser(path, response);
+ } catch (SdcToscaParserException e) {
+ throw new TechnicalException("unable to build response from tosca csar using sdc-parser : "
+ + path.toString() + " " + e.getMessage());
}
-} \ No newline at end of file
+ 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");
+ 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);
+ // Check that resources cannot be found in the TOSCA template
+ assertThat(resources.get(0).get("modelCustomizationId")).isNull();
+ assertThat(resources.get(1).get("modelCustomizationId")).isNull();
+
+ }
+}
diff --git a/src/test/resources/__files/toscafile/service-Sdwanvpninfraservice-csar.csar b/src/test/resources/__files/toscafile/service-Sdwanvpninfraservice-csar.csar
new file mode 100644
index 0000000..52bdfe2
--- /dev/null
+++ b/src/test/resources/__files/toscafile/service-Sdwanvpninfraservice-csar.csar
Binary files differ
diff --git a/src/test/resources/karatetest/features/00--ServiceCatalog.feature b/src/test/resources/karatetest/features/00--ServiceCatalog.feature
index 31fd148..2a40526 100644
--- a/src/test/resources/karatetest/features/00--ServiceCatalog.feature
+++ b/src/test/resources/karatetest/features/00--ServiceCatalog.feature
@@ -18,6 +18,13 @@ And match $.resourceSpecification[0] contains { name : 'vFW-vSINK', resourceInst
And match $.resourceSpecification == '#[2]'
And match $.attachment == '#[5]'
+Scenario: testServiceCatalogGetServiceWithToscaInput
+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' }
+
Scenario: findServiceCatalog
Given path 'serviceSpecification'
When method get
diff --git a/src/test/resources/mappings/sdc_get_462f84e5-f0e5-44c5-ab95-38fb4bf77064_toscafile.json b/src/test/resources/mappings/sdc_get_462f84e5-f0e5-44c5-ab95-38fb4bf77064_toscafile.json
new file mode 100644
index 0000000..9886df7
--- /dev/null
+++ b/src/test/resources/mappings/sdc_get_462f84e5-f0e5-44c5-ab95-38fb4bf77064_toscafile.json
@@ -0,0 +1,10 @@
+{
+ "request": {
+ "method": "GET",
+ "url": "/sdc/v1/catalog/services/462f84e5-f0e5-44c5-ab95-38fb4bf77064/toscaModel"
+ },
+ "response": {
+ "status": 200,
+ "bodyFileName": "toscafile/service-Sdwanvpninfraservice-csar.csar"
+ }
+}
diff --git a/src/test/resources/mappings/sdc_get_462f84e5-f0e5-44c5-ab95-38fb4bf77064_withTosca.json b/src/test/resources/mappings/sdc_get_462f84e5-f0e5-44c5-ab95-38fb4bf77064_withTosca.json
new file mode 100644
index 0000000..848b725
--- /dev/null
+++ b/src/test/resources/mappings/sdc_get_462f84e5-f0e5-44c5-ab95-38fb4bf77064_withTosca.json
@@ -0,0 +1,213 @@
+{
+ "request": {
+ "method": "GET",
+ "url": "/sdc/v1/catalog/services/462f84e5-f0e5-44c5-ab95-38fb4bf77064/metadata"
+ },
+ "response": {
+ "status": 200,
+ "jsonBody": {
+ "uuid": "462f84e5-f0e5-44c5-ab95-38fb4bf77064",
+ "invariantUUID": "b58a118e-eeb9-4f6e-bdca-e292f84d17df",
+ "name": "vFW",
+ "version": "2.0",
+ "toscaModelURL": "/sdc/v1/catalog/services/462f84e5-f0e5-44c5-ab95-38fb4bf77064/toscaModel",
+ "category": "Network Service",
+ "lifecycleState": "CERTIFIED",
+ "lastUpdaterUserId": "jm0007",
+ "distributionStatus": "DISTRIBUTED",
+ "lastUpdaterFullName": "Joni Mitchell",
+ "resources": [{
+ "resourceInstanceName": "vFW-vSINK 0",
+ "resourceName": "vFW-vSINK",
+ "resourceInvariantUUID": "18b90934-aa82-456f-938e-e74a07a426f3",
+ "resourceVersion": "2.0",
+ "resoucreType": "VF",
+ "resourceUUID": "89a6b4c5-3973-4c19-b651-fae3713ca8d5",
+ "artifacts": [{
+ "artifactName": "vf-license-model.xml",
+ "artifactType": "VF_LICENSE",
+ "artifactURL": "/sdc/v1/catalog/services/1e3feeb0-8e36-46c6-862c-236d9c626439/resourceInstances/vfwvsink0/artifacts/f6fa3f94-f5cd-4233-a7b2-b5e8dc2e1ec6",
+ "artifactDescription": "VF license file",
+ "artifactChecksum": "NDQ2NzIxNzgyMjZhNTc1NDNlMWU0ODI1ZmIyNjc3Zjg=",
+ "artifactUUID": "f6fa3f94-f5cd-4233-a7b2-b5e8dc2e1ec6",
+ "artifactVersion": "1",
+ "artifactLabel": "vflicense",
+ "artifactGroupType": "DEPLOYMENT"
+ },
+ {
+ "artifactName": "vfwvsink0_modules.json",
+ "artifactType": "VF_MODULES_METADATA",
+ "artifactURL": "/sdc/v1/catalog/services/1e3feeb0-8e36-46c6-862c-236d9c626439/resourceInstances/vfwvsink0/artifacts/d0aaecf9-6ffb-4b4b-81fd-c59c1e8e6fb6",
+ "artifactDescription": "Auto-generated VF Modules information artifact",
+ "artifactChecksum": "ZGIyOWY3YzE0MTM2MjlhMjY1ZjkzNDg3YjE2ZmQxY2Y=",
+ "artifactUUID": "d0aaecf9-6ffb-4b4b-81fd-c59c1e8e6fb6",
+ "artifactVersion": "1",
+ "artifactLabel": "vfModulesMetadata",
+ "artifactGroupType": "DEPLOYMENT"
+ },
+ {
+ "artifactName": "base_vfw.yaml",
+ "artifactType": "HEAT",
+ "artifactURL": "/sdc/v1/catalog/services/1e3feeb0-8e36-46c6-862c-236d9c626439/resourceInstances/vfwvsink0/artifacts/c94e8eec-b1a7-431c-ab6f-2fda5f0ee920",
+ "artifactDescription": "created from csar",
+ "artifactTimeout": 60,
+ "artifactChecksum": "YTY0MDg5ODUwZDE4YzQyYWI0NjE5Y2NjYmM3ZDg5ZGE=",
+ "artifactUUID": "c94e8eec-b1a7-431c-ab6f-2fda5f0ee920",
+ "artifactVersion": "4",
+ "artifactLabel": "heat1",
+ "artifactGroupType": "DEPLOYMENT"
+ },
+ {
+ "artifactName": "vendor-license-model.xml",
+ "artifactType": "VENDOR_LICENSE",
+ "artifactURL": "/sdc/v1/catalog/services/1e3feeb0-8e36-46c6-862c-236d9c626439/resourceInstances/vfwvsink0/artifacts/423d2c66-6c3a-4257-9342-7b57ebf9dd54",
+ "artifactDescription": " Vendor license file",
+ "artifactChecksum": "YTNhYTc3ZGE4ZWViMmYzOThkOGQ3ZTVjZGNmNmU0ZmQ=",
+ "artifactUUID": "423d2c66-6c3a-4257-9342-7b57ebf9dd54",
+ "artifactVersion": "1",
+ "artifactLabel": "vendorlicense",
+ "artifactGroupType": "DEPLOYMENT"
+ },
+ {
+ "artifactName": "base_vfw.env",
+ "artifactType": "HEAT_ENV",
+ "artifactURL": "/sdc/v1/catalog/services/1e3feeb0-8e36-46c6-862c-236d9c626439/resourceInstances/vfwvsink0/artifacts/a1a58cc9-8225-4b6f-b81a-02fa3c7fb6ec",
+ "artifactDescription": "Auto-generated HEAT Environment deployment artifact",
+ "artifactChecksum": "ZmVkM2MwODhlZjcwNWY5MDk5ZGEyMjI5ZTAyYWRjNjY=",
+ "artifactUUID": "a1a58cc9-8225-4b6f-b81a-02fa3c7fb6ec",
+ "artifactVersion": "2",
+ "generatedFromUUID": "32591489-33c9-4461-a47c-7c463250788d.heat1",
+ "artifactLabel": "heat1env",
+ "artifactGroupType": "DEPLOYMENT"
+ }
+ ]
+ },
+ {
+ "resourceInstanceName": "vPkG 0",
+ "resourceName": "vPkG",
+ "resourceInvariantUUID": "8d8a20c0-746c-4d5e-a1a2-fa49fa5786ad",
+ "resourceVersion": "2.0",
+ "resoucreType": "VF",
+ "resourceUUID": "31961e27-2a2c-4beb-87c9-bfe0067088f5",
+ "artifacts": [{
+ "artifactName": "vf-license-model.xml",
+ "artifactType": "VF_LICENSE",
+ "artifactURL": "/sdc/v1/catalog/services/1e3feeb0-8e36-46c6-862c-236d9c626439/resourceInstances/vpkg0/artifacts/7af6cc3b-2ba3-4164-9d7d-65b3b46a71f4",
+ "artifactDescription": "VF license file",
+ "artifactChecksum": "MWM5NDlmNjdhZTdmZTA5MzIzY2RhYjcxZmFkYzQyZDM=",
+ "artifactUUID": "7af6cc3b-2ba3-4164-9d7d-65b3b46a71f4",
+ "artifactVersion": "1",
+ "artifactLabel": "vflicense",
+ "artifactGroupType": "DEPLOYMENT"
+ },
+ {
+ "artifactName": "vpkg0_modules.json",
+ "artifactType": "VF_MODULES_METADATA",
+ "artifactURL": "/sdc/v1/catalog/services/1e3feeb0-8e36-46c6-862c-236d9c626439/resourceInstances/vpkg0/artifacts/37b16173-bd54-447f-a5a2-1a5e24db8afb",
+ "artifactDescription": "Auto-generated VF Modules information artifact",
+ "artifactChecksum": "ZDA3MWQ3MTE3MTA1MzNkY2M1ODQ4YTUxN2YwMDk0MmM=",
+ "artifactUUID": "37b16173-bd54-447f-a5a2-1a5e24db8afb",
+ "artifactVersion": "1",
+ "artifactLabel": "vfModulesMetadata",
+ "artifactGroupType": "DEPLOYMENT"
+ },
+ {
+ "artifactName": "base_vpkg.yaml",
+ "artifactType": "HEAT",
+ "artifactURL": "/sdc/v1/catalog/services/1e3feeb0-8e36-46c6-862c-236d9c626439/resourceInstances/vpkg0/artifacts/43184998-c107-40a7-92f6-00ba74de8539",
+ "artifactDescription": "created from csar",
+ "artifactTimeout": 60,
+ "artifactChecksum": "NDZhY2U0YTExZjllNTFmZjc4ZTE4YzU2Zjk1ZDc2MWI=",
+ "artifactUUID": "43184998-c107-40a7-92f6-00ba74de8539",
+ "artifactVersion": "4",
+ "artifactLabel": "heat1",
+ "artifactGroupType": "DEPLOYMENT"
+ },
+ {
+ "artifactName": "vendor-license-model.xml",
+ "artifactType": "VENDOR_LICENSE",
+ "artifactURL": "/sdc/v1/catalog/services/1e3feeb0-8e36-46c6-862c-236d9c626439/resourceInstances/vpkg0/artifacts/6cd5f968-20aa-4b86-9a50-97db5e4ca806",
+ "artifactDescription": " Vendor license file",
+ "artifactChecksum": "YTNhYTc3ZGE4ZWViMmYzOThkOGQ3ZTVjZGNmNmU0ZmQ=",
+ "artifactUUID": "6cd5f968-20aa-4b86-9a50-97db5e4ca806",
+ "artifactVersion": "1",
+ "artifactLabel": "vendorlicense",
+ "artifactGroupType": "DEPLOYMENT"
+ },
+ {
+ "artifactName": "base_vpkg.env",
+ "artifactType": "HEAT_ENV",
+ "artifactURL": "/sdc/v1/catalog/services/1e3feeb0-8e36-46c6-862c-236d9c626439/resourceInstances/vpkg0/artifacts/60944038-d382-4aa6-b387-7b87c9c9df19",
+ "artifactDescription": "Auto-generated HEAT Environment deployment artifact",
+ "artifactChecksum": "OGU0OGFlZTFiZDdhYmQ0MmM0MjAyY2U5YjljYWViYTA=",
+ "artifactUUID": "60944038-d382-4aa6-b387-7b87c9c9df19",
+ "artifactVersion": "2",
+ "generatedFromUUID": "0d3918df-ea14-4fc3-a5c9-34032eaae573.heat1",
+ "artifactLabel": "heat1env",
+ "artifactGroupType": "DEPLOYMENT"
+ }
+ ]
+ }
+ ],
+ "artifacts": [{
+ "artifactName": "AAI-vFW-service-2VF-based-service-2.0.xml",
+ "artifactType": "MODEL_INVENTORY_PROFILE",
+ "artifactURL": "/sdc/v1/catalog/services/1e3feeb0-8e36-46c6-862c-236d9c626439/artifacts/2e6cd967-93c2-4f53-82bd-c56ab98e8df7",
+ "artifactDescription": "AAI Service Model",
+ "artifactChecksum": "ZTY5ZTJmYTY4YzE2NGUxMTQxNWNkN2QzMmI4MWIzNDU=",
+ "artifactUUID": "2e6cd967-93c2-4f53-82bd-c56ab98e8df7",
+ "artifactVersion": "1",
+ "artifactLabel": "aaiservice1603481860",
+ "artifactGroupType": "DEPLOYMENT"
+ },
+ {
+ "artifactName": "AAI-Vpkg..base_vpkg..module-0-resource-2.xml",
+ "artifactType": "MODEL_INVENTORY_PROFILE",
+ "artifactURL": "/sdc/v1/catalog/services/1e3feeb0-8e36-46c6-862c-236d9c626439/artifacts/ad600a09-edde-4356-bb0a-9e638a671d06",
+ "artifactDescription": "AAI Resource Model",
+ "artifactChecksum": "MzQyMjczOGVmYzM1OWQ1NmFhZjBhOWUxM2JjMmYxZTQ=",
+ "artifactUUID": "ad600a09-edde-4356-bb0a-9e638a671d06",
+ "artifactVersion": "1",
+ "artifactLabel": "aairesource529289386",
+ "artifactGroupType": "DEPLOYMENT"
+ },
+ {
+ "artifactName": "AAI-vFW-vSINK-resource-2.0.xml",
+ "artifactType": "MODEL_INVENTORY_PROFILE",
+ "artifactURL": "/sdc/v1/catalog/services/1e3feeb0-8e36-46c6-862c-236d9c626439/artifacts/413a631e-69c4-453b-ab68-fac09b390259",
+ "artifactDescription": "AAI Resource Model",
+ "artifactChecksum": "ZWRmMzQzYzc0MThlYjQ1YjY2ZTFkYzJmMjAyNzQ1YWU=",
+ "artifactUUID": "413a631e-69c4-453b-ab68-fac09b390259",
+ "artifactVersion": "1",
+ "artifactLabel": "aairesource1461475898",
+ "artifactGroupType": "DEPLOYMENT"
+ },
+ {
+ "artifactName": "AAI-vPkG-resource-2.0.xml",
+ "artifactType": "MODEL_INVENTORY_PROFILE",
+ "artifactURL": "/sdc/v1/catalog/services/1e3feeb0-8e36-46c6-862c-236d9c626439/artifacts/aee30754-eec4-4820-ae3a-790b80b76e81",
+ "artifactDescription": "AAI Resource Model",
+ "artifactChecksum": "OGQ4ZTdhYjkyZDRkYmFiZTBhNWU4MDc4YTM2YjY1NmI=",
+ "artifactUUID": "aee30754-eec4-4820-ae3a-790b80b76e81",
+ "artifactVersion": "1",
+ "artifactLabel": "aairesource936479495",
+ "artifactGroupType": "DEPLOYMENT"
+ },
+ {
+ "artifactName": "AAI-VfwVsink..base_vfw..module-0-resource-2.xml",
+ "artifactType": "MODEL_INVENTORY_PROFILE",
+ "artifactURL": "/sdc/v1/catalog/services/1e3feeb0-8e36-46c6-862c-236d9c626439/artifacts/ac9a3bbf-a052-4176-abff-fe2d2741194a",
+ "artifactDescription": "AAI Resource Model",
+ "artifactChecksum": "OWIzNjVhNmI2ZWYyZThlMjk1NjA2MDFhZTU3MGQ0ZDU=",
+ "artifactUUID": "ac9a3bbf-a052-4176-abff-fe2d2741194a",
+ "artifactVersion": "1",
+ "artifactLabel": "aairesource1106409880",
+ "artifactGroupType": "DEPLOYMENT"
+ }
+ ]
+ },
+ "headers": {
+ "Content-Type": "application/json"
+ }
+ }
+}