2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.sdc.impl;
23 import static org.testng.Assert.assertEquals;
24 import static org.testng.Assert.assertNull;
28 import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
29 import org.onap.sdc.toscaparser.api.CapabilityAssignment;
30 import org.onap.sdc.toscaparser.api.NodeTemplate;
31 import org.onap.sdc.toscaparser.api.RequirementAssignment;
32 import org.onap.sdc.toscaparser.api.elements.CapabilityTypeDef;
33 //import org.testng.ReporterConfig.Property;
34 import org.testng.annotations.Test;
35 import org.onap.sdc.toscaparser.api.Property;
37 //import static org.junit.Assert.assertEquals;
38 //import static org.junit.Assert.assertNull;
40 public class ToscaParserSubsMappingsTest extends SdcToscaParserBasicTest {
42 //region getServiceSubstitutionMappingsTypeName
44 public void testGetServiceSubstitutionMappingsTypeName() {
45 String serviceSubstitutionMappingsTypeName = fdntCsarHelper.getServiceSubstitutionMappingsTypeName();
46 assertEquals("org.openecomp.service.ServiceFdnt", serviceSubstitutionMappingsTypeName);
50 public void testServiceSubstitutionMappingsTypeName() {
51 String substitutionMappingsTypeName = rainyCsarHelperMultiVfs.getServiceSubstitutionMappingsTypeName();
52 assertNull(substitutionMappingsTypeName);
56 //Added by QA - Check for Capabilities in VF level (Capabilities QTY and Names).
57 //@Test // - BUG 283369
58 // public void testCapabilitiesofVFNames_QTY() throws SdcToscaParserException {
59 // List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
60 // String sName = serviceVfList.get(0).getName();
61 // assertEquals(sName,fdntCsarHelper_Data.get("FDNT").get("VF Name").get(0));
62 // Map<String, CapabilityAssignment> lCapabilitys = serviceVfList.get(0).getCapabilities().getAll();
63 // List<String> CPkeys = new ArrayList<>(lCapabilitys.keySet());
64 // List<String> CapabilitiesNames = new ArrayList<String>(CPkeys.size());
66 // for (int i = 0; i < CPkeys.size(); i++) {
68 // CapabilityAssignment cCp = lCapabilitys.get(CPkeys.get(i));
70 // CapabilitiesNames.add(cCp.getName());
72 // assertEquals(CPkeys.get(i).toLowerCase(), CapabilitiesNames.get(i).toLowerCase());// Compare keys to values, Should it be checked as Case sensitive????
74 // //System.out.println(String.format("Value of key: %s , Value of capability: %s", keys.get(i).toLowerCase(), Capabilities.get(i).toLowerCase()));
75 // //System.out.println(String.format("Value of key: %s , Value of capability: %s", ActualValues.get(i).toLowerCase(), Capabilities.get(i).toLowerCase()));
76 // //System.out.println(String.format("*******%d*******",i));
79 // for (int i = 0; i < CPkeys.size(); i++) {
80 // assertEquals(true, CapabilitiesNames.stream().map(String::toLowerCase).collect(Collectors.toList()).contains(fdntCsarHelper_Data.get("FDNT").get("capabilities").get(i).toLowerCase())); // Compare capabilities predefined list to actual one.
83 // assertEquals(fdntCsarHelper_Data.get("FDNT").get("capabilities").size(), CapabilitiesNames.size()); // Compare capabilities qty expected vs actual
86 //Added by QA - Check for Capabilities in VF level (Capabilities Types and Properties).
88 // public void testCapabilitiesofVFTypes_Properties() throws SdcToscaParserException {
89 // List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
90 // String sName = serviceVfList.get(0).getName();
91 // assertEquals(sName,fdntCsarHelper_Data.get("FDNT").get("VF Name").get(0));
92 // Map<String, CapabilityAssignment> lCapabilitys = serviceVfList.get(0).getCapabilities().getAll();
94 // List<String> CPkeys = new ArrayList<>(lCapabilitys.keySet());
95 // List<String> CPPropkeys = new ArrayList<>(lCapabilitys.keySet());
96 // List<String> CapabilitiesTypes = new ArrayList<String>(CPkeys.size());
98 // //int iKeysSize = keys.size(); //for debug
100 // for (int i = 0; i < CPkeys.size(); i++) {
102 // CapabilityAssignment cCp = lCapabilitys.get(CPkeys.get(i));
103 // CapabilityTypeDef CpDef = cCp.getDefinition();
104 // CapabilitiesTypes.add(CpDef.getEntityType());
106 // //LinkedHashMap<String,Object> lProperties = cCp.getDefinition().getProperties();
107 // LinkedHashMap<String, Property> lPropertiesR = cCp.getProperties();
109 // List<String> CP_Propkeys = new ArrayList<>(lPropertiesR.keySet());
111 // for (int j = 0; j < CP_Propkeys.size(); j++) {
113 // Property p = lPropertiesR.get(CP_Propkeys.get(j));
116 // String sPType = p.getEntityType();
117 // Boolean bPRequired = p.isRequired();
119 // System.out.println(sPType + " " + bPRequired);
127 // for (int i = 0; i < CPkeys.size(); i++) {
131 // assertEquals(fdntCsarHelper_Data.get("FDNT").get("capabilitiesTypes").size(), CapabilitiesTypes.size()); // Compare capabilities qty expected vs actual
134 //@Test // - BUG 283387
135 public void testRequirmentsofVF() throws SdcToscaParserException {
136 List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
137 String sName = serviceVfList.get(0).getName();
138 assertEquals(sName,"FDNT 1");
140 List<String> ActualReqsValues = new ArrayList<>(Arrays.asList( ));
142 List<RequirementAssignment> lRequirements = serviceVfList.get(0).getRequirements().getAll();
144 assertEquals(fdntCsarHelper_Data.get("FDNT").get("requirements").size(),lRequirements.size()); //
146 // Continue from here after bug is fixed ! ! ! ! - Test the Requirements values