f9b982e658723787642d6c2f386900f2fa56baf5
[sdc.git] /
1 package org.openecomp.core.converter.impl;
2
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;
13
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;
23
24 import java.net.URL;
25 import java.util.Map;
26 import java.util.Set;
27 public class ToscaConvertorDefinitionsTest {
28
29
30     @Ignore
31     @Test
32     public void loadCsar() throws Exception {
33         URL resource = ToscaConvertorDefinitionsTest.class.getResource("/csar/vCSCF.csar");
34         byte[] bytes = IOUtils.toByteArray(resource);
35         assertNotNull(bytes);
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);
42
43         assertNotNull(serviceTemplate);
44         assertTrue(serviceTemplate instanceof GlobalSubstitutionServiceTemplate);
45
46         assertNotNull(serviceTemplate.getMetadata());
47         assertFalse(serviceTemplate.getMetadata().isEmpty());
48         assertTrue(serviceTemplate.getMetadata().containsKey(TEMPLATE_NAME_PROPERTY));
49
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));
55
56         assertEquals(DEFININTION_VERSION, serviceTemplate.getTosca_definitions_version());
57
58
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"));
63     }
64
65
66 }