1 package org.openecomp.core.converter.impl;
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertFalse;
5 import static org.junit.Assert.assertNotNull;
6 import static org.junit.Assert.assertTrue;
7 import static org.openecomp.core.converter.datatypes.Constants.ONAP_INDEX;
8 import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.DEFININTION_VERSION;
9 import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME;
10 import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.HEAT_INDEX;
11 import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.TEMPLATE_NAME_PROPERTY;
12 import static org.openecomp.sdc.common.utils.CommonUtil.validateAndUploadFileContent;
14 import org.apache.commons.io.IOUtils;
15 import org.junit.Ignore;
16 import org.junit.Test;
17 import org.openecomp.core.impl.GlobalSubstitutionServiceTemplate;
18 import org.openecomp.core.impl.ToscaConverterImpl;
19 import org.openecomp.core.utilities.file.FileContentHandler;
20 import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
21 import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
22 import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
27 public class ToscaConvertorDefinitionsTest {
32 public void loadCsar() throws Exception {
33 URL resource = ToscaConvertorDefinitionsTest.class.getResource("/csar/vCSCF.csar");
34 byte[] bytes = IOUtils.toByteArray(resource);
36 FileContentHandler contentMap = validateAndUploadFileContent(OnboardingTypesEnum.CSAR, bytes);
37 ToscaConverterImpl toscaConverter = new ToscaConverterImpl();
38 ToscaServiceModel convert = toscaConverter.convert(contentMap);
39 Map<String, ServiceTemplate> serviceTemplates = convert.getServiceTemplates();
40 assertTrue(serviceTemplates.containsKey(GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME));
41 ServiceTemplate serviceTemplate = serviceTemplates.get(GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME);
43 assertNotNull(serviceTemplate);
44 assertTrue(serviceTemplate instanceof GlobalSubstitutionServiceTemplate);
46 assertNotNull(serviceTemplate.getMetadata());
47 assertFalse(serviceTemplate.getMetadata().isEmpty());
48 assertTrue(serviceTemplate.getMetadata().containsKey(TEMPLATE_NAME_PROPERTY));
50 assertNotNull(serviceTemplate.getImports());
51 assertFalse(serviceTemplate.getImports().isEmpty());
52 assertEquals(1 ,serviceTemplate.getImports().size());
53 assertTrue(serviceTemplate.getImports().get(0).containsKey(HEAT_INDEX));
54 assertTrue(serviceTemplate.getImports().get(0).containsKey(ONAP_INDEX));
56 assertEquals(DEFININTION_VERSION, serviceTemplate.getTosca_definitions_version());
59 assertNotNull(serviceTemplate.getNode_types());
60 assertEquals(1, serviceTemplate.getNode_types().size());
61 Set<String> keys = serviceTemplate.getNode_types().keySet();
62 assertTrue(keys.contains("tosca.nodes.nfv.ext.zte.VNF.vCSCF"));