/*
- * Copyright © 2016-2017 European Support Limited
+ * Copyright © 2018 European Support Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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.openecomp.sdc.translator;
import org.openecomp.core.translator.api.HeatToToscaTranslator;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.sdc.common.utils.SdcCommon;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.onap.sdc.tosca.datatypes.model.GroupDefinition;
import org.onap.sdc.tosca.datatypes.model.NodeTemplate;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.NotDirectoryException;
import java.util.ArrayList;
private static String zipFilename = "VSP.zip";
private static String validationFilename = "validationOutput.json";
- private static Logger logger = (Logger) LoggerFactory.getLogger(TestUtils.class);
-
private TestUtils() {
}
* @param baseDirPath base directory for the tosca file
* @return Map of <ServiceTemplateFilename, ServiceTemplate> for the files in this directory
*/
- private static Map<String, ServiceTemplate> getServiceTemplates(String baseDirPath) {
+ private static Map<String, ServiceTemplate> getServiceTemplates(String baseDirPath) throws URISyntaxException{
Map<String, ServiceTemplate> serviceTemplateMap = new HashMap<>();
ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
baseDirPath = "." + baseDirPath + "/";
- try {
+
String[] fileList = {};
URL filesDirUrl = TestUtils.class.getClassLoader().getResource(baseDirPath);
if (filesDirUrl != null && filesDirUrl.getProtocol().equals("file")) {
URL resource = TestUtils.class.getClassLoader().getResource(baseDirPath + fileName);
ServiceTemplate serviceTemplate = FileUtils.readViaInputStream(resource,
- stream -> toscaExtensionYamlUtil.yamlToObject(stream, ServiceTemplate.class));
+ stream -> toscaExtensionYamlUtil.yamlToObject(stream, ServiceTemplate.class));
serviceTemplateMap.put(fileName, serviceTemplate);
}
- } catch (Exception e) {
- logger.debug("", e);
- Assert.fail(e.getMessage());
- }
return serviceTemplateMap;
}
-
/**
* Get tosca service template models
*
public static ToscaServiceModel loadToscaServiceModel(String serviceTemplatesPath,
String globalServiceTemplatesPath,
String entryDefinitionServiceTemplate)
- throws IOException {
- ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
- Map<String, ServiceTemplate> serviceTemplates = new HashMap<>();
+ throws IOException, URISyntaxException {
+ Map<String, ServiceTemplate> serviceTemplates;
if (entryDefinitionServiceTemplate == null) {
entryDefinitionServiceTemplate = "MainServiceTemplate.yaml";
}
toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
createConcreteRequirementObjectsInServiceTemplate(serviceTemplateFromYaml,
toscaExtensionYamlUtil);
- try {
- yamlFile.close();
- } catch (IOException ignore) {
- logger.debug("", ignore);
- }
- } catch (FileNotFoundException e) {
- throw e;
- } catch (IOException e) {
- throw e;
}
}
} else {
createConcreteRequirementObjectsInServiceTemplate(serviceTemplateFromYaml,
toscaExtensionYamlUtil);
serviceTemplates.put(file.getName(), serviceTemplateFromYaml);
- try {
- yamlFile.close();
- } catch (IOException ignore) {
- logger.debug("", ignore);
- }
- } catch (FileNotFoundException e) {
- throw e;
- } catch (IOException e) {
- throw e;
}
}
}
nodeTemplateId) {
List<String> entityGroups = new ArrayList<>();
Map<String, GroupDefinition> groups = serviceTemplate.getTopology_template().getGroups();
- Map<String, NodeTemplate> nodeTemplates =
- serviceTemplate.getTopology_template().getNode_templates();
for (Map.Entry<String, GroupDefinition> entry : groups.entrySet()) {
String groupId = entry.getKey();
GroupDefinition groupDefinition = entry.getValue();
import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.GetAttrFuncData;
import java.io.IOException;
+import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
}
@Test
- public void testConsolidationValidPreCondition() throws IOException {
+ public void testConsolidationValidPreCondition() throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
}
@Test
- public void testConsolidationFalsePreConditionOneComputeNode() throws IOException {
+ public void testConsolidationFalsePreConditionOneComputeNode() throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
}
@Test
- public void testConsolidationFalsePreConditionMoreThanOnePortPerType() throws IOException {
+ public void testConsolidationFalsePreConditionMoreThanOnePortPerType() throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
@Test
public void testConsolidationFalsePreConditionDifferentPortTypesBetweenComputes()
- throws IOException {
+ throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
}
@Test
- public void testConsolidationResultTrueWithMoreThanTwoCompute() throws IOException {
+ public void testConsolidationResultTrueWithMoreThanTwoCompute() throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
}
@Test
- public void testConsolidationResultFalseWithMoreThanTwoComputeOneIsDiff() throws IOException {
+ public void testConsolidationResultFalseWithMoreThanTwoComputeOneIsDiff() throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
@Test
public void testConsolidationResultFalseForTwoTypesOfComputeWithOneInstanceEach()
- throws IOException {
+ throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName1 = "org.openecomp.resource.vfc.nodes.heat.ps_server";
String computeNodeTypeName2 = "org.openecomp.resource.vfc.nodes.heat.cmaui";
@Test
public void testConsolidationValidForTwoSimilarComputeAndFalseForSingleCompute()
- throws IOException {
+ throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName1 = "org.openecomp.resource.vfc.nodes.heat.ps_server";
String computeNodeTypeName2 = "org.openecomp.resource.vfc.nodes.heat.cmaui";
}
@Test
- public void testValidComputeAndPortConsolidation() throws IOException {
+ public void testValidComputeAndPortConsolidation() throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
}
@Test
- public void testFalseComputeConsolidationForTwoSimilarImageNamesAndOneDiff() throws IOException {
+ public void testFalseComputeConsolidationForTwoSimilarImageNamesAndOneDiff() throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName1 = "org.openecomp.resource.vfc.nodes.heat.ps_server";
String computeNodeTypeName2 = "org.openecomp.resource.vfc.nodes.heat.pd_server";
}
@Test
- public void testFalseComputeConsolidationOneImageNameMissing() throws IOException {
+ public void testFalseComputeConsolidationOneImageNameMissing() throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.pd_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
}
@Test
- public void testFalseComputeConsolidationForTwoSimilarFlavorNamesAndOneDiff() throws IOException {
+ public void testFalseComputeConsolidationForTwoSimilarFlavorNamesAndOneDiff() throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
}
@Test
- public void testFalsePortConsolidationForOneDiffFixedIpsValue() throws IOException {
+ public void testFalsePortConsolidationForOneDiffFixedIpsValue() throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
}
@Test
- public void testFalsePortConsolidationForTwoPortsWithFixedIpsAndOneWithout() throws IOException {
+ public void testFalsePortConsolidationForTwoPortsWithFixedIpsAndOneWithout() throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
@Test
public void testFalsePortConsolidationForTwoPortsWithAddressPairsAndOneWithout()
- throws IOException {
+ throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
@Test
public void testFalsePortConsolidationForTwoPortsWithMacAddressAndOneWithout()
- throws IOException {
+ throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
@Test
public void testValidPortConsolidationForPortsWithNoneOfTheCheckedProperties()
- throws IOException {
+ throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
}
@Test
- public void testComputeRelationsSimilarBetweenComputeNodes() throws IOException {
+ public void testComputeRelationsSimilarBetweenComputeNodes() throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
}
@Test
- public void testNodesInRelationsDiffBetweenThreeComputes() throws IOException {
+ public void testNodesInRelationsDiffBetweenThreeComputes() throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
}
@Test
- public void testNodesOutRelationsDiffBetweenThreeComputes() throws IOException {
+ public void testNodesOutRelationsDiffBetweenThreeComputes() throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
}
@Test
- public void testVolumeRelationsDiffBetweenThreeComputes() throws IOException {
+ public void testVolumeRelationsDiffBetweenThreeComputes() throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
}
@Test
- public void testGroupRelationsDiffBetweenThreeComputes() throws IOException {
+ public void testGroupRelationsDiffBetweenThreeComputes() throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
}
@Test
- public void testPortConsolidationDataRelationsSimilar() throws IOException {
+ public void testPortConsolidationDataRelationsSimilar() throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
}
@Test
- public void testNodesInRelationsDiffBetweenThreePortConsolidationDatas() throws IOException {
+ public void testNodesInRelationsDiffBetweenThreePortConsolidationDatas() throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
}
@Test
- public void testNodesOutRelationsDiffBetweenThreePortConsolidationDatas() throws IOException {
+ public void testNodesOutRelationsDiffBetweenThreePortConsolidationDatas() throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
}
@Test
- public void testGroupIdsRelationsDiffBetweenThreePortConsolidationDatas() throws IOException {
+ public void testGroupIdsRelationsDiffBetweenThreePortConsolidationDatas() throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
}
@Test
- public void testValidConsolidationForComputesWithValidGetAttr() throws IOException {
+ public void testValidConsolidationForComputesWithValidGetAttr() throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
}
@Test
- public void testInvalidConsolidationForComputesWithGetAttrForEachOther() throws IOException {
+ public void testInvalidConsolidationForComputesWithGetAttrForEachOther() throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
}
@Test
- public void testValidConsolidationForPortsWithValidGetAttr() throws IOException {
+ public void testValidConsolidationForPortsWithValidGetAttr() throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
}
@Test
- public void testInvalidConsolidationForPortsWithGetAttrInForEachOther() throws IOException {
+ public void testInvalidConsolidationForPortsWithGetAttrInForEachOther() throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
@Test
public void testValidConsolidationForComputesWithSamePortTypesPointingByGetAttrIn() throws
- IOException {
+ IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
}
@Test
- public void testValidGetAttrOutFromComputes() throws IOException {
+ public void testValidGetAttrOutFromComputes() throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
}
@Test
- public void testInValidGetAttrOutFromComputesPortTypeDifferent() throws IOException {
+ public void testInValidGetAttrOutFromComputesPortTypeDifferent() throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
}
@Test
- public void testValidGetAttrOutFromPorts() throws IOException {
+ public void testValidGetAttrOutFromPorts() throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
}
@Test
- public void testInvalidGetAttrOutFromPorts() throws IOException {
+ public void testInvalidGetAttrOutFromPorts() throws IOException, URISyntaxException {
ConsolidationData consolidationData = new ConsolidationData();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
}
@Test
- public void testSubstitutionConsolidationPreConditionTrue() throws IOException {
+ public void testSubstitutionConsolidationPreConditionTrue() throws IOException, URISyntaxException {
translationContext = new TranslationContext();
String mainSTName = "MainServiceTemplate.yaml";
String nestedServiceTemplateName = "nested-pcm_v0.1ServiceTemplate.yaml";
@Test
public void testSubstitutionConsolidationPreConditionFalseMoreThanOneComputeType()
- throws IOException {
+ throws IOException, URISyntaxException {
translationContext = new TranslationContext();
String mainSTName = "MainServiceTemplate.yaml";
String nestedServiceTemplateName = "nested-pcm_v0.1ServiceTemplate.yaml";
@Test
public void testSubstitutionConsolidationPreConditionFalseMoreThanOneComputeOfSameType()
- throws IOException {
+ throws IOException, URISyntaxException {
translationContext = new TranslationContext();
String mainSTName = "MainServiceTemplate.yaml";
String nestedServiceTemplateName = "nested-pcm_v0.1ServiceTemplate.yaml";
}
@Test
- public void testConsolidationPreConditionFalseDiffSubportTypes() throws IOException {
+ public void testConsolidationPreConditionFalseDiffSubportTypes() throws IOException, URISyntaxException {
translationContext = new TranslationContext();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
}
@Test
- public void testConsolidationPreConditionFalseDiffSubportNumber() throws IOException {
+ public void testConsolidationPreConditionFalseDiffSubportNumber() throws IOException, URISyntaxException {
translationContext = new TranslationContext();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
}
@Test
- public void testConsolidationRuleFalseDifferentCountInResourceGroup() throws IOException {
+ public void testConsolidationRuleFalseDifferentCountInResourceGroup() throws IOException, URISyntaxException {
translationContext = new TranslationContext();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
@Test
public void testConsolidationRuleFalseDifferentNodesConnectedInToResourceGroup()
- throws IOException {
+ throws IOException, URISyntaxException {
translationContext = new TranslationContext();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
@Test
public void testConsolidationRuleFalseDifferentNodesConnectedOutFromResourceGroup()
- throws IOException {
+ throws IOException, URISyntaxException {
translationContext = new TranslationContext();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
@Test
public void testConsolidationRuleFalseGetAttrInBetweenSubInterfacesOfSameType()
- throws IOException {
+ throws IOException, URISyntaxException {
translationContext = new TranslationContext();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
@Test
public void testConsolidationRuleFalseGetAttrOutBetweenSubInterfacesOfSameType()
- throws IOException {
+ throws IOException, URISyntaxException {
translationContext = new TranslationContext();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
}
@Test
- public void testConsolidationRuleFalseDifferentRoleInResourceGroup() throws IOException {
+ public void testConsolidationRuleFalseDifferentRoleInResourceGroup() throws IOException, URISyntaxException {
translationContext = new TranslationContext();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel
}
@Test
- public void testConsolidationRuleTrueForSubInterfaces() throws IOException {
+ public void testConsolidationRuleTrueForSubInterfaces() throws IOException, URISyntaxException {
translationContext = new TranslationContext();
String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server";
ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel