summaryrefslogtreecommitdiffstats
path: root/openecomp-be
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be')
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/core/converter/pnfd/model/ConversionQueryTest.java41
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java4
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/api/ToscaConverterManager.java29
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/exception/QueryOperationNotSupportedException.java28
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/ConversionDefinition.java35
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/ConversionQuery.java47
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/ConversionStrategyType.java57
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/PnfTransformationToken.java48
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/Transformation.java73
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/TransformationBlock.java57
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/TransformationDescription.java32
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/parser/AbstractPnfdBlockParser.java178
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/parser/PnfdBlockParser.java35
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/strategy/AbstractPnfdConversionStrategy.java39
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/strategy/PnfdConversionStrategy.java30
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/pom.xml96
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdQueryExecutor.java113
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdTransformationDescriptorReader.java89
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdTransformationEngine.java183
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/factory/PnfdBlockParserFactory.java57
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionDefinitionYamlParser.java55
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionQueryYamlParser.java42
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/NodeTemplateYamlParser.java55
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/ParameterDefinitionYamlParser.java57
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdConversionStrategyYamlParser.java74
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdInputBlockParser.java94
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdNodeTemplateBlockParser.java114
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/TransformationYamlParser.java80
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/strategy/CopyConversionStrategy.java37
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/strategy/ReplaceConversionStrategy.java39
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/strategy/ReplaceInListConversionStrategy.java60
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolConverterPnf.java271
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolModelDrivenConverterPnf.java39
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/resources/pnfdTransformationTemplate/model-driven-conversion.yaml76
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/PnfTransformationEngineParameterizedTest.java152
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/PnfTransformationEngineTest.java (renamed from openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaSolConverterPnfTest.java)87
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/PnfdQueryExecutorTest.java229
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionDefinitionYamlParserTest.java69
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/NodeTemplateYamlParserTest.java46
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdConversionStrategyYamlParserParametrizedTest.java68
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdConversionStrategyYamlParserTest.java53
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaConverterImplTest.java (renamed from openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java)36
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaConvertorDefinitionsTest.java (renamed from openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConvertorDefinitionsTest.java)37
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaSolConverterPnfMultipleNodeTemplatesTest.java74
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/util/TestResourcesUtil.java27
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/util/YamlTestUtil.java67
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/model-driven-conversion.yaml69
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/pnfDescriptor/in/pnfDescriptor_withLayerProtocolsAndDuplicatedGetInput.yaml2
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/conversionDefinition/conversionDefinitionWithReplaceStrategy.yaml7
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/nodeTemplate/nodeTemplate.yaml7
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/convertTwoAttributesSameLevel.yaml11
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/copyListAttribute.yaml8
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/copyObjectAttribute.yaml6
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/copyScalarAttribute.yaml5
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/defaultOutput.yaml2
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/invalidAndValidAttributeQuery.yaml4
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/replaceInListAttribute.yaml9
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/replaceInListAttributeWithNonExistentAndNonExistentFromValues.yaml8
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/replaceScalarAttributeToList.yaml8
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/replaceScalarAttributeToObject.yaml6
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/replaceScalarAttributeToScalar.yaml5
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/pnfAndExtCpWithInput.yaml (renamed from openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/pnfDescriptor/other/pnfDescriptor_PnfAnd2ExtCps.yaml)9
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/attributeQueryWithMoreThanOneAttribute.yaml13
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/convertTwoAttributesSameLevel.yaml32
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/copyListAttribute.yaml17
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/copyObjectAttribute.yaml10
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/copyScalarAttribute.yaml10
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/emptyDescriptor.yaml0
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/invalidAndValidAttributeQuery.yaml16
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/invalidAttributeQuery.yaml11
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/invalidBlock.yaml4
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/invalidBlockQueries.yaml10
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/invalidBlockQuery.yaml6
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/listAsAnAttributeQuery.yaml16
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/noConversions.yaml7
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/pnfAndExtCpWithInput-validBlockButNoQuery.yaml1
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/queryNonExistentLvl.yaml12
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/replaceInListAttribute.yaml19
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/replaceInListAttributeWithNonExistentAndNonExistentFromValues.yaml25
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/replaceInListAttributeWithNonExistentFromValues.yaml19
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/replaceScalarAttributeToList.yaml15
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/replaceScalarAttributeToObject.yaml13
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/replaceScalarAttributeToScalar.yaml12
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/stringAsAnAttributeQuery.yaml10
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/expectedOutput/defaultOutput.yaml2
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/expectedOutput/fullTransformation.yaml36
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/expectedOutput/inputQueryWithMoreThanOneAttribute.yaml21
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/expectedOutput/moreThanOneTransformationWithSameBlockQuery.yaml11
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/expectedOutput/nodeTemplateQueryWithMoreThanOneAttribute.yaml8
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/expectedOutput/wrongGetInputTransformationName.yaml14
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/expectedOutput/wrongTransformationBlock.yaml11
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/pnfWithGetInput.yaml61
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/transformationDescriptor/fullTransformation.yaml84
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/transformationDescriptor/inputQueryWithMoreThanOneAttribute.yaml39
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/transformationDescriptor/moreThanOneTransformationWithSameBlockQuery.yaml37
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/transformationDescriptor/nodeTemplateQueryWithMoreThanOneAttribute.yaml14
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/transformationDescriptor/wrongGetInputTransformationName.yaml39
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/transformationDescriptor/wrongTransformationBlock.yaml24
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/strategy/replaceStrategy.yaml3
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/strategy/strategyMissingStrategyAttribute.yaml2
100 files changed, 3636 insertions, 523 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/core/converter/pnfd/model/ConversionQueryTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/core/converter/pnfd/model/ConversionQueryTest.java
new file mode 100644
index 0000000000..34bd05b211
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/core/converter/pnfd/model/ConversionQueryTest.java
@@ -0,0 +1,41 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.pnfd.model;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.*;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.Test;
+
+public class ConversionQueryTest {
+
+ @Test
+ public void isValidAttributeQueryTest() {
+ ConversionQuery conversionQuery = new ConversionQuery(new HashMap<>());
+ assertThat("Map query should be valid", conversionQuery.isValidAttributeQuery(), is(true));
+ conversionQuery = new ConversionQuery(null);
+ assertThat("Non Map query should be invalid", conversionQuery.isValidAttributeQuery(), is(false));
+ conversionQuery = new ConversionQuery("query");
+ assertThat("Non Map query should be invalid", conversionQuery.isValidAttributeQuery(), is(false));
+ }
+} \ No newline at end of file
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java
index 875d6f2953..31898d26ae 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java
@@ -27,8 +27,8 @@ import java.util.Optional;
import org.apache.commons.collections4.MapUtils;
import org.openecomp.core.impl.AbstractToscaSolConverter;
import org.openecomp.core.impl.ToscaConverterImpl;
-import org.openecomp.core.impl.ToscaSolConverterPnf;
import org.openecomp.core.impl.ToscaSolConverterVnf;
+import org.openecomp.core.impl.ToscaSolModelDrivenConverterPnf;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.core.validation.util.MessageContainerUtil;
@@ -153,7 +153,7 @@ public class OrchestrationTemplateProcessCsarHandler implements OrchestrationTem
private AbstractToscaSolConverter instantiateToscaConverterFor(ResourceTypeEnum resourceType) {
if (resourceType == ResourceTypeEnum.PNF) {
- return new ToscaSolConverterPnf();
+ return new ToscaSolModelDrivenConverterPnf();
}
// default is VF
return new ToscaSolConverterVnf();
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/api/ToscaConverterManager.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/api/ToscaConverterManager.java
deleted file mode 100644
index f10c724375..0000000000
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/api/ToscaConverterManager.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.core.converter.api;
-
-import org.openecomp.core.utilities.file.FileContentHandler;
-import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
-
-public interface ToscaConverterManager {
-
- ToscaServiceModel convert(String csarName, FileContentHandler fileContentHandler);
-}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/exception/QueryOperationNotSupportedException.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/exception/QueryOperationNotSupportedException.java
new file mode 100644
index 0000000000..a3f4b83812
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/exception/QueryOperationNotSupportedException.java
@@ -0,0 +1,28 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.pnfd.exception;
+
+public class QueryOperationNotSupportedException extends RuntimeException {
+
+ public QueryOperationNotSupportedException(final String s) {
+ super(s);
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/ConversionDefinition.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/ConversionDefinition.java
new file mode 100644
index 0000000000..040639358f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/ConversionDefinition.java
@@ -0,0 +1,35 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.pnfd.model;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import org.openecomp.core.converter.pnfd.strategy.PnfdConversionStrategy;
+
+@Getter
+@AllArgsConstructor
+public class ConversionDefinition {
+
+ private ConversionQuery conversionQuery;
+ private String toAttributeName;
+ private PnfdConversionStrategy pnfdConversionStrategy;
+ private String toGetInput;
+
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/ConversionQuery.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/ConversionQuery.java
new file mode 100644
index 0000000000..fc1ef75f05
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/ConversionQuery.java
@@ -0,0 +1,47 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.pnfd.model;
+
+import java.util.Map;
+import lombok.AllArgsConstructor;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+
+/**
+ * Stores a YAML query. The query is a YAML Object that should have the same structure or part of the original YAML that
+ * is desired to find in a TOSCA Yaml block.
+ */
+@Getter
+@EqualsAndHashCode
+@AllArgsConstructor
+public class ConversionQuery {
+
+ private final Object query;
+
+ /**
+ * Checks if the query is a valid attribute query.
+ *
+ * @return {@code true} when its valid, {@code false} otherwise.
+ */
+ public boolean isValidAttributeQuery() {
+ //only a map structure is supported
+ return query instanceof Map;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/ConversionStrategyType.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/ConversionStrategyType.java
new file mode 100644
index 0000000000..b5c1f7c411
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/ConversionStrategyType.java
@@ -0,0 +1,57 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.pnfd.model;
+
+import java.util.Optional;
+
+/**
+ * Represents a type of a conversion strategy
+ */
+public enum ConversionStrategyType {
+ COPY("copy"),
+ REPLACE("replace"),
+ REPLACE_IN_LIST("replaceInList");
+
+ private final String type;
+
+ ConversionStrategyType(final String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Parse a String to the related {@link ConversionStrategyType}.
+ * @param type the {@link ConversionStrategyType} type
+ * @return
+ * The {@link ConversionStrategyType} representing the given type.
+ */
+ public static Optional<ConversionStrategyType> parse(final String type) {
+ for (final ConversionStrategyType conversionStrategyType : values()) {
+ if (conversionStrategyType.getType().equals(type)) {
+ return Optional.of(conversionStrategyType);
+ }
+ }
+
+ return Optional.empty();
+ }
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/PnfTransformationToken.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/PnfTransformationToken.java
new file mode 100644
index 0000000000..fab5b44720
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/PnfTransformationToken.java
@@ -0,0 +1,48 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.pnfd.model;
+
+/**
+ * Represents a token from the transformation descriptor
+ */
+public enum PnfTransformationToken {
+ CONVERSIONS("conversions"),
+ FROM("from"),
+ LIST("list"),
+ QUERY("query"),
+ TO("to"),
+ STRATEGY("strategy"),
+ TO_NAME("to-name"),
+ TO_VALUE("to-value"),
+ TRANSFORMATION_FOR("transformation-for"),
+ NAME("name"),
+ DESCRIPTION("description"),
+ GET_INPUT("get_input"), TO_GET_INPUT("to-get-input");
+
+ private final String name;
+
+ PnfTransformationToken(final String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/Transformation.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/Transformation.java
new file mode 100644
index 0000000000..fa4a9336e3
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/Transformation.java
@@ -0,0 +1,73 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.pnfd.model;
+
+import java.util.List;
+import java.util.Objects;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.commons.collections.CollectionUtils;
+
+/**
+ * Represents a transformation from the PNFD transformation descriptor.
+ */
+@Getter
+@Setter
+public class Transformation {
+
+ private String name;
+ private String description;
+ private TransformationBlock block;
+ private ConversionQuery conversionQuery;
+ private List<ConversionDefinition> conversionDefinitionList;
+
+ /**
+ * Checks if the instance contains all necessary information to be used.
+ *
+ * @return {code true} if the instance is valid, {code false} otherwise
+ */
+ public boolean isValid() {
+ return block != null && conversionQuery != null && !CollectionUtils.isEmpty(conversionDefinitionList);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ Transformation that = (Transformation) o;
+ //if there is no query, compares by block and name.
+ if (conversionQuery != null && conversionQuery.getQuery() == null && that.conversionQuery.getQuery() == null) {
+ return block == that.block &&
+ Objects.equals(name, that.name);
+ }
+ //transformations with the same block and query will override themselves.
+ return block == that.block &&
+ Objects.equals(conversionQuery, that.conversionQuery);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(block, conversionQuery);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/TransformationBlock.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/TransformationBlock.java
new file mode 100644
index 0000000000..4c897c45fb
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/TransformationBlock.java
@@ -0,0 +1,57 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.pnfd.model;
+
+import java.util.Optional;
+
+/**
+ * Represents a type of a transformation block
+ */
+public enum TransformationBlock {
+ INPUT("input"),
+ NODE_TEMPLATE("nodeTemplate"),
+ GET_INPUT_FUNCTION("getInputFunction");
+
+ private final String name;
+
+ TransformationBlock(final String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Parse a String to the related {@link TransformationBlock}.
+ * @param name the {@link TransformationBlock} name
+ * @return
+ * The {@link TransformationBlock} representing the given name.
+ */
+ public static Optional<TransformationBlock> parse(final String name) {
+ for (final TransformationBlock transformationBlock : values()) {
+ if (transformationBlock.getName().equals(name)) {
+ return Optional.of(transformationBlock);
+ }
+ }
+
+ return Optional.empty();
+ }
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/TransformationDescription.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/TransformationDescription.java
new file mode 100644
index 0000000000..f21a719f8d
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/TransformationDescription.java
@@ -0,0 +1,32 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.pnfd.model;
+
+import java.util.Set;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@Getter
+@AllArgsConstructor
+public class TransformationDescription {
+
+ private final Set<Transformation> transformationSet;
+
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/parser/AbstractPnfdBlockParser.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/parser/AbstractPnfdBlockParser.java
new file mode 100644
index 0000000000..fe8bd428c3
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/parser/AbstractPnfdBlockParser.java
@@ -0,0 +1,178 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.pnfd.parser;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import org.apache.commons.collections.MapUtils;
+import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.core.converter.ServiceTemplateReaderService;
+import org.openecomp.core.converter.pnfd.model.ConversionDefinition;
+import org.openecomp.core.converter.pnfd.model.PnfTransformationToken;
+import org.openecomp.core.converter.pnfd.model.Transformation;
+
+public abstract class AbstractPnfdBlockParser implements PnfdBlockParser {
+
+ protected final Transformation transformation;
+ protected ServiceTemplateReaderService templateFrom;
+ protected ServiceTemplate templateTo;
+
+ public AbstractPnfdBlockParser(final Transformation transformation) {
+ this.transformation = transformation;
+ }
+
+ /**
+ * Parses a PNFD block based on the {@link Transformation} provided during the {@link PnfdBlockParser}
+ * instantiation.
+ *
+ * @param templateFrom the original PNFD template
+ * @param templateTo the resulting PNFD template
+ */
+ public void parse(final ServiceTemplateReaderService templateFrom, final ServiceTemplate templateTo) {
+ this.templateFrom = templateFrom;
+ this.templateTo = templateTo;
+ final Set<Map<String, Object>> blockToParseSet = findBlocksToParse();
+ if (!blockToParseSet.isEmpty()) {
+ blockToParseSet.forEach(this::parse);
+ }
+ }
+
+ /**
+ * Applies all specified conversions in {@link Transformation#getConversionDefinitionList()} for the given
+ * blockYamlObject.
+ *
+ * @param blockYamlObject the block content as a YAML object
+ */
+ protected void parse(final Map<String, Object> blockYamlObject) {
+ if (MapUtils.isEmpty(blockYamlObject)) {
+ return;
+ }
+ final List<ConversionDefinition> conversionDefinitionList = transformation.getConversionDefinitionList();
+ final Map<String, Object> parsedBlockYamlObject = new HashMap<>();
+ final String blockName = blockYamlObject.keySet().iterator().next();
+ conversionDefinitionList.stream()
+ .filter(conversionDefinition -> conversionDefinition.getConversionQuery().isValidAttributeQuery())
+ .forEach(conversionDefinition -> {
+ final Map<String, Object> query =
+ (Map<String, Object>) conversionDefinition.getConversionQuery().getQuery();
+ final Map<String, Object> blockAttributeMap = (Map<String, Object>) blockYamlObject.get(blockName);
+ final Optional<Map<String, Object>> parsedBlockAttributeMap = buildParsedBlock(query, blockAttributeMap
+ , conversionDefinition);
+ parsedBlockAttributeMap.ifPresent(convertedNodeTemplateAttributeMap1 ->
+ mergeYamlObjects(parsedBlockYamlObject, convertedNodeTemplateAttributeMap1)
+ );
+ });
+
+ write(blockName, parsedBlockYamlObject);
+ }
+
+ /**
+ * Writes the block in the resulting {@link ServiceTemplate} {@link #templateTo}.
+ *
+ * @param blockName the name of the block
+ * @param parsedBlockYamlObject the block content as a YAML object
+ */
+ protected abstract void write(final String blockName, final Map<String, Object> parsedBlockYamlObject);
+
+ /**
+ * Uses the provided attribute query to find a attribute in the original YAML object and apply the provided
+ * conversion.
+ *
+ * @param attributeQuery the attribute query
+ * @param fromNodeTemplateAttributeMap the original YAML object
+ * @param conversionDefinition the conversion
+ * @return the rebuilt original YAML object with the converted attribute
+ */
+ protected abstract Optional<Map<String, Object>> buildParsedBlock(final Map<String, Object> attributeQuery,
+ final Map<String, Object> fromNodeTemplateAttributeMap,
+ final ConversionDefinition conversionDefinition);
+
+ /**
+ * Merges two YAML objects.
+ *
+ * @param originalMap original YAML object
+ * @param toBeMergedMap YAML object to be merged
+ * @return the new YAML object representing the merge result.
+ */
+ protected Map<String, Object> mergeYamlObjects(final Map<String, Object> originalMap,
+ final Map<String, Object> toBeMergedMap) {
+ toBeMergedMap.forEach(
+ (key, value) -> originalMap.merge(key, value,
+ (toBeMergedValue, originalValue) -> {
+ if (originalValue instanceof Map) {
+ return mergeYamlObjects((Map) originalValue, (Map) toBeMergedValue);
+ }
+ return originalValue;
+ })
+ );
+
+ return originalMap;
+ }
+
+ /**
+ * Executes the provided {@link #transformation getConversionQuery} YAML query to find the blocks to be parsed in
+ * {@link #templateFrom}.
+ *
+ * @return The YAML blocks found
+ */
+ protected abstract Set<Map<String, Object>> findBlocksToParse();
+
+ /**
+ * Checks if the YAML object is a TOSCA get_input call
+ *
+ * @param yamlObject the YAML object
+ * @return {@code true} if the YAML object is a TOSCA get_input call, {@code false} otherwise
+ */
+ protected boolean isGetInputFunction(final Object yamlObject) {
+ if (yamlObject instanceof Map) {
+ final Map<String, Object> yamlMap = (Map<String, Object>) yamlObject;
+ return yamlMap.containsKey(PnfTransformationToken.GET_INPUT.getName());
+ }
+
+ return false;
+ }
+
+ /**
+ * Gets the value (input name) of a YAML object representing a TOSCA get_input call: "get_input: <i>value</i>".
+ *
+ * @param yamlObject the YAML object
+ * @return The get_input function value, that represents the input name
+ */
+ protected String extractGetInputFunctionValue(final Object yamlObject) {
+ if (yamlObject instanceof Map) {
+ final Map<String, Object> yamlMap = (Map<String, Object>) yamlObject;
+ return (String) yamlMap.values().stream().findFirst().orElse(null);
+ }
+
+ return null;
+ }
+
+ /**
+ * Gets the stored input names called with TOSCA get_input function and its transformation configured in {@link
+ * ConversionDefinition#getToGetInput()}
+ */
+ public Optional<Map<String, String>> getInputAndTransformationNameMap() {
+ return Optional.empty();
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/parser/PnfdBlockParser.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/parser/PnfdBlockParser.java
new file mode 100644
index 0000000000..dd66f502ea
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/parser/PnfdBlockParser.java
@@ -0,0 +1,35 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.pnfd.parser;
+
+import java.util.Map;
+import java.util.Optional;
+import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.core.converter.ServiceTemplateReaderService;
+
+/**
+ * Represents a parser of a TOSCA block.
+ */
+public interface PnfdBlockParser {
+
+ void parse(final ServiceTemplateReaderService templateFrom, final ServiceTemplate templateTo);
+
+ Optional<Map<String, String>> getInputAndTransformationNameMap();
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/strategy/AbstractPnfdConversionStrategy.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/strategy/AbstractPnfdConversionStrategy.java
new file mode 100644
index 0000000000..ffd2e6fb34
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/strategy/AbstractPnfdConversionStrategy.java
@@ -0,0 +1,39 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.pnfd.strategy;
+
+import java.util.Map;
+import org.openecomp.core.converter.pnfd.model.ConversionStrategyType;
+
+public abstract class AbstractPnfdConversionStrategy<T, U> implements PnfdConversionStrategy<T, U> {
+
+ protected final ConversionStrategyType strategyType;
+ protected final Map<T, U> conversionMap;
+
+ public AbstractPnfdConversionStrategy(final ConversionStrategyType strategyType, final Map<T, U> conversionMap) {
+ this.strategyType = strategyType;
+ this.conversionMap = conversionMap;
+ }
+
+ public ConversionStrategyType getStrategyType() {
+ return strategyType;
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/strategy/PnfdConversionStrategy.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/strategy/PnfdConversionStrategy.java
new file mode 100644
index 0000000000..724f20550f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/strategy/PnfdConversionStrategy.java
@@ -0,0 +1,30 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.pnfd.strategy;
+
+import java.util.Optional;
+import org.openecomp.core.converter.pnfd.model.ConversionStrategyType;
+
+public interface PnfdConversionStrategy<T, U> {
+
+ Optional<U> convert(final T originalValue);
+
+ ConversionStrategyType getStrategyType();
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/pom.xml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/pom.xml
index 213d6e1f44..35d8e2e310 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/pom.xml
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/pom.xml
@@ -1,54 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <dependencies>
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-tosca-converter-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.sdc.core</groupId>
- <artifactId>openecomp-tosca-lib</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.sdc.core</groupId>
- <artifactId>openecomp-facade-core</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-translator-core</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest</artifactId>
- <version>${hamcrest.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-library</artifactId>
- <version>${hamcrest.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-tosca-converter-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-tosca-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-facade-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-translator-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
+ <version>${hamcrest.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-library</artifactId>
+ <version>${hamcrest.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
- <parent>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-tosca-converter-lib</artifactId>
- <version>1.5.1-SNAPSHOT</version>
- </parent>
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-tosca-converter-lib</artifactId>
+ <version>1.5.1-SNAPSHOT</version>
+ </parent>
- <artifactId>openecomp-tosca-converter-core</artifactId>
+ <artifactId>openecomp-tosca-converter-core</artifactId>
</project> \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdQueryExecutor.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdQueryExecutor.java
new file mode 100644
index 0000000000..890dedb2a7
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdQueryExecutor.java
@@ -0,0 +1,113 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.impl.pnfd;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import org.apache.commons.collections.MapUtils;
+import org.openecomp.core.converter.pnfd.exception.QueryOperationNotSupportedException;
+import org.openecomp.core.converter.pnfd.model.ConversionQuery;
+
+/**
+ * Runs YAML queries
+ */
+public class PnfdQueryExecutor {
+
+ private PnfdQueryExecutor() {
+
+ }
+
+ /**
+ * Finds if a YAML object contains the provided YAML query.
+ * @param conversionQuery The query
+ * @param yamlObject The YAML object to be searched
+ * @return
+ * {@code true} if the YAML query structure was found in the YAML object, {@code false} otherwise.
+ */
+ public static boolean find(final ConversionQuery conversionQuery, final Object yamlObject) {
+ return find(conversionQuery.getQuery(), yamlObject);
+ }
+
+ /**
+ * Recursive structure combined with {@link #findMap(Map, Map)} to find if a YAML object contains the provided YAML query.
+ * Compares the objects if it's a scalar value, otherwise go further in the YAML hierarchical structure
+ * calling the {@link #findMap(Map, Map)}.
+ * @param query The current query
+ * @param yamlObject The current YAML object to be searched
+ * @return
+ * {@code true} if the YAML query structure was found in the YAML object, {@code false} otherwise.
+ */
+ private static boolean find(final Object query, final Object yamlObject) {
+ if (query == null) {
+ return true;
+ }
+
+ checkSupportedQueryType(query);
+
+ if (query instanceof String) {
+ return query.equals(yamlObject);
+ }
+ if (query instanceof Map) {
+ return findMap((Map) query, (Map) yamlObject);
+ }
+ return false;
+ }
+
+ /**
+ * Recursive structure combined with {@link #find(Object, Object)} to find if a YAML object contains the provided YAML query. *
+ * @param query The query current object
+ * @param yamlObject The YAML object to be searched
+ * @return
+ * {@code true} if the YAML query structure was found in the YAML object, {@code false} otherwise.
+ */
+ private static boolean findMap(final Map query, final Map yamlObject) {
+ if (MapUtils.isEmpty(query) || MapUtils.isEmpty(yamlObject)) {
+ return false;
+ }
+
+ if (!yamlObject.keySet().containsAll(query.keySet())) {
+ return false;
+ }
+
+ return query.entrySet().parallelStream().allMatch(queryEntryObj -> {
+ final Entry queryEntry = (Entry) queryEntryObj;
+ return find(queryEntry.getValue(), yamlObject.get(queryEntry.getKey()));
+ });
+ }
+
+ /**
+ * Checks the supported types for a query.
+ * @param query the query to check
+ */
+ private static void checkSupportedQueryType(final Object query) {
+ if (query instanceof String || query instanceof Map) {
+ return;
+ }
+ if (query instanceof List || query instanceof Set) {
+ throw new QueryOperationNotSupportedException("Yaml list query is not supported yet");
+ }
+ throw new QueryOperationNotSupportedException(
+ String.format("Yaml query operation for '%s' is not supported yet", query.getClass())
+ );
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdTransformationDescriptorReader.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdTransformationDescriptorReader.java
new file mode 100644
index 0000000000..6ef5caf21b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdTransformationDescriptorReader.java
@@ -0,0 +1,89 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.impl.pnfd;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+import org.apache.commons.collections.CollectionUtils;
+import org.onap.sdc.tosca.services.YamlUtil;
+import org.openecomp.core.converter.impl.pnfd.parser.TransformationYamlParser;
+import org.openecomp.core.converter.pnfd.model.Transformation;
+import org.openecomp.core.converter.pnfd.model.TransformationDescription;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+
+/**
+ * Reads the PNF Transformation Description
+ */
+public class PnfdTransformationDescriptorReader {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(PnfdTransformationDescriptorReader.class);
+
+ /**
+ * Parse the transformation description to {@link TransformationDescription} class.
+ * @return
+ * The {@link TransformationDescription} instance.
+ */
+ public TransformationDescription parse(final InputStream transformationDescriptionInputStream) {
+ final List<Object> transformationList = readDescriptionYaml(transformationDescriptionInputStream);
+ final Set<Transformation> transformationSet = parseTransformationList(transformationList);
+
+ return new TransformationDescription(transformationSet);
+ }
+
+ /**
+ * Reads the description file that has the required YAML format.
+ * @return
+ * The yaml parsed to Object
+ */
+ private List<Object> readDescriptionYaml(final InputStream transformationDescriptionPath) {
+ try (final InputStream fileInputStream = transformationDescriptionPath) {
+ return YamlUtil.yamlToList(fileInputStream).orElse(Collections.emptyList());
+ } catch (final FileNotFoundException e) {
+ LOGGER.error("Could not find the resource on path.", e);
+ } catch (final IOException e) {
+ LOGGER.error("Could not load resource.", e);
+ }
+ return Collections.emptyList();
+ }
+
+ /**
+ * Parse the transformation list represented in a YAML object to {@link Transformation}.
+ * @param transformationYamlList the YAML object read from the transformation description file
+ * @return
+ * The set of transformations represented as {@link Transformation} class
+ */
+ private Set<Transformation> parseTransformationList(final List<Object> transformationYamlList) {
+ if (CollectionUtils.isEmpty(transformationYamlList)) {
+ return Collections.emptySet();
+ }
+
+ return transformationYamlList.stream()
+ .map(conversionMap -> TransformationYamlParser.parse((Map<String, Object>) conversionMap))
+ .collect(Collectors.toSet());
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdTransformationEngine.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdTransformationEngine.java
new file mode 100644
index 0000000000..a2365b4f8a
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdTransformationEngine.java
@@ -0,0 +1,183 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.impl.pnfd;
+
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.MapUtils;
+import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.onap.sdc.tosca.datatypes.model.TopologyTemplate;
+import org.openecomp.core.converter.ServiceTemplateReaderService;
+import org.openecomp.core.converter.impl.pnfd.factory.PnfdBlockParserFactory;
+import org.openecomp.core.converter.impl.pnfd.parser.ConversionQueryYamlParser;
+import org.openecomp.core.converter.pnfd.model.Transformation;
+import org.openecomp.core.converter.pnfd.model.TransformationBlock;
+import org.openecomp.core.converter.pnfd.model.TransformationDescription;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+
+/**
+ * Engine that manages the PNF Descriptor transformation process.
+ */
+public class PnfdTransformationEngine {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(PnfdTransformationEngine.class);
+
+ private final ServiceTemplate templateTo;
+ private final ServiceTemplateReaderService templateFrom;
+ private final PnfdTransformationDescriptorReader pnfdTransformationDescriptorReader =
+ new PnfdTransformationDescriptorReader();
+ private TransformationDescription transformationDescription;
+ private Map<TransformationBlock, List<Transformation>> transformationGroupByBlockMap;
+ private final String descriptorResourcePath;
+
+ public PnfdTransformationEngine(final ServiceTemplateReaderService templateFrom, final ServiceTemplate templateTo) {
+ this(templateFrom, templateTo, "pnfdTransformationTemplate/model-driven-conversion.yaml");
+ }
+
+ //used for tests purposes
+ PnfdTransformationEngine(final ServiceTemplateReaderService templateFrom, final ServiceTemplate templateTo,
+ final String descriptorResourcePath) {
+ this.templateFrom = templateFrom;
+ this.templateTo = templateTo;
+ this.descriptorResourcePath = descriptorResourcePath;
+ }
+
+ /**
+ * Runs the transformation process.
+ */
+ public void transform() {
+ readDefinition();
+ initializeTopologyTemplate();
+ executeTransformations();
+ }
+
+ /**
+ * Initializes the topology template and its node template set.
+ */
+ private void initializeTopologyTemplate() {
+ TopologyTemplate topologyTemplate = templateTo.getTopology_template();
+ if (topologyTemplate == null) {
+ topologyTemplate = new TopologyTemplate();
+ templateTo.setTopology_template(topologyTemplate);
+ }
+ if (topologyTemplate.getNode_templates() == null) {
+ topologyTemplate.setNode_templates(new HashMap<>());
+ }
+ }
+
+ /**
+ * Reads the transformation description yaml file.
+ */
+ private void readDefinition() {
+ transformationDescription = pnfdTransformationDescriptorReader.parse(getDefinitionFileInputStream());
+ }
+
+ /**
+ * Execute all transformations specified in the descriptor.
+ */
+ private void executeTransformations() {
+ final Set<Transformation> transformationSet = transformationDescription.getTransformationSet();
+ if (CollectionUtils.isEmpty(transformationSet)) {
+ return;
+ }
+ transformationGroupByBlockMap = transformationSet.stream()
+ .filter(Transformation::isValid)
+ .collect(Collectors.groupingBy(Transformation::getBlock));
+ final Map<String, String> inputsToConvertMap = executeNodeTemplateTransformations();
+ executeGetInputFunctionTransformations(inputsToConvertMap);
+ }
+
+ /**
+ * Parses all topology_template node_template.
+ * @return
+ * A map containing any input that was called with a get_input TOSCA function and its getInputFunction
+ * transformation name
+ */
+ private Map<String, String> executeNodeTemplateTransformations() {
+ final List<Transformation> transformationList = transformationGroupByBlockMap
+ .get(TransformationBlock.NODE_TEMPLATE);
+ if (CollectionUtils.isEmpty(transformationList)) {
+ return Collections.emptyMap();
+ }
+
+ final Map<String, String> inputsToConvertMap = new HashMap<>();
+ transformationList.forEach(transformation ->
+ PnfdBlockParserFactory.getInstance().get(transformation).ifPresent(pnfParser -> {
+ pnfParser.parse(templateFrom, templateTo);
+ if (pnfParser.getInputAndTransformationNameMap().isPresent()) {
+ inputsToConvertMap.putAll(pnfParser.getInputAndTransformationNameMap().get());
+ }
+ }));
+ return inputsToConvertMap;
+ }
+
+ /**
+ * Parses all topology_template inputs called with a get_input TOSCA function.
+ * @param inputsToConvertMap A map containing the topology_template input name and its conversion definition name
+ */
+ private void executeGetInputFunctionTransformations(final Map<String, String> inputsToConvertMap) {
+ final List<Transformation> transformationListOfGetInputFunction = transformationGroupByBlockMap
+ .get(TransformationBlock.GET_INPUT_FUNCTION);
+
+ if(MapUtils.isEmpty(inputsToConvertMap) || CollectionUtils.isEmpty(transformationListOfGetInputFunction)) {
+ return;
+ }
+
+ final Map<String, List<Transformation>> transformationByName = transformationListOfGetInputFunction.stream()
+ .collect(Collectors.groupingBy(Transformation::getName));
+
+ inputsToConvertMap.forEach((inputName, transformationName) -> {
+ final List<Transformation> transformationList = transformationByName.get(transformationName);
+ if (!CollectionUtils.isEmpty(transformationList)) {
+ final Transformation transformation = transformationList.stream()
+ .findFirst().orElse(null);
+ if (transformation != null) {
+ final Map<String, Object> conversionQueryMap = new HashMap<>();
+ conversionQueryMap.put(inputName, null);
+ transformation.setConversionQuery(ConversionQueryYamlParser.parse(conversionQueryMap));
+ PnfdBlockParserFactory.getInstance().get(transformation)
+ .ifPresent(pnfParser -> pnfParser.parse(templateFrom, templateTo));
+ }
+ }
+ });
+ }
+
+ /**
+ * Gets the transformation definition yaml file path.
+ * @return The transformation definition yaml path.
+ */
+ private InputStream getDefinitionFileInputStream() {
+ final InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream(descriptorResourcePath);
+ if (resourceAsStream == null) {
+ if (LOGGER.isErrorEnabled()) {
+ LOGGER.error(String.format("Could not find resource '%s'", descriptorResourcePath));
+ }
+ return null;
+ }
+ return resourceAsStream;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/factory/PnfdBlockParserFactory.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/factory/PnfdBlockParserFactory.java
new file mode 100644
index 0000000000..512fdb5ca7
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/factory/PnfdBlockParserFactory.java
@@ -0,0 +1,57 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.impl.pnfd.factory;
+
+import java.util.Optional;
+import org.openecomp.core.converter.pnfd.model.Transformation;
+import org.openecomp.core.converter.impl.pnfd.parser.PnfdInputBlockParser;
+import org.openecomp.core.converter.impl.pnfd.parser.PnfdNodeTemplateBlockParser;
+import org.openecomp.core.converter.pnfd.parser.PnfdBlockParser;
+
+/**
+ * Factory for {@link PnfdBlockParser}.
+ */
+public class PnfdBlockParserFactory {
+ private static PnfdBlockParserFactory instance;
+
+ private PnfdBlockParserFactory() {
+ }
+
+ public static PnfdBlockParserFactory getInstance() {
+ if (instance == null) {
+ instance = new PnfdBlockParserFactory();
+ }
+
+ return instance;
+ }
+
+ public Optional<PnfdBlockParser> get(final Transformation transformation) {
+ switch (transformation.getBlock()) {
+ case NODE_TEMPLATE:
+ return Optional.of(new PnfdNodeTemplateBlockParser(transformation));
+ case INPUT:
+ case GET_INPUT_FUNCTION:
+ return Optional.of(new PnfdInputBlockParser(transformation));
+ default:
+ return Optional.empty();
+ }
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionDefinitionYamlParser.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionDefinitionYamlParser.java
new file mode 100644
index 0000000000..143185210e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionDefinitionYamlParser.java
@@ -0,0 +1,55 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.impl.pnfd.parser;
+
+import java.util.Map;
+import org.openecomp.core.converter.pnfd.model.ConversionDefinition;
+import org.openecomp.core.converter.pnfd.model.ConversionQuery;
+import org.openecomp.core.converter.pnfd.model.PnfTransformationToken;
+import org.openecomp.core.converter.pnfd.strategy.PnfdConversionStrategy;
+
+/**
+ * Handles YAML from/to {@link ConversionDefinition} conversions
+ */
+public class ConversionDefinitionYamlParser {
+
+ private ConversionDefinitionYamlParser() {
+
+ }
+
+ /**
+ * Parses the given a YAML object to a {@link ConversionDefinition} instance.
+ * @param conversionYaml the YAML object representing a conversion definition
+ * @return
+ * A new instance of {@link ConversionDefinition}.
+ */
+ public static ConversionDefinition parse(final Map<String, Object> conversionYaml) {
+ final ConversionQuery conversionQuery = ConversionQueryYamlParser
+ .parse(conversionYaml.get(PnfTransformationToken.QUERY.getName()));
+ final String toName = (String) conversionYaml.get(PnfTransformationToken.TO_NAME.getName());
+ final PnfdConversionStrategy toValue = PnfdConversionStrategyYamlParser
+ .parse((Map<String, Object>) conversionYaml.get(PnfTransformationToken.TO_VALUE.getName()))
+ .orElse(null);
+ final String toGetInput = (String) conversionYaml.get(PnfTransformationToken.TO_GET_INPUT.getName());
+
+ return new ConversionDefinition(conversionQuery, toName, toValue, toGetInput);
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionQueryYamlParser.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionQueryYamlParser.java
new file mode 100644
index 0000000000..417262c61c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionQueryYamlParser.java
@@ -0,0 +1,42 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.impl.pnfd.parser;
+
+import org.openecomp.core.converter.pnfd.model.ConversionQuery;
+
+/**
+ * Handles YAML from/to {@link ConversionQuery} conversions
+ */
+public class ConversionQueryYamlParser {
+
+ private ConversionQueryYamlParser() {
+
+ }
+
+ /**
+ * Parses the given a YAML object to a {@link ConversionQuery} instance.
+ * @param conversionYaml the YAML object representing a conversion query
+ * @return
+ * A new instance of {@link ConversionQuery}.
+ */
+ public static ConversionQuery parse(final Object conversionYaml) {
+ return new ConversionQuery(conversionYaml);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/NodeTemplateYamlParser.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/NodeTemplateYamlParser.java
new file mode 100644
index 0000000000..fdf276f37d
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/NodeTemplateYamlParser.java
@@ -0,0 +1,55 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.impl.pnfd.parser;
+
+import java.util.List;
+import java.util.Map;
+import org.onap.sdc.tosca.datatypes.model.NodeTemplate;
+
+/**
+ * Handles YAML from/to {@link NodeTemplate} conversions
+ */
+public class NodeTemplateYamlParser {
+
+ private NodeTemplateYamlParser() {
+ }
+
+ /**
+ * Parses the given a YAML object to a {@link NodeTemplate} instance.
+ * @param nodeTemplateYaml the YAML object representing a TOSCA Node Template
+ * @return
+ * A new instance of {@link NodeTemplate}.
+ */
+ public static NodeTemplate parse(final Map<String, Object> nodeTemplateYaml) {
+ final NodeTemplate nodeTemplate = new NodeTemplate();
+ nodeTemplate.setType((String) nodeTemplateYaml.get("type"));
+ nodeTemplate.setDescription((String) nodeTemplateYaml.get("description"));
+ nodeTemplate.setCopy((String) nodeTemplateYaml.get("copy"));
+ nodeTemplate.setProperties((Map<String, Object>) nodeTemplateYaml.get("properties"));
+ nodeTemplate.setAttributes((Map<String, Object>) nodeTemplateYaml.get("attributes"));
+ nodeTemplate.setDirectives((List<String>) nodeTemplateYaml.get("directives"));
+ nodeTemplate.setMetadata((Map<String, String>) nodeTemplateYaml.get("metadata"));
+ nodeTemplate.setInterfaces((Map<String, Object>) nodeTemplateYaml.get("interfaces"));
+
+ return nodeTemplate;
+ }
+
+
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/ParameterDefinitionYamlParser.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/ParameterDefinitionYamlParser.java
new file mode 100644
index 0000000000..d103326c11
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/ParameterDefinitionYamlParser.java
@@ -0,0 +1,57 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.impl.pnfd.parser;
+
+import java.util.Map;
+import org.onap.sdc.tosca.datatypes.model.EntrySchema;
+import org.onap.sdc.tosca.datatypes.model.ParameterDefinition;
+import org.onap.sdc.tosca.datatypes.model.Status;
+
+/**
+ * Handles YAML from/to {@link ParameterDefinition} conversions
+ */
+public class ParameterDefinitionYamlParser {
+
+ private ParameterDefinitionYamlParser() {
+ }
+
+ /**
+ * Parses the given a YAML object to a {@link ParameterDefinition} instance.
+ * @param parameterDefinitionYaml the YAML object representing a TOSCA Parameter Definition
+ * @return
+ * A new instance of {@link ParameterDefinition}.
+ */
+ public static ParameterDefinition parse(final Map<String, Object> parameterDefinitionYaml) {
+ final ParameterDefinition parameterDefinition = new ParameterDefinition();
+ parameterDefinition.set_default(parameterDefinitionYaml.get("default"));
+ parameterDefinition.setDescription((String) parameterDefinitionYaml.get("description"));
+ final Map<String, Object> entrySchemaYaml = (Map<String, Object>) parameterDefinitionYaml.get("entry_schema");
+ if (entrySchemaYaml != null) {
+ final EntrySchema entrySchema = new EntrySchema();
+ entrySchema.setType((String) entrySchemaYaml.get("type"));
+ parameterDefinition.setEntry_schema(entrySchema);
+ }
+ parameterDefinition.setRequired((Boolean) parameterDefinitionYaml.get("required"));
+ parameterDefinition.setType((String) parameterDefinitionYaml.get("type"));
+ parameterDefinition.setStatus((Status) parameterDefinitionYaml.get("status"));
+
+ return parameterDefinition;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdConversionStrategyYamlParser.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdConversionStrategyYamlParser.java
new file mode 100644
index 0000000000..dee16749ae
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdConversionStrategyYamlParser.java
@@ -0,0 +1,74 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.impl.pnfd.parser;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import org.openecomp.core.converter.pnfd.model.ConversionStrategyType;
+import org.openecomp.core.converter.pnfd.model.PnfTransformationToken;
+import org.openecomp.core.converter.impl.pnfd.strategy.CopyConversionStrategy;
+import org.openecomp.core.converter.pnfd.strategy.PnfdConversionStrategy;
+import org.openecomp.core.converter.impl.pnfd.strategy.ReplaceConversionStrategy;
+import org.openecomp.core.converter.impl.pnfd.strategy.ReplaceInListConversionStrategy;
+
+
+/**
+ * Handles YAML from/to {@link PnfdConversionStrategy} conversions.
+ */
+public class PnfdConversionStrategyYamlParser {
+
+ private PnfdConversionStrategyYamlParser() {
+
+ }
+
+ /**
+ * Parses the given YAML object to a {@link PnfdConversionStrategy} instance.
+ * @param strategyYaml the YAML object representing a conversion strategy
+ * @return
+ * A new instance of {@link PnfdConversionStrategy}.
+ */
+ public static Optional<PnfdConversionStrategy> parse(final Map<String, Object> strategyYaml) {
+ final Optional<ConversionStrategyType> optionalStrategy = ConversionStrategyType.parse(
+ (String) strategyYaml.get(PnfTransformationToken.STRATEGY.getName())
+ );
+
+ if (!optionalStrategy.isPresent()) {
+ return Optional.empty();
+ }
+
+ final ConversionStrategyType strategyType = optionalStrategy.get();
+ if (strategyType == ConversionStrategyType.COPY) {
+ return Optional.of(new CopyConversionStrategy());
+ }
+ if (strategyType == ConversionStrategyType.REPLACE) {
+ final Object from = strategyYaml.get(PnfTransformationToken.FROM.getName());
+ final Object to = strategyYaml.get(PnfTransformationToken.TO.getName());
+ return Optional.of(new ReplaceConversionStrategy(from, to));
+ }
+ if (strategyType == ConversionStrategyType.REPLACE_IN_LIST) {
+ return Optional.of(new ReplaceInListConversionStrategy(
+ (List<Map<String, Object>>) strategyYaml.get(PnfTransformationToken.LIST.getName()))
+ );
+ }
+ return Optional.empty();
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdInputBlockParser.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdInputBlockParser.java
new file mode 100644
index 0000000000..4aec8c8ac3
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdInputBlockParser.java
@@ -0,0 +1,94 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.impl.pnfd.parser;
+
+import com.google.common.collect.ImmutableMap;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+import org.apache.commons.collections.MapUtils;
+import org.onap.sdc.tosca.datatypes.model.ParameterDefinition;
+import org.openecomp.core.converter.pnfd.parser.AbstractPnfdBlockParser;
+import org.openecomp.core.converter.impl.pnfd.PnfdQueryExecutor;
+import org.openecomp.core.converter.pnfd.model.ConversionDefinition;
+import org.openecomp.core.converter.pnfd.model.ConversionQuery;
+import org.openecomp.core.converter.pnfd.model.Transformation;
+import org.openecomp.core.converter.pnfd.strategy.PnfdConversionStrategy;
+import org.openecomp.sdc.tosca.services.DataModelUtil;
+
+public class PnfdInputBlockParser extends AbstractPnfdBlockParser {
+
+ public PnfdInputBlockParser(final Transformation transformation) {
+ super(transformation);
+ }
+
+ @Override
+ protected Optional<Map<String, Object>> buildParsedBlock(final Map<String, Object> attributeQuery,
+ final Map<String, Object> originalAttributeMap, final ConversionDefinition conversionDefinition) {
+ //cannot query for more than one attribute
+ if (attributeQuery.keySet().size() > 1) {
+ return Optional.empty();
+ }
+ final String attribute = attributeQuery.keySet().iterator().next();
+ final Map<String, Object> parsedInput = new HashMap<>();
+ if (attributeQuery.get(attribute) == null) {
+ final PnfdConversionStrategy pnfdConversionStrategy = conversionDefinition.getPnfdConversionStrategy();
+ final Optional convertedAttribute = pnfdConversionStrategy.convert(originalAttributeMap.get(attribute));
+ convertedAttribute.ifPresent(convertedAttribute1 -> parsedInput.put(conversionDefinition.getToAttributeName(), convertedAttribute1));
+ } else {
+ final Optional<Map<String, Object>> builtInput = buildParsedBlock((Map<String, Object>) attributeQuery.get(attribute),
+ (Map<String, Object>) originalAttributeMap.get(attribute), conversionDefinition);
+ builtInput.ifPresent(builtInput1 -> parsedInput.put(attribute, builtInput1));
+ }
+
+ return parsedInput.isEmpty() ? Optional.empty() : Optional.of(parsedInput);
+ }
+
+ @Override
+ protected void write(final String blockName, final Map<String, Object> parsedBlockYamlObject) {
+ if (!parsedBlockYamlObject.isEmpty()) {
+ final ParameterDefinition parameterDefinition = ParameterDefinitionYamlParser.parse(parsedBlockYamlObject);
+ DataModelUtil.addInputParameterToTopologyTemplate(templateTo, blockName, parameterDefinition);
+ }
+ }
+
+ @Override
+ protected Set<Map<String, Object>> findBlocksToParse() {
+ final ConversionQuery conversionQuery = transformation.getConversionQuery();
+ final Map<String, Object> inputsMap = templateFrom.getInputs();
+ if (MapUtils.isEmpty(inputsMap)) {
+ return Collections.emptySet();
+ }
+
+ return inputsMap.entrySet().stream()
+ .filter(inputMapEntry -> PnfdQueryExecutor
+ .find(conversionQuery, ImmutableMap.of(inputMapEntry.getKey(), inputMapEntry.getValue()))
+ )
+ .map(inputMapEntry -> {
+ final Map<String, Object> map = new HashMap<>();
+ map.put(inputMapEntry.getKey(), inputMapEntry.getValue());
+ return map;
+ }).collect(Collectors.toSet());
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdNodeTemplateBlockParser.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdNodeTemplateBlockParser.java
new file mode 100644
index 0000000000..5539840561
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdNodeTemplateBlockParser.java
@@ -0,0 +1,114 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.impl.pnfd.parser;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+import org.apache.commons.collections.MapUtils;
+import org.onap.sdc.tosca.datatypes.model.NodeTemplate;
+import org.openecomp.core.converter.pnfd.parser.AbstractPnfdBlockParser;
+import org.openecomp.core.converter.impl.pnfd.PnfdQueryExecutor;
+import org.openecomp.core.converter.pnfd.model.ConversionDefinition;
+import org.openecomp.core.converter.pnfd.model.ConversionQuery;
+import org.openecomp.core.converter.pnfd.model.Transformation;
+import org.openecomp.core.converter.impl.pnfd.strategy.CopyConversionStrategy;
+import org.openecomp.core.converter.pnfd.strategy.PnfdConversionStrategy;
+import org.openecomp.sdc.tosca.services.DataModelUtil;
+
+public class PnfdNodeTemplateBlockParser extends AbstractPnfdBlockParser {
+
+ private Map<String, String> inputNameToConvertMap = new HashMap<>();
+
+ public PnfdNodeTemplateBlockParser(final Transformation transformation) {
+ super(transformation);
+ }
+
+ public Optional<Map<String, Object>> buildParsedBlock(final Map<String, Object> attributeQuery,
+ final Map<String, Object> fromNodeTemplateAttributeMap,
+ final ConversionDefinition conversionDefinition) {
+ //cannot query for more than one attribute
+ if (attributeQuery.keySet().size() > 1) {
+ return Optional.empty();
+ }
+ final String attribute = attributeQuery.keySet().iterator().next();
+ final Object queryValue = attributeQuery.get(attribute);
+ final Object attributeValueToConvert = fromNodeTemplateAttributeMap.get(attribute);
+ if (queryValue == null) {
+ PnfdConversionStrategy pnfdConversionStrategy = conversionDefinition.getPnfdConversionStrategy();
+ if (isGetInputFunction(attributeValueToConvert)) {
+ inputNameToConvertMap.put(extractGetInputFunctionValue(attributeValueToConvert)
+ , conversionDefinition.getToGetInput()
+ );
+ pnfdConversionStrategy = new CopyConversionStrategy();
+ }
+ final Map<String, Object> parsedNodeTemplate = new HashMap<>();
+ final Optional convertedAttribute = pnfdConversionStrategy.convert(attributeValueToConvert);
+ if (convertedAttribute.isPresent()) {
+ parsedNodeTemplate.put(conversionDefinition.getToAttributeName(), convertedAttribute.get());
+ }
+
+ return parsedNodeTemplate.isEmpty() ? Optional.empty() : Optional.of(parsedNodeTemplate);
+ } else {
+ if (!(queryValue instanceof Map) || !(attributeValueToConvert instanceof Map)) {
+ return Optional.empty();
+ }
+ final Map<String, Object> parsedNodeTemplate = new HashMap<>();
+ final Optional<Map<String, Object>> builtNodeTemplate = buildParsedBlock(
+ (Map<String, Object>) queryValue,
+ (Map<String, Object>) attributeValueToConvert, conversionDefinition);
+ builtNodeTemplate.ifPresent(builtNodeTemplate1 -> parsedNodeTemplate.put(attribute, builtNodeTemplate1));
+
+ return parsedNodeTemplate.isEmpty() ? Optional.empty() : Optional.of(parsedNodeTemplate);
+ }
+ }
+
+ protected Set<Map<String, Object>> findBlocksToParse() {
+ final ConversionQuery conversionQuery = transformation.getConversionQuery();
+ final Map<String, Object> nodeTemplateMap = templateFrom.getNodeTemplates();
+ if (MapUtils.isEmpty(nodeTemplateMap)) {
+ return Collections.emptySet();
+ }
+
+ return nodeTemplateMap.entrySet().stream()
+ .filter(mapEntry -> PnfdQueryExecutor.find(conversionQuery, mapEntry.getValue()))
+ .map(stringObjectEntry -> {
+ final Map<String, Object> map = new HashMap<>();
+ map.put(stringObjectEntry.getKey(), stringObjectEntry.getValue());
+ return map;
+ }).collect(Collectors.toSet());
+ }
+
+ @Override
+ public void write(final String nodeTemplateName, final Map<String, Object> parsedNodeTemplateMap) {
+ if (!parsedNodeTemplateMap.isEmpty()) {
+ final NodeTemplate parsedNodeTemplate = NodeTemplateYamlParser.parse(parsedNodeTemplateMap);
+ DataModelUtil.addNodeTemplate(templateTo, nodeTemplateName, parsedNodeTemplate);
+ }
+ }
+
+ @Override
+ public Optional<Map<String, String>> getInputAndTransformationNameMap() {
+ return Optional.of(inputNameToConvertMap);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/TransformationYamlParser.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/TransformationYamlParser.java
new file mode 100644
index 0000000000..16d06704b3
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/TransformationYamlParser.java
@@ -0,0 +1,80 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.impl.pnfd.parser;
+
+import static org.openecomp.core.converter.pnfd.model.PnfTransformationToken.CONVERSIONS;
+import static org.openecomp.core.converter.pnfd.model.PnfTransformationToken.DESCRIPTION;
+import static org.openecomp.core.converter.pnfd.model.PnfTransformationToken.NAME;
+import static org.openecomp.core.converter.pnfd.model.PnfTransformationToken.QUERY;
+import static org.openecomp.core.converter.pnfd.model.PnfTransformationToken.TRANSFORMATION_FOR;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import org.apache.commons.collections.CollectionUtils;
+import org.openecomp.core.converter.pnfd.model.ConversionDefinition;
+import org.openecomp.core.converter.pnfd.model.Transformation;
+import org.openecomp.core.converter.pnfd.model.TransformationBlock;
+
+/**
+ * Handles YAML from/to {@link Transformation} conversions
+ */
+public class TransformationYamlParser {
+
+ private TransformationYamlParser() {
+
+ }
+
+ /**
+ * Parses the given YAML object to a {@link Transformation} instance.
+ * @param transformationYaml the YAML object representing a transformation
+ * @return
+ * A new instance of {@link Transformation}.
+ */
+ public static Transformation parse(final Map<String, Object> transformationYaml) {
+ final Transformation transformation = new Transformation();
+ transformation.setName((String) transformationYaml.get(NAME.getName()));
+ transformation.setDescription((String) transformationYaml.get(DESCRIPTION.getName()));
+
+ final String block = (String) transformationYaml.get(TRANSFORMATION_FOR.getName());
+ transformation.setBlock(TransformationBlock.parse(block).orElse(null));
+
+ transformation.setConversionQuery(
+ ConversionQueryYamlParser.parse(transformationYaml.get(QUERY.getName()))
+ );
+ transformation.setConversionDefinitionList(parseConversions(transformationYaml));
+
+ return transformation;
+ }
+
+ private static List<ConversionDefinition> parseConversions(final Map<String, Object> conversionYaml) {
+ final List<Object> conversionList = (List<Object>) conversionYaml.get(CONVERSIONS.getName());
+
+ if (CollectionUtils.isEmpty(conversionList)) {
+ return Collections.emptyList();
+ }
+
+ return conversionList.stream()
+ .map(conversion -> ConversionDefinitionYamlParser.parse((Map<String, Object>) conversion))
+ .collect(Collectors.toList());
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/strategy/CopyConversionStrategy.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/strategy/CopyConversionStrategy.java
new file mode 100644
index 0000000000..c379dfa85c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/strategy/CopyConversionStrategy.java
@@ -0,0 +1,37 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.impl.pnfd.strategy;
+
+import java.util.HashMap;
+import java.util.Optional;
+import org.openecomp.core.converter.pnfd.strategy.AbstractPnfdConversionStrategy;
+import org.openecomp.core.converter.pnfd.model.ConversionStrategyType;
+
+public class CopyConversionStrategy extends AbstractPnfdConversionStrategy<Object, Object> {
+
+ public CopyConversionStrategy() {
+ super(ConversionStrategyType.COPY, new HashMap<>());
+ }
+
+ @Override
+ public Optional<Object> convert(final Object originalValue) {
+ return Optional.ofNullable(originalValue);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/strategy/ReplaceConversionStrategy.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/strategy/ReplaceConversionStrategy.java
new file mode 100644
index 0000000000..3bde6326b7
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/strategy/ReplaceConversionStrategy.java
@@ -0,0 +1,39 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.impl.pnfd.strategy;
+
+import java.util.HashMap;
+import java.util.Optional;
+import org.openecomp.core.converter.pnfd.strategy.AbstractPnfdConversionStrategy;
+import org.openecomp.core.converter.pnfd.model.ConversionStrategyType;
+
+public class ReplaceConversionStrategy extends AbstractPnfdConversionStrategy<Object, Object> {
+
+ public ReplaceConversionStrategy(final Object from, final Object to) {
+ super(ConversionStrategyType.REPLACE, new HashMap<>());
+ conversionMap.put(from, to);
+ }
+
+ @Override
+ public Optional<Object> convert(final Object originalValue) {
+ return Optional.ofNullable(conversionMap.get(originalValue));
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/strategy/ReplaceInListConversionStrategy.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/strategy/ReplaceInListConversionStrategy.java
new file mode 100644
index 0000000000..9984a8708d
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/strategy/ReplaceInListConversionStrategy.java
@@ -0,0 +1,60 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.impl.pnfd.strategy;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.stream.Collectors;
+import org.openecomp.core.converter.pnfd.strategy.AbstractPnfdConversionStrategy;
+import org.openecomp.core.converter.pnfd.model.ConversionStrategyType;
+import org.openecomp.core.converter.pnfd.model.PnfTransformationToken;
+
+public class ReplaceInListConversionStrategy extends AbstractPnfdConversionStrategy<List<Object>, List<Object>> {
+
+ private final Map<Object, Object> replaceInListConversionStrategyMap;
+
+ public ReplaceInListConversionStrategy(final List<Map<String, Object>> descriptorList) {
+ super(ConversionStrategyType.REPLACE_IN_LIST, new HashMap<>());
+ replaceInListConversionStrategyMap = new LinkedHashMap<>();
+ descriptorList
+ .forEach(stringObjectMap -> replaceInListConversionStrategyMap.put(stringObjectMap.get(
+ PnfTransformationToken.FROM.getName())
+ , stringObjectMap.get(PnfTransformationToken.TO.getName()))
+ );
+ }
+
+ @Override
+ public Optional<List<Object>> convert(final List<Object> originalValue) {
+ if (originalValue == null || originalValue.isEmpty()) {
+ return Optional.empty();
+ }
+
+ final List<Object> convertedList = originalValue.stream()
+ .map(replaceInListConversionStrategyMap::get)
+ .filter(Objects::nonNull)
+ .collect(Collectors.toList());
+
+ return convertedList.isEmpty() ? Optional.empty() : Optional.of(convertedList);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolConverterPnf.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolConverterPnf.java
deleted file mode 100644
index a3935ee735..0000000000
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolConverterPnf.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * -
- * * ============LICENSE_START=======================================================
- * * Copyright (C) 2019 Nordix Foundation.
- * * ================================================================================
- * * 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.
- * *
- * * SPDX-License-Identifier: Apache-2.0
- * * ============LICENSE_END=========================================================
- *
- */
-
-package org.openecomp.core.impl;
-
-import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.CONSTRAINTS;
-import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.DEFAULT_VALUE;
-import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.DESCRIPTION;
-import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.ENTRY_SCHEMA;
-import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.GET_INPUT;
-import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.PROPERTIES;
-import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.REQUIRED;
-import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.TYPE;
-
-import java.util.AbstractMap;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.stream.Collectors;
-import org.apache.commons.collections.MapUtils;
-import org.onap.sdc.tosca.datatypes.model.Constraint;
-import org.onap.sdc.tosca.datatypes.model.EntrySchema;
-import org.onap.sdc.tosca.datatypes.model.NodeTemplate;
-import org.onap.sdc.tosca.datatypes.model.ParameterDefinition;
-import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
-import org.onap.sdc.tosca.datatypes.model.TopologyTemplate;
-import org.openecomp.core.converter.ServiceTemplateReaderService;
-import org.openecomp.sdc.tosca.services.DataModelUtil;
-
-public class ToscaSolConverterPnf extends AbstractToscaSolConverter {
-
- private static final String PNF_EXT_CP_TYPE = "tosca.nodes.nfv.PnfExtCp";
- private static final String EXT_CP_TYPE = "org.openecomp.resource.cp.v2.extCP";
- private static final String LAYER_PROTOCOLS = "layer_protocols";
- private static final String ASSIGNMENT_METHOD = "assingment_method";
- private static final String DHCP = "dhcp";
- private static final String IP_V4 = "ipv4";
- private static final String IP_V6 = "ipv6";
- private static final String IP_VERSION = "ip_version";
- private static final String IP_REQUIREMENTS = "ip_requirements";
- private static final String IP_REQUIREMENTS_TYPE = "org.openecomp.datatypes.network.IpRequirements";
- private ServiceTemplate serviceTemplate;
- private ServiceTemplateReaderService readerService;
-
- /**
- * For PNF the node templates are converted ETSI node types to ecomp node types. All other data i.e. inputs,
- * substitution mappings and outputs are simply dropped at this stage. The equivalent ecomp data will be added when
- * the vsp is imported into the catalog.
- *
- * @param serviceTemplate - the service template
- * @param readerService - the reader service
- */
- @Override
- public void convertTopologyTemplate(final ServiceTemplate serviceTemplate,
- final ServiceTemplateReaderService readerService) {
- this.serviceTemplate = serviceTemplate;
- this.readerService = readerService;
- convertNodeTemplatesToEcompTypes();
- addEmptyNodeTemplatesIfNoneDefined();
- }
-
- /**
- * Copies a input from the reader (input) to the service template (output)
- * @param inputName the name of the input to copy
- */
- private void copyTopologyTemplateInput(final String inputName) {
- final Map<String, Object> inputMap = readerService.getInputs();
- if (MapUtils.isEmpty(inputMap)) {
- return;
- }
- final Map propertyMap = (Map) inputMap.get(inputName);
- final Object requiredObj = propertyMap.get(REQUIRED.getElementName());
- final Object constraintsObj = propertyMap.get(CONSTRAINTS.getElementName());
- final Object entrySchemaObj = propertyMap.get(ENTRY_SCHEMA.getElementName());
-
- EntrySchema entrySchema = null;
- if (entrySchemaObj instanceof Map) {
- final Map entrySchemaMap = ((Map) entrySchemaObj);
- entrySchema = parseEntrySchema(entrySchemaMap);
- }
- final ParameterDefinition parameterDefinition =
- DataModelUtil.createParameterDefinition(
- (String) propertyMap.get(TYPE.getElementName()),
- (String) propertyMap.get(DESCRIPTION.getElementName()),
- requiredObj instanceof Boolean ? (Boolean) requiredObj : null,
- constraintsObj instanceof List ? (List<Constraint>) constraintsObj : null,
- entrySchema,
- propertyMap.get(DEFAULT_VALUE.getElementName()));
-
- DataModelUtil
- .addInputParameterToTopologyTemplate(serviceTemplate, inputName, parameterDefinition);
- }
-
- /**
- * PNF only has nfv.PNF and nfv.PnfExtCp types defined in ETSI SOL001 v2.5.1. - The PNF is mapped to the outer
- * Abstract PNF container in ecomp model and hence nfv.PNF is dropped here. - nfv.PnfExtCp is mapped to ecomp
- * v2.extCp type.
- */
- private void convertNodeTemplatesToEcompTypes() {
- final Map<String, Object> nodeTemplates = readerService.getNodeTemplates();
- if (MapUtils.isEmpty(nodeTemplates)) {
- return;
- }
-
- nodeTemplates.entrySet().stream()
- .filter(nodeTemplateEntry ->
- PNF_EXT_CP_TYPE.equals(((Map<String, Object>) nodeTemplateEntry.getValue()).get(TYPE.getElementName())))
- .forEach(nodeTemplateEntry ->
- DataModelUtil.addNodeTemplate(serviceTemplate, nodeTemplateEntry.getKey(),
- convertToEcompConnectionPointNodeType((Map<String, Object>) nodeTemplateEntry.getValue())));
- }
-
- /**
- * Converts from the ETSI PnfExtCp node type to ecomp v2.extCP node type The following properties are mapped -
- * layer_protocols is mapped to ip_requirements if it contains the values ipv4 and/or ipv6. All other data e.g.
- * remaining properties, requirements, capabilities are not mapped over to ecomp equivalent
- *
- * @param pnfExtCp - the ETSI PnfExtCp map
- * @return ecomp v2.extCP node type
- */
- private NodeTemplate convertToEcompConnectionPointNodeType(final Map<String, Object> pnfExtCp) {
- final NodeTemplate nodeTemplate = new NodeTemplate();
- nodeTemplate.setType(EXT_CP_TYPE);
- final Map<String, Object> properties = (Map<String, Object>) pnfExtCp.get(PROPERTIES.getElementName());
-
- properties.entrySet().stream()
- .filter(propertyMap -> LAYER_PROTOCOLS.equals(propertyMap.getKey()))
- .forEach(propertyMap -> {
- final Object propertyValue = propertyMap.getValue();
- if (propertyValue instanceof List) {
- // layer_protocols: [ ipv4, ipv6, ... ]
- final List<Map<String, Object>> ipRequirements =
- convertToIpRequirementsProperty((List<String>) propertyValue);
- if (!ipRequirements.isEmpty()) {
- final Map<String, Object> convertedProperties = new HashMap<>();
- convertedProperties.put(IP_REQUIREMENTS, ipRequirements);
- nodeTemplate.setProperties(convertedProperties);
- }
- } else if (propertyValue instanceof AbstractMap) {
- final Map propertyValueMap = (Map) propertyValue;
- if (propertyValueMap.containsKey(GET_INPUT.getElementName())) {
- // layer_protocols: {get_input: anInputName}
- final Map<String, Object> convertedProperties = new HashMap<>();
- convertedProperties.put(IP_REQUIREMENTS, propertyValueMap);
- nodeTemplate.setProperties(convertedProperties);
- final String getInputValue = (String) propertyValueMap.get(GET_INPUT.getElementName());
- if (!isInputAlreadyAdded(getInputValue)) {
- copyTopologyTemplateInput(getInputValue);
- parseLayerProtocolsInputToIpRequirements(getInputValue);
- }
- }
- }
- });
- return nodeTemplate;
- }
-
- /**
- * Checks if a topology template input was already added
- *
- * @param inputName The name of the input to check
- * @return
- * {@code true} if the input was found in the topology template structure
- */
- private boolean isInputAlreadyAdded(final String inputName) {
- final TopologyTemplate topologyTemplate = serviceTemplate.getTopology_template();
- if (topologyTemplate == null) {
- return false;
- }
-
- final Map<String, ParameterDefinition> inputMap = topologyTemplate.getInputs();
- if (MapUtils.isNotEmpty(inputMap)) {
- return inputMap.keySet().contains(inputName);
- }
-
- return false;
- }
-
- /**
- * Parses a layer_protocol input to org.openecomp.datatypes.network.IpRequirements ecomp type.
- *
- * @param inputName The name of the input to parse
- *
- */
- private void parseLayerProtocolsInputToIpRequirements(final String inputName) {
- final TopologyTemplate topologyTemplate = serviceTemplate.getTopology_template();
- final ParameterDefinition layerProtocolsInput = topologyTemplate.getInputs().get(inputName);
- final EntrySchema entrySchema = layerProtocolsInput.getEntry_schema();
- entrySchema.setType(IP_REQUIREMENTS_TYPE);
- final List<String> defaultLayerProtocolList = (List<String>) layerProtocolsInput.get_default();
- layerProtocolsInput.set_default(convertToIpRequirementsProperty(defaultLayerProtocolList));
- }
-
- /**
- * Converts each layer_protocols entry that is either {@link #IP_V4} or {@link #IP_V6} to the ecomp
- * {@link #IP_REQUIREMENTS_TYPE}, ignoring other entry types.
- *
- * @param layerProtocols the PnfExtCp layer_protocols list
- * @return
- * A list of map representing a {@link #IP_REQUIREMENTS_TYPE} ecomp type
- */
- private List<Map<String, Object>> convertToIpRequirementsProperty(final List<String> layerProtocols) {
- return layerProtocols.stream()
- .filter(layerProtocol -> IP_V4.equals(layerProtocol) || IP_V6.equals(layerProtocol))
- .map(this::createIpRequirementsEntry)
- .collect(Collectors.toList());
- }
-
- /**
- * Creates a {@link #IP_REQUIREMENTS_TYPE} based on the ip version
- * @param ipVersion the provided ip version, either {@link #IP_V4} or {@link #IP_V6}
- * @return
- * A map representing an {@link #IP_REQUIREMENTS_TYPE} ecomp type
- */
- private Map<String, Object> createIpRequirementsEntry(final String ipVersion) {
- final int version = IP_V4.equals(ipVersion) ? 4 : 6;
- final Map<String, Object> result = new HashMap<>();
- result.put(IP_VERSION, version);
- result.put(ASSIGNMENT_METHOD, DHCP);
- return result;
- }
-
- /**
- * Fills missing required entries in the service template. Checks for topology_template entry and
- * topology_template->node_templates entry.
- */
- private void addEmptyNodeTemplatesIfNoneDefined() {
- TopologyTemplate topologyTemplate = serviceTemplate.getTopology_template();
- if (Objects.isNull(topologyTemplate)) {
- topologyTemplate = new TopologyTemplate();
- serviceTemplate.setTopology_template(topologyTemplate);
- }
- if (topologyTemplate.getNode_templates() == null) {
- topologyTemplate.setNode_templates(new HashMap<>());
- }
- }
-
- /**
- * Parses an input entry schema
- *
- * @param entrySchemaMap the descriptor input entry schema map
- * @return
- * A parsed entry schema based on the provided map
- */
- private EntrySchema parseEntrySchema(Map entrySchemaMap) {
- return DataModelUtil.createEntrySchema((String) entrySchemaMap.get(TYPE.getElementName())
- , (String) entrySchemaMap.get(DESCRIPTION.getElementName())
- , (List<Constraint>) entrySchemaMap.get(CONSTRAINTS.getElementName())
- );
- }
-
-} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolModelDrivenConverterPnf.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolModelDrivenConverterPnf.java
new file mode 100644
index 0000000000..ee2c4060e5
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolModelDrivenConverterPnf.java
@@ -0,0 +1,39 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.impl;
+
+import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.core.converter.ServiceTemplateReaderService;
+import org.openecomp.core.converter.impl.pnfd.PnfdTransformationEngine;
+
+public class ToscaSolModelDrivenConverterPnf extends AbstractToscaSolConverter {
+
+ /**
+ * Calls the model driven engine to parse the onboarding PNF descriptor
+ * @param serviceTemplate
+ * @param readerService
+ */
+ @Override
+ public void convertTopologyTemplate(final ServiceTemplate serviceTemplate, final ServiceTemplateReaderService readerService) {
+ final PnfdTransformationEngine pnfdTransformationEngine = new PnfdTransformationEngine(readerService, serviceTemplate);
+ pnfdTransformationEngine.transform();
+ }
+
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/resources/pnfdTransformationTemplate/model-driven-conversion.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/resources/pnfdTransformationTemplate/model-driven-conversion.yaml
new file mode 100644
index 0000000000..c58a23b8a2
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/resources/pnfdTransformationTemplate/model-driven-conversion.yaml
@@ -0,0 +1,76 @@
+- transformation-for: nodeTemplate #block
+ name: PnfExtCp transformation #transformation name
+ description: converts any node template that has a type tosca.nodes.nfv.PnfExtCp #transformation description
+ query: # Block query. Searches for node_template(s) with the same attributes. Ignores the node_template name.
+ # Supports recursive structure of key (string): value (new map or string).
+ # Each lvl can contain more than one key that will be treated as an AND.
+ # Must have the same structure in the original node_template declaration, otherwise the node_template will not be found.
+ type: tosca.nodes.nfv.PnfExtCp
+ conversions: # List of conversions/transformations that will be applied to the node_template attributes.
+ - query: # Attribute query for "type". Finds one attribute inside the node_template(s) found with the block query.
+ # Supports recursive structure of key (string): value (new map or string).
+ # Each lvl can only contain one key.
+ # If the attribute is found, the transformation strategy defined in this element will be applied.
+ # Must have the same structure in the original node_template declaration, otherwise the attribute will not be found.
+ type:
+ to-name: type # New attribute name.
+ to-value:
+ # Replace transformation strategy: replaces the old value for a new one. Must have this structure.
+ strategy: replace # Transformation strategy name.
+ from: tosca.nodes.nfv.PnfExtCp # Original attribute value.
+ to: org.openecomp.resource.cp.v2.extCP # New attribute value.
+ - query: # Another attribute query. This time for "properties/layer_protocols"
+ properties:
+ layer_protocols:
+ to-name: ip_requirements
+ to-value:
+ # Replace in list strategy: replaces specific values of a list for new ones.
+ strategy: replaceInList
+ list: # List of values to be replaced
+ - from: ipv4 # Searches for "ipv4" value and...
+ to: #...replaces for the following map
+ assingment_method: dhcp
+ ip_version: 4
+ - from: ipv6 # Another list value search and replace
+ to:
+ assingment_method: dhcp
+ ip_version: 6
+ # When a TOSCA { get_input: provided-input-name } function is found, the "provided-input-name"
+ # will be converted using the "transformation-for: getInputFunction" with name "ipRequirements".
+ to-get-input: ipRequirements
+- transformation-for: getInputFunction # Transforms inputs called by get_input TOSCA function.
+ name: ipRequirements # Transformation name, used to be referred by "to-get-input" transformation attribute.
+ description: converts IpRequirements inputs when called by a get_input TOSCA function
+ conversions: #this part works exactly the same as the correspondent node_template transformation declarations.
+ - query:
+ type:
+ to-name: type
+ to-value:
+ strategy: copy
+ - query:
+ description:
+ to-name: description
+ to-value:
+ strategy: copy
+ - query:
+ entry_schema:
+ type:
+ to-name: type
+ to-value:
+ strategy: replace
+ from: string
+ to: org.openecomp.datatypes.network.IpRequirements
+ - query:
+ default:
+ to-name: default
+ to-value:
+ strategy: replaceInList
+ list:
+ - from: ipv4
+ to:
+ assingment_method: dhcp
+ ip_version: 4
+ - from: ipv6
+ to:
+ assingment_method: dhcp
+ ip_version: 6 \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/PnfTransformationEngineParameterizedTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/PnfTransformationEngineParameterizedTest.java
new file mode 100644
index 0000000000..e2cbc147ac
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/PnfTransformationEngineParameterizedTest.java
@@ -0,0 +1,152 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.impl.pnfd;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.onap.sdc.tosca.services.ToscaExtensionYamlUtil;
+import org.onap.sdc.tosca.services.YamlUtil;
+import org.openecomp.core.converter.ServiceTemplateReaderService;
+import org.openecomp.core.impl.services.ServiceTemplateReaderServiceImpl;
+
+@RunWith(Parameterized.class)
+public class PnfTransformationEngineParameterizedTest {
+
+ private static final String TEST_CASES_PATH = "transformation/pnfParseEngine";
+ private static final String TRANSFORMATION_DESCRIPTOR_FOLDER = "transformationDescriptor";
+ private static final String OUTPUT_FOLDER = "expectedOutput";
+ private static final String DEFAULT_OUTPUT_FILE_NAME = "defaultOutput.yaml";
+
+ private final String inputFileName;
+ private final Path inputFilePath;
+ private final String outputFileName;
+ private final Path outputFilePath;
+ private final String transformationDescriptorFileName;
+ private final Path transformationDescriptorFilePath;
+ private final YamlUtil yamlUtil = new YamlUtil();
+ private final ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
+
+ public PnfTransformationEngineParameterizedTest(final String inputFileName, final Path inputFilePath,
+ final String outputFileName, final Path outputFilePath,
+ final String transformationDescriptorFileName, final Path transformationDescriptorFilePath) {
+ this.inputFileName = inputFileName;
+ this.inputFilePath = inputFilePath;
+ this.outputFileName = outputFileName;
+ this.outputFilePath = outputFilePath;
+ this.transformationDescriptorFileName = transformationDescriptorFileName;
+ this.transformationDescriptorFilePath = transformationDescriptorFilePath;
+ }
+
+
+ @Parameterized.Parameters(name = "{index}: input: {0}, descriptor: {4}, output: {2}")
+ public static Collection input() throws IOException {
+ return Files.list(getPathFromClasspath(TEST_CASES_PATH)).map(path -> {
+ try {
+ return buildTestCase(path);
+ } catch (final IOException e) {
+ return null;
+ }
+ }).filter(Objects::nonNull).flatMap(Collection::stream).collect(Collectors.toList());
+ }
+
+ private static Collection buildTestCase(final Path testCasePath) throws IOException {
+ final Path inputFilePath = Files.list(testCasePath)
+ .filter(path -> path.toFile().getName().endsWith("yaml"))
+ .findAny().orElse(null);
+
+ if (inputFilePath == null) {
+ return Collections.emptyList();
+ }
+ ;
+ final List<Path> transformationDescriptorList;
+ try (final Stream<Path> files = Files.walk(testCasePath.resolve(TRANSFORMATION_DESCRIPTOR_FOLDER))) {
+ transformationDescriptorList = files.filter(path -> Files.isRegularFile(path))
+ .map(path -> Paths.get(TEST_CASES_PATH, testCasePath.getFileName().toString()
+ , TRANSFORMATION_DESCRIPTOR_FOLDER, path.getFileName().toString()))
+ .collect(Collectors.toList());
+ }
+
+ final List<Path> outputList;
+ try (final Stream<Path> files = Files.walk(testCasePath.resolve(OUTPUT_FOLDER))) {
+ outputList = files.filter(path -> Files.isRegularFile(path)).collect(Collectors.toList());
+ }
+ final Path defaultOutput = outputList.stream()
+ .filter(path -> path.toFile().getName().equals(DEFAULT_OUTPUT_FILE_NAME))
+ .findFirst().orElse(null);
+
+ final List<Object[]> testCaseList = new ArrayList<>();
+
+ for (final Path transformationDescriptorPath : transformationDescriptorList) {
+ final Path outputPath = outputList.stream()
+ .filter(path -> path.toFile().getName().equals(transformationDescriptorPath.toFile().getName()))
+ .findFirst().orElse(defaultOutput);
+ if (outputPath != null) {
+ testCaseList.add(new Object[] {inputFilePath.toFile().getName(), inputFilePath,
+ outputPath.toFile().getName(), outputPath,
+ transformationDescriptorPath.toFile().getName(), transformationDescriptorPath});
+ }
+ }
+
+ return testCaseList;
+
+ }
+
+ @Test
+ public void testTopologyTemplateConversions() throws IOException {
+ final byte[] descriptor = Files.readAllBytes(inputFilePath);
+ final ServiceTemplateReaderService serviceTemplateReaderService = new ServiceTemplateReaderServiceImpl(descriptor);
+ final ServiceTemplate serviceTemplate = new ServiceTemplate();
+
+ final PnfdTransformationEngine pnfdTransformationEngine = new PnfdTransformationEngine(serviceTemplateReaderService, serviceTemplate
+ , transformationDescriptorFilePath.toString());
+ pnfdTransformationEngine.transform();
+
+ final String result = yamlUtil.objectToYaml(serviceTemplate);
+ final String expectedResult = parseToYaml(outputFilePath);
+ assertEquals(expectedResult, result);
+ }
+
+ private String parseToYaml(final Path filePath) throws IOException {
+ try (final InputStream inputStream = Files.newInputStream(filePath)) {
+ ServiceTemplate serviceTemplate = toscaExtensionYamlUtil.yamlToObject(inputStream, ServiceTemplate.class);
+ return yamlUtil.objectToYaml(serviceTemplate);
+ }
+ }
+
+ private static Path getPathFromClasspath(final String location) {
+ return Paths.get(Thread.currentThread().getContextClassLoader().getResource(location).getPath());
+ }
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaSolConverterPnfTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/PnfTransformationEngineTest.java
index 4d59d6bfe9..280d14888d 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaSolConverterPnfTest.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/PnfTransformationEngineTest.java
@@ -1,30 +1,25 @@
/*
- * -
- * * ============LICENSE_START=======================================================
- * * Copyright (C) 2019 Nordix Foundation.
- * * ================================================================================
- * * 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.
- * *
- * * SPDX-License-Identifier: Apache-2.0
- * * ============LICENSE_END=========================================================
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
*/
-package org.openecomp.core.impl;
+package org.openecomp.core.converter.impl.pnfd;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.equalTo;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.io.InputStream;
@@ -45,57 +40,53 @@ import org.openecomp.core.converter.ServiceTemplateReaderService;
import org.openecomp.core.impl.services.ServiceTemplateReaderServiceImpl;
@RunWith(Parameterized.class)
-public class ToscaSolConverterPnfTest {
+public class PnfTransformationEngineTest {
- private static final String INPUT_DIR = "pnfDescriptor/in/";
- private static final String OUTPUT_DIR = "pnfDescriptor/out/";
+ public static final String INPUT_DIR = "pnfDescriptor/in/";
+ public static final String OUTPUT_DIR = "pnfDescriptor/out/";
private String inputFilename;
- private YamlUtil yamlUtil = new YamlUtil();
- private ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
+ private final YamlUtil yamlUtil = new YamlUtil();
+ private final ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
- public ToscaSolConverterPnfTest(String inputFilename) {
+ public PnfTransformationEngineTest(final String inputFilename) {
this.inputFilename = inputFilename;
}
@Parameterized.Parameters(name = "{index}: {0}")
public static Collection<String> input() throws IOException {
- try (Stream<Path> files = Files.list(getPathFromClasspath(INPUT_DIR))) {
+ try (final Stream<Path> files = Files.list(getPathFromClasspath(INPUT_DIR))) {
return files.map(path -> path.getFileName().toString())
.collect(Collectors.toList());
}
}
@Test
- public void testTopologyTemplateConversions() {
+ public void testTopologyTemplateConversions() throws IOException {
final byte[] descriptor = getInputFileResource(inputFilename);
- final ServiceTemplateReaderService serviceTemplateReaderService =
- new ServiceTemplateReaderServiceImpl(descriptor);
+ final ServiceTemplateReaderService serviceTemplateReaderService = new ServiceTemplateReaderServiceImpl(descriptor);
final ServiceTemplate serviceTemplate = new ServiceTemplate();
- final ToscaSolConverterPnf toscaSolConverter = new ToscaSolConverterPnf();
- toscaSolConverter.convertTopologyTemplate(serviceTemplate, serviceTemplateReaderService);
- final String actualYaml = yamlUtil.objectToYaml(serviceTemplate);
- final String expectedYaml = getExpectedResultFor(inputFilename);
- assertThat("Converted PNF descriptor should be the same as the expected topology template", actualYaml,
- equalTo(expectedYaml));
+ final PnfdTransformationEngine pnfdTransformationEngine = new PnfdTransformationEngine(
+ serviceTemplateReaderService, serviceTemplate);
+ pnfdTransformationEngine.transform();
+
+ final String result = yamlUtil.objectToYaml(serviceTemplate);
+ final String expectedResult = getExpectedResultFor(inputFilename);
+ assertEquals(expectedResult, result);
}
- private String getExpectedResultFor(final String inputFilename) {
+ private String getExpectedResultFor(final String inputFilename) throws IOException {
try (final InputStream inputStream = getOutputFileResourceCorrespondingTo(inputFilename)) {
final ServiceTemplate serviceTemplate = toscaExtensionYamlUtil.yamlToObject(inputStream, ServiceTemplate.class);
return yamlUtil.objectToYaml(serviceTemplate);
- } catch (final IOException e) {
- fail(String.format("Could not find file '%s'", inputFilename));
}
-
- return null;
}
private static Path getPathFromClasspath(final String location) {
return Paths.get(Thread.currentThread().getContextClassLoader().getResource(location).getPath());
}
- private byte[] getInputFileResource(final String inputFilename) {
+ private byte[] getInputFileResource(final String inputFilename) throws IOException {
return getFileResource(INPUT_DIR + inputFilename);
}
@@ -108,14 +99,10 @@ public class ToscaSolConverterPnfTest {
return inputFilename.replace("pnfDescriptor", "topologyTemplate");
}
- private byte[] getFileResource(final String filePath) {
- try (InputStream inputStream = getFileResourceAsInputStream(filePath)) {
+ private byte[] getFileResource(final String filePath) throws IOException {
+ try (final InputStream inputStream = getFileResourceAsInputStream(filePath)) {
return IOUtils.toByteArray(inputStream);
- } catch (final IOException e) {
- fail(String.format("Could not find file '%s'", filePath));
}
-
- return null;
}
private InputStream getFileResourceAsInputStream(final String filePath) {
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/PnfdQueryExecutorTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/PnfdQueryExecutorTest.java
new file mode 100644
index 0000000000..17f60ee43c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/PnfdQueryExecutorTest.java
@@ -0,0 +1,229 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.impl.pnfd;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.openecomp.core.converter.pnfd.exception.QueryOperationNotSupportedException;
+import org.openecomp.core.converter.pnfd.model.ConversionQuery;
+
+public class PnfdQueryExecutorTest {
+ @Rule
+ public ExpectedException expectedExceptionRule = ExpectedException.none();
+
+ private Map<String, Object> yamlToQuery;
+
+ @Before
+ public void setup() {
+ yamlToQuery = new HashMap<>();
+ final LinkedHashMap<String, Object> nodeTemplateMap = new LinkedHashMap<>();
+ yamlToQuery.put("topology_template", nodeTemplateMap);
+ final Map nodeTemplate1 = ImmutableMap.of("nodeTemplate1"
+ , ImmutableMap.of(
+ "type", "tosca.nodes.nfv.PNF",
+ "properties", ImmutableMap.of(
+ "layers_protocol", "",
+ "provider", "Mycompany",
+ "version", "1.0"
+ )
+ )
+ );
+
+ final Map nodeTemplate2 = ImmutableMap.of("nodeTemplate2"
+ , ImmutableMap.of(
+ "type", "tosca.nodes.nfv.PnfExtCp",
+ "properties", ImmutableMap.of(
+ "trunk_mode", "false",
+ "role", "leaf",
+ "description", "External connection point to access this pnf",
+ "layers_protocol", ImmutableList.of("ipv4", "ipv6", "otherProtocol")
+ )
+ )
+ );
+
+ nodeTemplateMap.putAll(nodeTemplate1);
+ nodeTemplateMap.putAll(nodeTemplate2);
+ }
+
+
+ @Test
+ public void queryNestedYaml() {
+ //given
+ final ImmutableMap<String, Object> query =
+ ImmutableMap.of("topology_template",
+ ImmutableMap.of("nodeTemplate2",
+ ImmutableMap.of("type", "tosca.nodes.nfv.PnfExtCp")
+ )
+ );
+ //when
+ final boolean queryResult = PnfdQueryExecutor.find(new ConversionQuery(query), yamlToQuery);
+ //then
+ assertThat("Element should be found", queryResult, is(true));
+ }
+
+ @Test
+ public void andQueryWithPropertiesInSameLevel() {
+ //given
+ final ImmutableMap<String, Object> query =
+ ImmutableMap.of(
+ "topology_template",
+ ImmutableMap.of(
+ "nodeTemplate2",
+ ImmutableMap.of(
+ "type", "tosca.nodes.nfv.PnfExtCp",
+ "properties", ImmutableMap.of(
+ "role", "leaf",
+ "description", "External connection point to access this pnf"
+ )
+ )
+ )
+ );
+ //when
+ final boolean queryResult = PnfdQueryExecutor.find(new ConversionQuery(query), yamlToQuery);
+ //then
+ assertThat("Element should be found", queryResult, is(true));
+ }
+
+ @Test
+ public void andQueryWithPropertiesDifferentLevel() {
+ //given
+ final ImmutableMap<String, Object> query =
+ ImmutableMap.of(
+ "topology_template",
+ ImmutableMap.of(
+ "nodeTemplate2",
+ ImmutableMap.of(
+ "type", "tosca.nodes.nfv.PnfExtCp"
+ ),
+ "nodeTemplate1",
+ ImmutableMap.of(
+ "type", "tosca.nodes.nfv.PNF"
+ )
+ )
+ );
+ //when
+ final boolean queryResult = PnfdQueryExecutor.find(new ConversionQuery(query), yamlToQuery);
+ //then
+ assertThat("Element should be found", queryResult, is(true));
+ }
+
+ @Test
+ public void queryListPropertyNotSupported() {
+ //then
+ expectedExceptionRule.expect(QueryOperationNotSupportedException.class);
+ expectedExceptionRule.expectMessage("Yaml list query is not supported yet");
+ //given query with a list instance
+ final ImmutableMap<String, Object> query =
+ ImmutableMap.of(
+ "topology_template",
+ ImmutableMap.of(
+ "nodeTemplate2",
+ ImmutableMap.of(
+ "type", "tosca.nodes.nfv.PnfExtCp",
+ "properties", ImmutableMap.of(
+ "layers_protocol", ImmutableList.of("ipv4", "ipv6", "otherProtocol")
+ )
+ )
+ )
+ );
+ //when
+ final boolean queryResult = PnfdQueryExecutor.find(new ConversionQuery(query), yamlToQuery);
+ }
+
+ @Test
+ public void queryStartingListPropertyNotSupported() {
+ //then
+ expectedExceptionRule.expect(QueryOperationNotSupportedException.class);
+ expectedExceptionRule.expectMessage("Yaml list query is not supported yet");
+ //given query with a list instance
+ final Object query = ImmutableSet.of("test", "test", "test");
+ //when
+ PnfdQueryExecutor.find(new ConversionQuery(query), yamlToQuery);
+ }
+
+ @Test
+ public void queryWithUnsupportedClassInstance() {
+ //given a query with unsupported class instance
+ final Object query = ImmutableMap.of("topology_template", new Object());
+ //then
+ expectedExceptionRule.expect(QueryOperationNotSupportedException.class);
+ expectedExceptionRule.expectMessage(String.format("Yaml query operation for '%s' is not supported yet", Object.class));
+ //when
+ PnfdQueryExecutor.find(new ConversionQuery(query), yamlToQuery);
+ }
+
+ @Test
+ public void queryAString() {
+ //given a query with string
+ final Object yaml = "query";
+ final Object query = "query";
+ //when
+ final boolean queryResult = PnfdQueryExecutor.find(new ConversionQuery(query), yaml);
+
+ //then
+ assertThat("Element should be found", queryResult, is(true));
+
+ }
+
+ @Test
+ public void queryWithNullPropertyValue() {
+ //given a query with string
+ final Map<String, Object> query1 = new HashMap<>();
+ query1.put("topology_template", null);
+
+ final Map<String, Object> topologyTemplate = new HashMap<>();
+ topologyTemplate.put("nodeTemplate1", null);
+ final Object query2 = ImmutableMap.of("topology_template", topologyTemplate);
+
+ final Map<String, Object> query3 = new HashMap<>();
+ query3.put("topology_template1", null);
+ //when
+ final boolean queryResult1 = PnfdQueryExecutor.find(new ConversionQuery(query1), yamlToQuery);
+ final boolean queryResult2 = PnfdQueryExecutor.find(new ConversionQuery(query2), yamlToQuery);
+ final boolean queryResult3 = PnfdQueryExecutor.find(new ConversionQuery(query3), yamlToQuery);
+ //then
+ assertThat("Element should be found", queryResult1, is(true));
+ assertThat("Element should be found", queryResult2, is(true));
+ assertThat("Element should be found", queryResult3, is(false));
+ }
+
+ @Test
+ public void nullQuery() {
+ //given a null query
+ final Object query = null;
+ //when
+ final boolean queryResult = PnfdQueryExecutor.find(new ConversionQuery(query), yamlToQuery);
+ //then
+ assertThat("Element should be found", queryResult, is(true));
+
+ }
+
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionDefinitionYamlParserTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionDefinitionYamlParserTest.java
new file mode 100644
index 0000000000..967081ba0f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionDefinitionYamlParserTest.java
@@ -0,0 +1,69 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.impl.pnfd.parser;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+import static org.openecomp.core.converter.pnfd.model.PnfTransformationToken.QUERY;
+import static org.openecomp.core.converter.pnfd.model.PnfTransformationToken.TO_NAME;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+import org.junit.Test;
+import org.openecomp.core.converter.pnfd.model.ConversionDefinition;
+import org.openecomp.core.converter.pnfd.model.ConversionStrategyType;
+import org.openecomp.core.util.TestResourcesUtil;
+import org.openecomp.core.util.YamlTestUtil;
+
+public class ConversionDefinitionYamlParserTest {
+
+ @Test
+ public void shouldBuildDefinition() {
+ final Map<String, Object> definitionYaml;
+ final String definitionYamlFilePath = "transformation/conversionDefinition/conversionDefinitionWithReplaceStrategy.yaml";
+ try (final InputStream resourceInputStream = TestResourcesUtil.getFileResourceAsStream(definitionYamlFilePath)) {
+ definitionYaml = (Map<String, Object>) YamlTestUtil.read(resourceInputStream);
+ } catch (final IOException e) {
+ fail(String.format("Could not load %s", definitionYamlFilePath));
+ return;
+ }
+ final ConversionDefinition conversionDefinition = ConversionDefinitionYamlParser.parse(definitionYaml);
+ assertConversionDefinition(definitionYaml, conversionDefinition);
+ }
+
+ private void assertConversionDefinition(final Map<String, Object> definitionYaml,
+ final ConversionDefinition conversionDefinition) {
+ assertThat("The conversion definition should have been built"
+ , conversionDefinition, notNullValue());
+ assertThat("Should have initialized the conversion definition query"
+ , conversionDefinition.getConversionQuery(), notNullValue());
+ assertThat("The conversion definition should have been built"
+ , conversionDefinition.getConversionQuery().getQuery(), equalTo(definitionYaml.get(QUERY.getName())));
+ assertThat("Should have initialized the conversion definition to attribute name"
+ , conversionDefinition.getToAttributeName(), equalTo(definitionYaml.get(TO_NAME.getName())));
+ assertThat("Should have initialized the conversion definition strategy"
+ , conversionDefinition.getPnfdConversionStrategy(), notNullValue());
+ assertThat("Should have the expected strategy"
+ , conversionDefinition.getPnfdConversionStrategy().getStrategyType(), equalTo(ConversionStrategyType.REPLACE));
+ }
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/NodeTemplateYamlParserTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/NodeTemplateYamlParserTest.java
new file mode 100644
index 0000000000..5bb7ca360e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/NodeTemplateYamlParserTest.java
@@ -0,0 +1,46 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.impl.pnfd.parser;
+
+import static org.hamcrest.Matchers.aMapWithSize;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.junit.Assert.assertThat;
+
+import java.util.Map;
+import org.junit.Test;
+import org.onap.sdc.tosca.datatypes.model.NodeTemplate;
+import org.openecomp.core.converter.impl.pnfd.parser.NodeTemplateYamlParser;
+import org.openecomp.core.util.YamlTestUtil;
+
+public class NodeTemplateYamlParserTest {
+
+ @Test
+ public void shouldParseNodeTemplate() {
+ final Map<String, Object> nodeTemplateYaml = (Map<String, Object>) YamlTestUtil.readOrFail("transformation/nodeTemplate/nodeTemplate.yaml");
+ final NodeTemplate nodeTemplate = NodeTemplateYamlParser.parse(nodeTemplateYaml);
+ assertThat("Should have the same type", nodeTemplate.getType(), equalTo(nodeTemplateYaml.get("type")));
+ assertThat("Should have a not null properties map", nodeTemplate.getProperties(), notNullValue());
+ assertThat("Should have a not empty properties map", nodeTemplate.getProperties(), is(not(aMapWithSize(0))));
+ assertThat("Should have the same properties", nodeTemplate.getProperties(), equalTo(nodeTemplateYaml.get("properties")));
+ }
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdConversionStrategyYamlParserParametrizedTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdConversionStrategyYamlParserParametrizedTest.java
new file mode 100644
index 0000000000..83b7620b42
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdConversionStrategyYamlParserParametrizedTest.java
@@ -0,0 +1,68 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.impl.pnfd.parser;
+
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Optional;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+import org.openecomp.core.converter.pnfd.strategy.PnfdConversionStrategy;
+import org.openecomp.core.converter.impl.pnfd.strategy.ReplaceConversionStrategy;
+import org.openecomp.core.util.YamlTestUtil;
+
+@RunWith(Parameterized.class)
+public class PnfdConversionStrategyYamlParserParametrizedTest {
+
+ private final String strategyYamlFilePath;
+ private final Class expectedStrategyClass;
+
+ public PnfdConversionStrategyYamlParserParametrizedTest(final String strategyYamlFilePath, final Class expectedStrategyClass) {
+ this.strategyYamlFilePath = strategyYamlFilePath;
+ this.expectedStrategyClass = expectedStrategyClass;
+ }
+
+ @Parameters(name = "Run {index} for {0}, expecting {1}")
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][] {
+ {"transformation/strategy/replaceStrategy.yaml", ReplaceConversionStrategy.class}
+ });
+ }
+
+ @Test
+ public void shouldBuildTheExpectedStrategy() {
+ final Object replaceStrategyYaml = YamlTestUtil.readOrFail(strategyYamlFilePath);
+ final Optional<PnfdConversionStrategy> actualStrategy = PnfdConversionStrategyYamlParser
+ .parse((Map<String, Object>) replaceStrategyYaml);
+
+ assertThat("The strategy should have been built"
+ , actualStrategy.isPresent(), is(true));
+ assertThat("The built strategy should be " + expectedStrategyClass.getName()
+ , actualStrategy.get(), instanceOf(expectedStrategyClass));
+ }
+
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdConversionStrategyYamlParserTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdConversionStrategyYamlParserTest.java
new file mode 100644
index 0000000000..1eab214980
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdConversionStrategyYamlParserTest.java
@@ -0,0 +1,53 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.converter.impl.pnfd.parser;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.Optional;
+import org.junit.Test;
+import org.openecomp.core.converter.pnfd.strategy.PnfdConversionStrategy;
+import org.openecomp.core.util.TestResourcesUtil;
+import org.openecomp.core.util.YamlTestUtil;
+
+public class PnfdConversionStrategyYamlParserTest {
+
+ @Test
+ public void parseInvalidYamlObject() {
+ final Object replaceStrategyYaml;
+ final String strategyYamlFilePath = "transformation/strategy/strategyMissingStrategyAttribute.yaml";
+ try (final InputStream resourceInputStream = TestResourcesUtil.getFileResourceAsStream(strategyYamlFilePath)) {
+ replaceStrategyYaml = YamlTestUtil.read(resourceInputStream);
+ } catch (final IOException e) {
+ fail(String.format("Could not load %s", strategyYamlFilePath));
+ return;
+ }
+ final Optional<PnfdConversionStrategy> actualStrategy = PnfdConversionStrategyYamlParser
+ .parse((Map<String, Object>) replaceStrategyYaml);
+ assertThat("The strategy should not have been built"
+ , actualStrategy.isPresent(), is(false));
+ }
+
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaConverterImplTest.java
index c14b02b3a0..3e4e62a0d1 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaConverterImplTest.java
@@ -1,24 +1,23 @@
-/*-
+/*
* ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
*/
-package org.openecomp.core.converter.impl;
+package org.openecomp.core.impl;
import org.apache.commons.collections.CollectionUtils;
import org.junit.Assert;
@@ -27,7 +26,6 @@ import org.onap.sdc.tosca.datatypes.model.*;
import org.onap.sdc.tosca.services.ToscaExtensionYamlUtil;
import org.onap.sdc.tosca.services.YamlUtil;
import org.openecomp.core.converter.ToscaConverter;
-import org.openecomp.core.impl.ToscaConverterImpl;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.utilities.json.JsonUtil;
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConvertorDefinitionsTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaConvertorDefinitionsTest.java
index 68318c7b73..b978b7db99 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConvertorDefinitionsTest.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaConvertorDefinitionsTest.java
@@ -1,31 +1,28 @@
-/*-
+/*
* ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
*/
-package org.openecomp.core.converter.impl;
+package org.openecomp.core.impl;
import org.apache.commons.io.IOUtils;
import org.junit.Ignore;
import org.junit.Test;
import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
-import org.openecomp.core.impl.GlobalSubstitutionServiceTemplate;
-import org.openecomp.core.impl.ToscaConverterImpl;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaSolConverterPnfMultipleNodeTemplatesTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaSolConverterPnfMultipleNodeTemplatesTest.java
deleted file mode 100644
index 21394c9c47..0000000000
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaSolConverterPnfMultipleNodeTemplatesTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * -
- * * ============LICENSE_START=======================================================
- * * Copyright (C) 2019 Nordix Foundation.
- * * ================================================================================
- * * 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.
- * *
- * * SPDX-License-Identifier: Apache-2.0
- * * ============LICENSE_END=========================================================
- *
- */
-
-package org.openecomp.core.impl;
-
-import org.apache.commons.io.IOUtils;
-import org.junit.Test;
-import org.onap.sdc.tosca.datatypes.model.NodeTemplate;
-import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
-import org.openecomp.core.converter.ServiceTemplateReaderService;
-import org.openecomp.core.impl.services.ServiceTemplateReaderServiceImpl;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-public class ToscaSolConverterPnfMultipleNodeTemplatesTest {
-
- private static final String PNF_EXT_CP_1 = "pnfExtCp_1";
- private static final String PNF_EXT_CP_2 = "pnfExtCp_2";
-
- @Test
- public void testGivenDescriptorWithPnfAndTwoPnfExts_WhenConvertTopologyTemplate_ThenTwoExtCpsInOutput() throws IOException {
- // Added this as separate test as data-driven tests compare strings and as order of nodeTemplates
- // can be different in hashMap and hence test may fail
- final byte[] descriptor = getFileResource("pnfDescriptor/other/pnfDescriptor_PnfAnd2ExtCps.yaml");
- ServiceTemplateReaderService serviceTemplateReaderService = new ServiceTemplateReaderServiceImpl(descriptor);
- ServiceTemplate serviceTemplate = new ServiceTemplate();
- ToscaSolConverterPnf toscaSolConverter = new ToscaSolConverterPnf();
- toscaSolConverter.convertTopologyTemplate(serviceTemplate, serviceTemplateReaderService);
- Map<String, NodeTemplate> nodeTemplates = serviceTemplate.getTopology_template().getNode_templates();
- assertEquals(2, nodeTemplates.size());
-
- nodeTemplates.entrySet().stream()
- .map(Map.Entry::getKey)
- .forEach((key -> assertTrue(getErrorString(), hasCorrectName(key))));
- }
-
- private byte[] getFileResource(String filePath) throws IOException {
- try (InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(filePath)) {
- return IOUtils.toByteArray(inputStream);
- }
- }
-
- private boolean hasCorrectName(String name) {
- return PNF_EXT_CP_1.equals(name) || PNF_EXT_CP_2.equals(name);
- }
-
- private String getErrorString() {
- return "node template name should be either " + PNF_EXT_CP_1 + " or " + PNF_EXT_CP_2;
- }
-}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/util/TestResourcesUtil.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/util/TestResourcesUtil.java
index 34559f5386..7d89bb3eab 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/util/TestResourcesUtil.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/util/TestResourcesUtil.java
@@ -23,6 +23,7 @@ import static org.junit.Assert.fail;
import java.io.IOException;
import java.io.InputStream;
+import java.net.URL;
import org.apache.commons.io.IOUtils;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
@@ -47,7 +48,7 @@ public class TestResourcesUtil {
* @throws IOException
* When the file was not found or the input stream could not be opened
*/
- public static byte[] getFileResource(final String resourcePath) throws IOException {
+ public static byte[] getFileResourceBytes(final String resourcePath) throws IOException {
try(final InputStream inputStream = ClassLoader.class.getResourceAsStream(resourcePath)) {
if (inputStream == null) {
throw new IOException(String.format("Could not find the resource on path \"%s\"", resourcePath));
@@ -67,7 +68,7 @@ public class TestResourcesUtil {
*/
public static byte[] getResourceBytesOrFail(final String resourcePath) {
try {
- return getFileResource(resourcePath);
+ return getFileResourceBytes(resourcePath);
} catch (final IOException e) {
final String errorMsg = String.format("Could not load resource '%s'", resourcePath);
LOGGER.error(errorMsg, e);
@@ -77,4 +78,26 @@ public class TestResourcesUtil {
return null;
}
+ /**
+ * Gets the input stream of a resource file
+ *
+ * @param resourcePath The resource file path
+ * @return
+ * The resource input stream
+ */
+ public static InputStream getFileResourceAsStream(final String resourcePath) {
+ return Thread.currentThread().getContextClassLoader().getResourceAsStream(resourcePath);
+ }
+
+ /**
+ * Gets the input stream of a resource file
+ *
+ * @param resourcePath The resource file path
+ * @return
+ * The resource input stream
+ */
+ public static URL getFileUrl(final String resourcePath) {
+ return Thread.currentThread().getContextClassLoader().getResource(resourcePath);
+ }
+
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/util/YamlTestUtil.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/util/YamlTestUtil.java
new file mode 100644
index 0000000000..b095d13ed7
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/util/YamlTestUtil.java
@@ -0,0 +1,67 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.util;
+
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import org.onap.sdc.tosca.services.YamlUtil;
+
+public class YamlTestUtil {
+
+ private YamlTestUtil() {
+ }
+
+ /**
+ * Reads the description file that has the required YAML format.
+ *
+ * @param yamlFile The yaml file
+ * @return The yaml parsed to Object
+ */
+ public static Object read(final File yamlFile) throws IOException {
+ try (final InputStream fileInputStream = new FileInputStream(yamlFile)) {
+ return read(fileInputStream);
+ }
+ }
+
+ public static Object read(final String yamlFilePath) throws IOException {
+ try (final InputStream resourceInputStream = TestResourcesUtil.getFileResourceAsStream(yamlFilePath)) {
+ return read(resourceInputStream);
+ }
+ }
+
+ public static Object read(final InputStream yamlFileInputStream) {
+ return YamlUtil.read(yamlFileInputStream);
+ }
+
+ public static Object readOrFail(final String yamlFilePath) {
+ try {
+ return read(yamlFilePath);
+ } catch (final IOException ignored) {
+ fail(String.format("Could not load '%s'", yamlFilePath));
+ return null;
+ }
+ }
+
+
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/model-driven-conversion.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/model-driven-conversion.yaml
new file mode 100644
index 0000000000..4d1500169e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/model-driven-conversion.yaml
@@ -0,0 +1,69 @@
+- transformation-for: nodeTemplate #or "region: nodeTemplate"; or "object: nodeTemplate"
+ name: PnfExtCp transformation
+ description: converts any node template that has a type tosca.nodes.nfv.PnfExtCp
+ query: #or "find:"
+ #currently we only support a single attribute and value search. Can be hierarchical like "properties: layer_protocols:".
+ #must have the same structure in the original node_template declaration, otherwise the attribute will not be found.
+ type: tosca.nodes.nfv.PnfExtCp
+ conversions:
+ - query: #attribute query
+ #must have the same structure in the original node_template declaration, otherwise the attribute will not be found.
+ #the value does not matter as we are going to convert it.
+ type:
+ to-name: type #new attribute name. We could have a default strategy to copy the original name (in the query) if this entry is not provided.
+ to-value:
+ strategy: replace
+ from: tosca.nodes.nfv.PnfExtCp #could be ignored
+ to: org.openecomp.resource.cp.v2.extCP
+ - query:
+ properties:
+ layer_protocols:
+ to-name: ip_requirements
+ to-value:
+ strategy: replaceInList
+ list:
+ - from: ipv4
+ to:
+ assingment_method: dhcp
+ ip_version: 4
+ - from: ipv6
+ to:
+ assingment_method: dhcp
+ ip_version: 6
+ to-get-input: ipRequirements
+- transformation-for: getInputFunction
+ name: ipRequirements
+ description: converts IpRequirements inputs when called by a get_input TOSCA function
+ conversions:
+ - query:
+ type:
+ to-name: type
+ to-value:
+ strategy: copy
+ - query:
+ description:
+ to-name: description
+ to-value:
+ strategy: copy
+ - query:
+ entry_schema:
+ type:
+ to-name: type
+ to-value:
+ strategy: replace
+ from: string
+ to: org.openecomp.datatypes.network.IpRequirements
+ - query:
+ default:
+ to-name: default
+ to-value:
+ strategy: replaceInList
+ list:
+ - from: ipv4
+ to:
+ assingment_method: dhcp
+ ip_version: 4
+ - from: ipv6
+ to:
+ assingment_method: dhcp
+ ip_version: 6 \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/pnfDescriptor/in/pnfDescriptor_withLayerProtocolsAndDuplicatedGetInput.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/pnfDescriptor/in/pnfDescriptor_withLayerProtocolsAndDuplicatedGetInput.yaml
index 8549da09b2..8867cd46f8 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/pnfDescriptor/in/pnfDescriptor_withLayerProtocolsAndDuplicatedGetInput.yaml
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/pnfDescriptor/in/pnfDescriptor_withLayerProtocolsAndDuplicatedGetInput.yaml
@@ -42,4 +42,4 @@ topology_template:
role: leaf
description: External connection point to access Acme myPnf
requirements:
- - dependency: myPnf
+ - dependency: myPnf \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/conversionDefinition/conversionDefinitionWithReplaceStrategy.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/conversionDefinition/conversionDefinitionWithReplaceStrategy.yaml
new file mode 100644
index 0000000000..cc365b7a71
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/conversionDefinition/conversionDefinitionWithReplaceStrategy.yaml
@@ -0,0 +1,7 @@
+query:
+ type:
+to-name: type
+to-value:
+ strategy: replace
+ from: tosca.nodes.nfv.PnfExtCp
+ to: org.openecomp.resource.cp.v2.extCP \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/nodeTemplate/nodeTemplate.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/nodeTemplate/nodeTemplate.yaml
new file mode 100644
index 0000000000..fd4bb5a7b8
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/nodeTemplate/nodeTemplate.yaml
@@ -0,0 +1,7 @@
+type: org.openecomp.resource.cp.v2.extCP
+properties:
+ ip_requirements:
+ - assingment_method: dhcp
+ ip_version: 4
+ - assingment_method: dhcp
+ ip_version: 6 \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/convertTwoAttributesSameLevel.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/convertTwoAttributesSameLevel.yaml
new file mode 100644
index 0000000000..8ec436ed9f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/convertTwoAttributesSameLevel.yaml
@@ -0,0 +1,11 @@
+topology_template:
+ node_templates:
+ pnfExtCp_1:
+ type: org.openecomp.resource.cp.v2.extCP
+ properties:
+ ip_requirements:
+ - assingment_method: dhcp
+ ip_version: 4
+ - assingment_method: dhcp
+ ip_version: 6
+ description_converted: External connection point to access this pnf \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/copyListAttribute.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/copyListAttribute.yaml
new file mode 100644
index 0000000000..55c5f52851
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/copyListAttribute.yaml
@@ -0,0 +1,8 @@
+topology_template:
+ node_templates:
+ pnfExtCp_1:
+ properties:
+ layer_protocols_copy:
+ - ipv4
+ - ipv6
+ - otherProtocol \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/copyObjectAttribute.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/copyObjectAttribute.yaml
new file mode 100644
index 0000000000..fe832edc14
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/copyObjectAttribute.yaml
@@ -0,0 +1,6 @@
+topology_template:
+ node_templates:
+ pnfExtCp_1:
+ properties:
+ anObjectAttribute_copy:
+ anyAttribute: anyAttributeValue \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/copyScalarAttribute.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/copyScalarAttribute.yaml
new file mode 100644
index 0000000000..e2684d4c0a
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/copyScalarAttribute.yaml
@@ -0,0 +1,5 @@
+topology_template:
+ node_templates:
+ pnfExtCp_1:
+ properties:
+ trunk_mode_copy: false \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/defaultOutput.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/defaultOutput.yaml
new file mode 100644
index 0000000000..d47ce66ace
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/defaultOutput.yaml
@@ -0,0 +1,2 @@
+topology_template:
+ node_templates: {} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/invalidAndValidAttributeQuery.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/invalidAndValidAttributeQuery.yaml
new file mode 100644
index 0000000000..90164839a4
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/invalidAndValidAttributeQuery.yaml
@@ -0,0 +1,4 @@
+topology_template:
+ node_templates:
+ pnfExtCp_1:
+ type: tosca.nodes.nfv.PnfExtCp \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/replaceInListAttribute.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/replaceInListAttribute.yaml
new file mode 100644
index 0000000000..6086d5e14d
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/replaceInListAttribute.yaml
@@ -0,0 +1,9 @@
+topology_template:
+ node_templates:
+ pnfExtCp_1:
+ properties:
+ ip_requirements:
+ - assingment_method: dhcp
+ ip_version: 4
+ - assingment_method: dhcp
+ ip_version: 6 \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/replaceInListAttributeWithNonExistentAndNonExistentFromValues.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/replaceInListAttributeWithNonExistentAndNonExistentFromValues.yaml
new file mode 100644
index 0000000000..8dfc98149a
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/replaceInListAttributeWithNonExistentAndNonExistentFromValues.yaml
@@ -0,0 +1,8 @@
+topology_template:
+ node_templates:
+ pnfExtCp_1:
+ properties:
+ ip_requirements:
+ - assingment_method: dhcp
+ ip_version: 4
+ - anyStringValue \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/replaceScalarAttributeToList.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/replaceScalarAttributeToList.yaml
new file mode 100644
index 0000000000..35139472c3
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/replaceScalarAttributeToList.yaml
@@ -0,0 +1,8 @@
+topology_template:
+ node_templates:
+ pnfExtCp_1:
+ properties:
+ trunk_mode_replaced:
+ - my
+ - replaced
+ - list \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/replaceScalarAttributeToObject.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/replaceScalarAttributeToObject.yaml
new file mode 100644
index 0000000000..0e82ea33e3
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/replaceScalarAttributeToObject.yaml
@@ -0,0 +1,6 @@
+topology_template:
+ node_templates:
+ pnfExtCp_1:
+ properties:
+ trunk_mode_replaced:
+ myObjectReplaced: myObjectReplacedValue \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/replaceScalarAttributeToScalar.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/replaceScalarAttributeToScalar.yaml
new file mode 100644
index 0000000000..03492963ac
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/expectedOutput/replaceScalarAttributeToScalar.yaml
@@ -0,0 +1,5 @@
+topology_template:
+ node_templates:
+ pnfExtCp_1:
+ properties:
+ trunk_mode_replaced: myReplacedValue \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/pnfDescriptor/other/pnfDescriptor_PnfAnd2ExtCps.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/pnfAndExtCpWithInput.yaml
index b37334496c..1e11d3833b 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/pnfDescriptor/other/pnfDescriptor_PnfAnd2ExtCps.yaml
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/pnfAndExtCpWithInput.yaml
@@ -35,10 +35,5 @@ topology_template:
layer_protocols: [ ipv4, ipv6, otherProtocol ]
role: leaf
description: External connection point to access this pnf
- pnfExtCp_2:
- type: tosca.nodes.nfv.PnfExtCp
- properties:
- trunk_mode: false
- layer_protocols: {get_input: layer_protocols}
- role: {get_input: role}
- description: External connection point to access this pnf \ No newline at end of file
+ anObjectAttribute:
+ anyAttribute: anyAttributeValue \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/attributeQueryWithMoreThanOneAttribute.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/attributeQueryWithMoreThanOneAttribute.yaml
new file mode 100644
index 0000000000..fda5646d63
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/attributeQueryWithMoreThanOneAttribute.yaml
@@ -0,0 +1,13 @@
+- transformation-for: nodeTemplate
+ query:
+ type: tosca.nodes.nfv.PnfExtCp
+ conversions:
+ - query: #more than one attribute is not allowed here
+ type: tosca.nodes.nfv.PnfExtCp
+ properties:
+ trunk_mode: false
+ to-name: type
+ to-value:
+ strategy: replace
+ from: tosca.nodes.nfv.PnfExtCp
+ to: org.openecomp.resource.cp.v2.extCP \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/convertTwoAttributesSameLevel.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/convertTwoAttributesSameLevel.yaml
new file mode 100644
index 0000000000..421fef587b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/convertTwoAttributesSameLevel.yaml
@@ -0,0 +1,32 @@
+- transformation-for: nodeTemplate
+ query:
+ type: tosca.nodes.nfv.PnfExtCp
+ conversions:
+ - query:
+ type:
+ to-name: type
+ to-value:
+ strategy: replace
+ from: tosca.nodes.nfv.PnfExtCp
+ to: org.openecomp.resource.cp.v2.extCP
+ - query:
+ properties:
+ layer_protocols:
+ to-name: ip_requirements
+ to-value:
+ strategy: replaceInList
+ list:
+ - from: ipv4
+ to:
+ assingment_method: dhcp
+ ip_version: 4
+ - from: ipv6
+ to:
+ assingment_method: dhcp
+ ip_version: 6
+ - query:
+ properties:
+ description:
+ to-name: description_converted
+ to-value:
+ strategy: copy \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/copyListAttribute.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/copyListAttribute.yaml
new file mode 100644
index 0000000000..7e6e475c1c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/copyListAttribute.yaml
@@ -0,0 +1,17 @@
+- transformation-for: nodeTemplate
+ query:
+ type: tosca.nodes.nfv.PnfExtCp
+ conversions:
+ - query: #attribute query: this attribute does not exists
+ type1:
+ to-name: type
+ to-value:
+ strategy: replace
+ from: tosca.nodes.nfv.PnfExtCp
+ to: org.openecomp.resource.cp.v2.extCP
+ - query: #attribute query: this attribute exists
+ properties:
+ layer_protocols:
+ to-name: layer_protocols_copy
+ to-value:
+ strategy: copy \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/copyObjectAttribute.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/copyObjectAttribute.yaml
new file mode 100644
index 0000000000..019d5f2e7b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/copyObjectAttribute.yaml
@@ -0,0 +1,10 @@
+- transformation-for: nodeTemplate
+ query:
+ type: tosca.nodes.nfv.PnfExtCp
+ conversions:
+ - query:
+ properties:
+ anObjectAttribute:
+ to-name: anObjectAttribute_copy
+ to-value:
+ strategy: copy \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/copyScalarAttribute.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/copyScalarAttribute.yaml
new file mode 100644
index 0000000000..6b28f9603d
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/copyScalarAttribute.yaml
@@ -0,0 +1,10 @@
+- transformation-for: nodeTemplate
+ query:
+ type: tosca.nodes.nfv.PnfExtCp
+ conversions:
+ - query:
+ properties:
+ trunk_mode:
+ to-name: trunk_mode_copy
+ to-value:
+ strategy: copy \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/emptyDescriptor.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/emptyDescriptor.yaml
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/emptyDescriptor.yaml
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/invalidAndValidAttributeQuery.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/invalidAndValidAttributeQuery.yaml
new file mode 100644
index 0000000000..bdd7437892
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/invalidAndValidAttributeQuery.yaml
@@ -0,0 +1,16 @@
+- transformation-for: nodeTemplate
+ query:
+ type: tosca.nodes.nfv.PnfExtCp
+ conversions:
+ - query: #attribute query: this attribute does not exists
+ type1:
+ to-name: type
+ to-value:
+ strategy: replace
+ from: tosca.nodes.nfv.PnfExtCp
+ to: org.openecomp.resource.cp.v2.extCP
+ - query: #attribute query: this attribute exists
+ type:
+ to-name: type
+ to-value:
+ strategy: copy \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/invalidAttributeQuery.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/invalidAttributeQuery.yaml
new file mode 100644
index 0000000000..a1fe0ce95d
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/invalidAttributeQuery.yaml
@@ -0,0 +1,11 @@
+- transformation-for: nodeTemplate
+ query:
+ type: tosca.nodes.nfv.PnfExtCp
+ conversions:
+ - query: #attribute query: this attribute does not exists
+ type1:
+ to-name: type
+ to-value:
+ strategy: replace
+ from: tosca.nodes.nfv.PnfExtCp
+ to: org.openecomp.resource.cp.v2.extCP \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/invalidBlock.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/invalidBlock.yaml
new file mode 100644
index 0000000000..069096a705
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/invalidBlock.yaml
@@ -0,0 +1,4 @@
+#this block, nodeTemplate1, is invalid
+- transformation-for: nodeTemplate1
+ query:
+ type: tosca.nodes.nfv.PnfExtCp \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/invalidBlockQueries.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/invalidBlockQueries.yaml
new file mode 100644
index 0000000000..e18c69094e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/invalidBlockQueries.yaml
@@ -0,0 +1,10 @@
+- transformation-for: nodeTemplate
+ query: #this attribute value does not exists
+ type: tosca.nodes.nfv.PnfExtCp1
+- transformation-for: nodeTemplate
+ query: #this attribute does not exists
+ type1: tosca.nodes.nfv.PnfExtCp
+- transformation-for: nodeTemplate
+ query:
+ type:
+ non-existent-lvl: #this attribute does not exists \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/invalidBlockQuery.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/invalidBlockQuery.yaml
new file mode 100644
index 0000000000..6b612093a9
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/invalidBlockQuery.yaml
@@ -0,0 +1,6 @@
+- transformation-for: nodeTemplate
+ query: #this type does not exists
+ type: tosca.nodes.nfv.PnfExtCp1
+- transformation-for: nodeTemplate
+ query: #this attribute does not exists
+ type1: tosca.nodes.nfv.PnfExtCp \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/listAsAnAttributeQuery.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/listAsAnAttributeQuery.yaml
new file mode 100644
index 0000000000..f99abe7107
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/listAsAnAttributeQuery.yaml
@@ -0,0 +1,16 @@
+- transformation-for: nodeTemplate
+ query:
+ type: tosca.nodes.nfv.PnfExtCp
+ conversions:
+ - query:
+ - list
+ - as
+ - query
+ - does
+ - not
+ - work
+ to-name: type
+ to-value:
+ strategy: replace
+ from: tosca.nodes.nfv.PnfExtCp
+ to: org.openecomp.resource.cp.v2.extCP \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/noConversions.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/noConversions.yaml
new file mode 100644
index 0000000000..e11071cddc
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/noConversions.yaml
@@ -0,0 +1,7 @@
+- transformation-for: nodeTemplate
+ query:
+ type: tosca.nodes.nfv.PnfExtCp
+ conversions:
+- transformation-for: nodeTemplate
+ query:
+ type: tosca.nodes.nfv.PnfExtCp \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/pnfAndExtCpWithInput-validBlockButNoQuery.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/pnfAndExtCpWithInput-validBlockButNoQuery.yaml
new file mode 100644
index 0000000000..fc70960b6a
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/pnfAndExtCpWithInput-validBlockButNoQuery.yaml
@@ -0,0 +1 @@
+- transformation-for: nodeTemplate \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/queryNonExistentLvl.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/queryNonExistentLvl.yaml
new file mode 100644
index 0000000000..0700c17fbc
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/queryNonExistentLvl.yaml
@@ -0,0 +1,12 @@
+- transformation-for: nodeTemplate
+ query:
+ type: tosca.nodes.nfv.PnfExtCp
+ conversions:
+ - query:
+ type:
+ non-existent-lvl: #this lvl does not exists in the input file
+ to-name: type
+ to-value:
+ strategy: replace
+ from: tosca.nodes.nfv.PnfExtCp
+ to: org.openecomp.resource.cp.v2.extCP \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/replaceInListAttribute.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/replaceInListAttribute.yaml
new file mode 100644
index 0000000000..077c95c409
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/replaceInListAttribute.yaml
@@ -0,0 +1,19 @@
+- transformation-for: nodeTemplate
+ query:
+ type: tosca.nodes.nfv.PnfExtCp
+ conversions:
+ - query:
+ properties:
+ layer_protocols:
+ to-name: ip_requirements
+ to-value:
+ strategy: replaceInList
+ list:
+ - from: ipv4
+ to:
+ assingment_method: dhcp
+ ip_version: 4
+ - from: ipv6
+ to:
+ assingment_method: dhcp
+ ip_version: 6 \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/replaceInListAttributeWithNonExistentAndNonExistentFromValues.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/replaceInListAttributeWithNonExistentAndNonExistentFromValues.yaml
new file mode 100644
index 0000000000..3f835bd5e2
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/replaceInListAttributeWithNonExistentAndNonExistentFromValues.yaml
@@ -0,0 +1,25 @@
+- transformation-for: nodeTemplate
+ query:
+ type: tosca.nodes.nfv.PnfExtCp
+ conversions:
+ - query:
+ properties:
+ layer_protocols:
+ to-name: ip_requirements
+ to-value:
+ strategy: replaceInList
+ list:
+ - from: ipv4
+ to:
+ assingment_method: dhcp
+ ip_version: 4
+ - from: ipv6
+ to: anyStringValue
+ - from: ipv2
+ to:
+ assingment_method: dhcp
+ ip_version: 2
+ - from: ipv3
+ to:
+ assingment_method: dhcp
+ ip_version: 3 \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/replaceInListAttributeWithNonExistentFromValues.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/replaceInListAttributeWithNonExistentFromValues.yaml
new file mode 100644
index 0000000000..5fbf9d6e7e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/replaceInListAttributeWithNonExistentFromValues.yaml
@@ -0,0 +1,19 @@
+- transformation-for: nodeTemplate
+ query:
+ type: tosca.nodes.nfv.PnfExtCp
+ conversions:
+ - query:
+ properties:
+ layer_protocols:
+ to-name: ip_requirements
+ to-value:
+ strategy: replaceInList
+ list:
+ - from: ipv2
+ to:
+ assingment_method: dhcp
+ ip_version: 2
+ - from: ipv3
+ to:
+ assingment_method: dhcp
+ ip_version: 3 \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/replaceScalarAttributeToList.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/replaceScalarAttributeToList.yaml
new file mode 100644
index 0000000000..b4f95a9adb
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/replaceScalarAttributeToList.yaml
@@ -0,0 +1,15 @@
+- transformation-for: nodeTemplate
+ query:
+ type: tosca.nodes.nfv.PnfExtCp
+ conversions:
+ - query:
+ properties:
+ trunk_mode:
+ to-name: trunk_mode_replaced
+ to-value:
+ strategy: replace
+ from: false
+ to:
+ - my
+ - replaced
+ - list \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/replaceScalarAttributeToObject.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/replaceScalarAttributeToObject.yaml
new file mode 100644
index 0000000000..34a0344957
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/replaceScalarAttributeToObject.yaml
@@ -0,0 +1,13 @@
+- transformation-for: nodeTemplate
+ query:
+ type: tosca.nodes.nfv.PnfExtCp
+ conversions:
+ - query:
+ properties:
+ trunk_mode:
+ to-name: trunk_mode_replaced
+ to-value:
+ strategy: replace
+ from: false
+ to:
+ myObjectReplaced: myObjectReplacedValue \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/replaceScalarAttributeToScalar.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/replaceScalarAttributeToScalar.yaml
new file mode 100644
index 0000000000..6cbb08e828
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/replaceScalarAttributeToScalar.yaml
@@ -0,0 +1,12 @@
+- transformation-for: nodeTemplate
+ query:
+ type: tosca.nodes.nfv.PnfExtCp
+ conversions:
+ - query:
+ properties:
+ trunk_mode:
+ to-name: trunk_mode_replaced
+ to-value:
+ strategy: replace
+ from: false
+ to: myReplacedValue \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/stringAsAnAttributeQuery.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/stringAsAnAttributeQuery.yaml
new file mode 100644
index 0000000000..7836b97386
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfAndExtCpWithInput/transformationDescriptor/stringAsAnAttributeQuery.yaml
@@ -0,0 +1,10 @@
+- transformation-for: nodeTemplate
+ query:
+ type: tosca.nodes.nfv.PnfExtCp
+ conversions:
+ - query: anyStringHere #query for a string does not work as it is meant to find a yaml attribute
+ to-name: type
+ to-value:
+ strategy: replace
+ from: tosca.nodes.nfv.PnfExtCp
+ to: org.openecomp.resource.cp.v2.extCP \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/expectedOutput/defaultOutput.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/expectedOutput/defaultOutput.yaml
new file mode 100644
index 0000000000..d47ce66ace
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/expectedOutput/defaultOutput.yaml
@@ -0,0 +1,2 @@
+topology_template:
+ node_templates: {} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/expectedOutput/fullTransformation.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/expectedOutput/fullTransformation.yaml
new file mode 100644
index 0000000000..4f9af4d7d2
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/expectedOutput/fullTransformation.yaml
@@ -0,0 +1,36 @@
+topology_template:
+ inputs:
+ role1:
+ type: string
+ description: Role
+ default: leaf
+ layer_protocols:
+ type: list
+ description: IP protocols
+ entry_schema:
+ type: org.openecomp.datatypes.network.IpRequirements
+ default:
+ - assingment_method: dhcp
+ ip_version: 4
+ - assingment_method: dhcp
+ ip_version: 6
+ role:
+ type: string
+ description: Role
+ default: leaf
+ node_templates:
+ pnfExtCp_3:
+ properties:
+ role: {get_input: role1}
+ pnfExtCp_2:
+ properties:
+ ip_requirements: {get_input: layer_protocols}
+ role: {get_input: role}
+ pnfExtCp_1:
+ properties:
+ ip_requirements:
+ - assingment_method: dhcp
+ ip_version: 4
+ - assingment_method: dhcp
+ ip_version: 6
+ role: leaf \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/expectedOutput/inputQueryWithMoreThanOneAttribute.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/expectedOutput/inputQueryWithMoreThanOneAttribute.yaml
new file mode 100644
index 0000000000..a55692cac9
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/expectedOutput/inputQueryWithMoreThanOneAttribute.yaml
@@ -0,0 +1,21 @@
+topology_template:
+ inputs:
+ role1:
+ description: Role
+ default: leaf
+ role:
+ description: Role
+ default: leaf
+ node_templates:
+ pnfExtCp_3:
+ properties:
+ trunk_mode_copy: false
+ role: {get_input: role1}
+ pnfExtCp_2:
+ properties:
+ trunk_mode_copy: false
+ role: {get_input: role}
+ pnfExtCp_1:
+ properties:
+ trunk_mode_copy: false
+ role: leaf \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/expectedOutput/moreThanOneTransformationWithSameBlockQuery.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/expectedOutput/moreThanOneTransformationWithSameBlockQuery.yaml
new file mode 100644
index 0000000000..0ae58056eb
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/expectedOutput/moreThanOneTransformationWithSameBlockQuery.yaml
@@ -0,0 +1,11 @@
+topology_template:
+ node_templates:
+ pnfExtCp_3:
+ properties:
+ trunk_mode_copy: false
+ pnfExtCp_2:
+ properties:
+ trunk_mode_copy: false
+ pnfExtCp_1:
+ properties:
+ trunk_mode_copy: false \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/expectedOutput/nodeTemplateQueryWithMoreThanOneAttribute.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/expectedOutput/nodeTemplateQueryWithMoreThanOneAttribute.yaml
new file mode 100644
index 0000000000..4a23ac3b2e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/expectedOutput/nodeTemplateQueryWithMoreThanOneAttribute.yaml
@@ -0,0 +1,8 @@
+topology_template:
+ node_templates:
+ pnfExtCp_3:
+ type: org.openecomp.resource.cp.v2.extCP
+ pnfExtCp_2:
+ type: org.openecomp.resource.cp.v2.extCP
+ pnfExtCp_1:
+ type: org.openecomp.resource.cp.v2.extCP \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/expectedOutput/wrongGetInputTransformationName.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/expectedOutput/wrongGetInputTransformationName.yaml
new file mode 100644
index 0000000000..45e0bbb85e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/expectedOutput/wrongGetInputTransformationName.yaml
@@ -0,0 +1,14 @@
+topology_template:
+ node_templates:
+ pnfExtCp_3:
+ properties:
+ trunk_mode_copy: false
+ role: {get_input: role1}
+ pnfExtCp_2:
+ properties:
+ trunk_mode_copy: false
+ role: {get_input: role}
+ pnfExtCp_1:
+ properties:
+ trunk_mode_copy: false
+ role: leaf \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/expectedOutput/wrongTransformationBlock.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/expectedOutput/wrongTransformationBlock.yaml
new file mode 100644
index 0000000000..0ae58056eb
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/expectedOutput/wrongTransformationBlock.yaml
@@ -0,0 +1,11 @@
+topology_template:
+ node_templates:
+ pnfExtCp_3:
+ properties:
+ trunk_mode_copy: false
+ pnfExtCp_2:
+ properties:
+ trunk_mode_copy: false
+ pnfExtCp_1:
+ properties:
+ trunk_mode_copy: false \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/pnfWithGetInput.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/pnfWithGetInput.yaml
new file mode 100644
index 0000000000..1b89d15293
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/pnfWithGetInput.yaml
@@ -0,0 +1,61 @@
+tosca_definitions_version: tosca_simple_yaml_1_1
+
+description: service template of a PNF
+
+topology_template:
+ inputs:
+ role:
+ type: string
+ description: Role
+ default: leaf
+ role1:
+ type: string
+ description: Role
+ default: leaf
+ layer_protocols:
+ type: list
+ description: IP protocols
+ entry_schema:
+ type: string
+ default: [ipv4, ipv6, otherProtocol]
+ node_templates:
+ notToBeConvertedNode:
+ type: tosca.nodes.nfv.PNF
+ properties:
+ descriptor_id: b1bb0ce7-ebca-4fa7-95ed-4840d70a2233
+ function_description: an example PNF
+ provider: Mycompany
+ version: 1.0
+ descriptor_invariant_id: 1111-2222-ccaa-bbdd
+ name: ExamplePnf
+ requirements:
+ - virtual_link:
+ capability: tosca.capabilities.nfv.VirtualLinkable
+ node: pnfExtCp_1
+ pnfExtCp_1:
+ type: tosca.nodes.nfv.PnfExtCp
+ properties:
+ trunk_mode: false
+ layer_protocols: [ipv4, ipv6, otherProtocol]
+ role: leaf
+ description: External connection point to access this pnf
+ anObjectAttribute:
+ anyAttribute: anyAttributeValue
+ pnfExtCp_2:
+ type: tosca.nodes.nfv.PnfExtCp
+ properties:
+ trunk_mode: false
+ layer_protocols:
+ get_input: layer_protocols
+ role: {get_input: role}
+ description: External connection point to access this pnf
+ anObjectAttribute:
+ anyAttribute: anyAttributeValue
+ pnfExtCp_3:
+ type: tosca.nodes.nfv.PnfExtCp
+ properties:
+ trunk_mode: false
+ description: External connection point to access this pnf
+ anObjectAttribute:
+ anyAttribute: anyAttributeValue
+ role: {get_input: role1} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/transformationDescriptor/fullTransformation.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/transformationDescriptor/fullTransformation.yaml
new file mode 100644
index 0000000000..4772bfe4f9
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/transformationDescriptor/fullTransformation.yaml
@@ -0,0 +1,84 @@
+- transformation-for: nodeTemplate
+ name: PnfExtCp transformation
+ description: converts any node template that has a type tosca.nodes.nfv.PnfExtCp
+ query:
+ type: tosca.nodes.nfv.PnfExtCp
+ conversions:
+ - query:
+ properties:
+ layer_protocols:
+ to-name: ip_requirements
+ to-value:
+ strategy: replaceInList
+ list:
+ - from: ipv4
+ to:
+ assingment_method: dhcp
+ ip_version: 4
+ - from: ipv6
+ to:
+ assingment_method: dhcp
+ ip_version: 6
+ to-get-input: ipRequirements
+ - query:
+ properties:
+ role:
+ to-name: role
+ to-value:
+ strategy: copy
+ to-get-input: stringTransformation
+- transformation-for: getInputFunction
+ name: ipRequirements
+ description: converts IpRequirements inputs when called by a get_input TOSCA function
+ conversions:
+ - query:
+ type:
+ to-name: type
+ to-value:
+ strategy: copy
+ - query:
+ description:
+ to-name: description
+ to-value:
+ strategy: copy
+ - query:
+ entry_schema:
+ type:
+ to-name: type
+ to-value:
+ strategy: replace
+ from: string
+ to: org.openecomp.datatypes.network.IpRequirements
+ - query:
+ default:
+ to-name: default
+ to-value:
+ strategy: replaceInList
+ list:
+ - from: ipv4
+ to:
+ assingment_method: dhcp
+ ip_version: 4
+ - from: ipv6
+ to:
+ assingment_method: dhcp
+ ip_version: 6
+- transformation-for: getInputFunction
+ name: stringTransformation
+ description: converts a string input
+ conversions:
+ - query:
+ type:
+ to-name: type
+ to-value:
+ strategy: copy
+ - query:
+ description:
+ to-name: description
+ to-value:
+ strategy: copy
+ - query:
+ default:
+ to-name: default
+ to-value:
+ strategy: copy \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/transformationDescriptor/inputQueryWithMoreThanOneAttribute.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/transformationDescriptor/inputQueryWithMoreThanOneAttribute.yaml
new file mode 100644
index 0000000000..1655ca4880
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/transformationDescriptor/inputQueryWithMoreThanOneAttribute.yaml
@@ -0,0 +1,39 @@
+- transformation-for: nodeTemplate
+ name: PnfExtCp transformation
+ description: converts any node template that has a type tosca.nodes.nfv.PnfExtCp
+ query:
+ type: tosca.nodes.nfv.PnfExtCp
+ conversions:
+ - query:
+ properties:
+ trunk_mode:
+ to-name: trunk_mode_copy
+ to-value:
+ strategy: copy
+ - query:
+ properties:
+ role:
+ to-name: role
+ to-value:
+ strategy: copy
+ to-get-input: stringTransformation
+- transformation-for: getInputFunction
+ name: stringTransformation
+ description: converts a string input
+ conversions:
+ - query:
+ type:
+ invalid-another-attribute: #cannot have two attributes in the attribute query
+ to-name: type
+ to-value:
+ strategy: copy
+ - query:
+ description:
+ to-name: description
+ to-value:
+ strategy: copy
+ - query:
+ default:
+ to-name: default
+ to-value:
+ strategy: copy \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/transformationDescriptor/moreThanOneTransformationWithSameBlockQuery.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/transformationDescriptor/moreThanOneTransformationWithSameBlockQuery.yaml
new file mode 100644
index 0000000000..aa05627da2
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/transformationDescriptor/moreThanOneTransformationWithSameBlockQuery.yaml
@@ -0,0 +1,37 @@
+#just one of the transformations will be considered
+- transformation-for: nodeTemplate #same time
+ name: PnfExtCp transformation
+ description: converts any node template that has a type tosca.nodes.nfv.PnfExtCp
+ query: #same block query
+ type: tosca.nodes.nfv.PnfExtCp
+ conversions:
+ - query:
+ properties:
+ trunk_mode:
+ to-name: trunk_mode_copy
+ to-value:
+ strategy: copy
+- transformation-for: nodeTemplate #same time
+ name: PnfExtCp transformation
+ description: converts any node template that has a type tosca.nodes.nfv.PnfExtCp
+ query: #same block query
+ type: tosca.nodes.nfv.PnfExtCp
+ conversions:
+ - query:
+ properties:
+ role:
+ to-name: role
+ to-value:
+ strategy: copy
+- transformation-for: nodeTemplate #same time
+ name: PnfExtCp transformation
+ description: converts any node template that has a type tosca.nodes.nfv.PnfExtCp
+ query: #same block query
+ type: tosca.nodes.nfv.PnfExtCp
+ conversions:
+ - query:
+ properties:
+ trunk_mode:
+ to-name: trunk_mode_copy1
+ to-value:
+ strategy: copy \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/transformationDescriptor/nodeTemplateQueryWithMoreThanOneAttribute.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/transformationDescriptor/nodeTemplateQueryWithMoreThanOneAttribute.yaml
new file mode 100644
index 0000000000..b20f48eebd
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/transformationDescriptor/nodeTemplateQueryWithMoreThanOneAttribute.yaml
@@ -0,0 +1,14 @@
+- transformation-for: nodeTemplate
+ query:
+ type: tosca.nodes.nfv.PnfExtCp
+ properties:
+ anObjectAttribute:
+ anyAttribute: anyAttributeValue
+ conversions:
+ - query:
+ type:
+ to-name: type
+ to-value:
+ strategy: replace
+ from: tosca.nodes.nfv.PnfExtCp
+ to: org.openecomp.resource.cp.v2.extCP \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/transformationDescriptor/wrongGetInputTransformationName.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/transformationDescriptor/wrongGetInputTransformationName.yaml
new file mode 100644
index 0000000000..fd5133cb91
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/transformationDescriptor/wrongGetInputTransformationName.yaml
@@ -0,0 +1,39 @@
+- transformation-for: nodeTemplate
+ name: PnfExtCp transformation
+ description: converts any node template that has a type tosca.nodes.nfv.PnfExtCp
+ query:
+ type: tosca.nodes.nfv.PnfExtCp
+ conversions:
+ - query:
+ properties:
+ trunk_mode:
+ to-name: trunk_mode_copy
+ to-value:
+ strategy: copy
+ - query:
+ properties:
+ role:
+ to-name: role
+ to-value:
+ strategy: copy
+ to-get-input: stringTransformation1
+- transformation-for: getInputFunction
+ name: stringTransformation
+ description: converts a string input
+ conversions:
+ - query:
+ type:
+ invalid-another-attribute: #cannot have two attributes in the attribute query
+ to-name: type
+ to-value:
+ strategy: copy
+ - query:
+ description:
+ to-name: description
+ to-value:
+ strategy: copy
+ - query:
+ default:
+ to-name: default
+ to-value:
+ strategy: copy \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/transformationDescriptor/wrongTransformationBlock.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/transformationDescriptor/wrongTransformationBlock.yaml
new file mode 100644
index 0000000000..0559b02642
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/pnfParseEngine/pnfWithGetInput/transformationDescriptor/wrongTransformationBlock.yaml
@@ -0,0 +1,24 @@
+- transformation-for: nodeTemplate
+ name: PnfExtCp transformation
+ description: converts any node template that has a type tosca.nodes.nfv.PnfExtCp
+ query:
+ type: tosca.nodes.nfv.PnfExtCp
+ conversions:
+ - query:
+ properties:
+ trunk_mode:
+ to-name: trunk_mode_copy
+ to-value:
+ strategy: copy
+- transformation-for: wrongBlock
+ name: PnfExtCp transformation
+ description: converts any node template that has a type tosca.nodes.nfv.PnfExtCp
+ query:
+ type: tosca.nodes.nfv.PnfExtCp
+ conversions:
+ - query:
+ properties:
+ role:
+ to-name: role
+ to-value:
+ strategy: copy \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/strategy/replaceStrategy.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/strategy/replaceStrategy.yaml
new file mode 100644
index 0000000000..f60655c5ca
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/strategy/replaceStrategy.yaml
@@ -0,0 +1,3 @@
+strategy: replace
+from: tosca.nodes.nfv.PnfExtCp
+to: org.openecomp.resource.cp.v2.extCP \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/strategy/strategyMissingStrategyAttribute.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/strategy/strategyMissingStrategyAttribute.yaml
new file mode 100644
index 0000000000..40200cecb0
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/transformation/strategy/strategyMissingStrategyAttribute.yaml
@@ -0,0 +1,2 @@
+from: tosca.nodes.nfv.PnfExtCp
+to: org.openecomp.resource.cp.v2.extCP \ No newline at end of file