diff options
author | Avi Gaffa <avi.gaffa@amdocs.com> | 2017-09-12 11:00:02 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2017-09-12 11:00:02 +0000 |
commit | e6fc26ab18d1409c490c859398fc5fca71d0518b (patch) | |
tree | 30441a6b43e2507e8cdef3589a5defc74083263f /openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConvertorDefinitionsTest.java | |
parent | a0858efdab2f9bdc5d46be5655cdbb76708f4763 (diff) | |
parent | c8a540b3c234449163f6fb1899807bba951113b4 (diff) |
Merge "Create new VSP, onboard from TOSCA file - UI"
Diffstat (limited to 'openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConvertorDefinitionsTest.java')
-rw-r--r-- | openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConvertorDefinitionsTest.java | 62 |
1 files changed, 62 insertions, 0 deletions
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/converter/impl/ToscaConvertorDefinitionsTest.java new file mode 100644 index 0000000000..9f7071e9e7 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConvertorDefinitionsTest.java @@ -0,0 +1,62 @@ +package org.openecomp.core.converter.impl; + +import org.apache.commons.io.IOUtils; +import org.junit.Test; +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; +import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate; + +import java.net.URL; +import java.util.Map; +import java.util.Set; + +import static org.openecomp.sdc.common.utils.CommonUtil.*; +import static org.junit.Assert.*; +import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.*; +public class ToscaConvertorDefinitionsTest { + + + @Test + public void loadCsar() throws Exception { + URL resource = ToscaConvertorDefinitionsTest.class.getResource("/csar/vCSCF.csar"); + byte[] bytes = IOUtils.toByteArray(resource); + assertNotNull(bytes); + FileContentHandler contentMap = validateAndUploadFileContent(OnboardingTypesEnum.CSAR, bytes); + ToscaConverterImpl toscaConverter = new ToscaConverterImpl(); + ToscaServiceModel convert = toscaConverter.convert(contentMap); + Map<String, ServiceTemplate> serviceTemplates = convert.getServiceTemplates(); + assertTrue(serviceTemplates.containsKey(GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME)); + ServiceTemplate serviceTemplate = serviceTemplates.get(GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME); + + assertNotNull(serviceTemplate); + assertTrue(serviceTemplate instanceof GlobalSubstitutionServiceTemplate); + + assertNotNull(serviceTemplate.getMetadata()); + assertFalse(serviceTemplate.getMetadata().isEmpty()); + assertTrue(serviceTemplate.getMetadata().containsKey(TEMPLATE_NAME_PROPERTY)); + + assertNotNull(serviceTemplate.getImports()); + assertFalse(serviceTemplate.getImports().isEmpty()); + assertEquals(1 ,serviceTemplate.getImports().size()); + assertTrue(serviceTemplate.getImports().get(0).containsKey(HEAT_INDEX)); + + assertEquals(DEFININTION_VERSION, serviceTemplate.getTosca_definitions_version()); + + + assertNotNull(serviceTemplate.getNode_types()); + assertEquals(7, serviceTemplate.getNode_types().size()); + Set<String> keys = serviceTemplate.getNode_types().keySet(); + assertTrue(keys.contains("tosca.nodes.nfv.ext.zte.VDU")); + assertTrue(keys.contains("tosca.nodes.nfv.ext.zte.CP")); + assertTrue(keys.contains("tosca.nodes.nfv.ext.zte.VNF.vCSCF")); + assertTrue(keys.contains("tosca.nodes.nfv.ext.ImageFile")); + assertTrue(keys.contains("tosca.nodes.nfv.ext.LocalStorage")); + assertTrue(keys.contains("tosca.nodes.nfv.ext.zte.VNF")); + assertTrue(keys.contains("tosca.nodes.nfv.ext.zte.VL")); + } + + +} |