Migrate TestNG to Junit5
[sdc/sdc-tosca.git] / sdc-tosca / src / test / java / org / onap / sdc / impl / ToscaParserSubsMappingsTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * sdc-tosca
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.onap.sdc.impl;
22
23 import static org.junit.jupiter.api.Assertions.assertEquals;
24 import static org.junit.jupiter.api.Assertions.assertNull;
25
26 import java.util.ArrayList;
27 import java.util.Arrays;
28 import java.util.List;
29 import org.junit.jupiter.api.Test;
30 import org.junit.jupiter.api.extension.ExtendWith;
31 import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
32 import org.onap.sdc.toscaparser.api.NodeTemplate;
33 import org.onap.sdc.toscaparser.api.RequirementAssignment;
34
35 @ExtendWith({SdcToscaParserBasicTest.class})
36  class ToscaParserSubsMappingsTest extends SdcToscaParserBasicTest {
37
38     //region getServiceSubstitutionMappingsTypeName
39     @Test
40     public void testGetServiceSubstitutionMappingsTypeName() {
41         String serviceSubstitutionMappingsTypeName = fdntCsarHelper.getServiceSubstitutionMappingsTypeName();
42         assertEquals("org.openecomp.service.ServiceFdnt", serviceSubstitutionMappingsTypeName);
43     }
44
45     @Test
46     public void testServiceSubstitutionMappingsTypeName() {
47         String substitutionMappingsTypeName = rainyCsarHelperMultiVfs.getServiceSubstitutionMappingsTypeName();
48         assertNull(substitutionMappingsTypeName);
49     }
50     //endregion
51
52     //Added by QA - Check for Capabilities in VF level (Capabilities QTY and Names).
53     //@Test // - BUG 283369
54 //              public void testCapabilitiesofVFNames_QTY() throws SdcToscaParserException {
55 //                      List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
56 //                      String sName = serviceVfList.get(0).getName();
57 //                      assertEquals(sName,fdntCsarHelper_Data.get("FDNT").get("VF Name").get(0));
58 //                      Map<String, CapabilityAssignment> lCapabilitys = serviceVfList.get(0).getCapabilities().getAll();
59 //                      List<String> CPkeys = new ArrayList<>(lCapabilitys.keySet());
60 //                      List<String> CapabilitiesNames = new ArrayList<String>(CPkeys.size());
61 //
62 //                      for (int i = 0; i < CPkeys.size(); i++) {
63 //
64 //                              CapabilityAssignment cCp = lCapabilitys.get(CPkeys.get(i));
65 //
66 //                              CapabilitiesNames.add(cCp.getName());
67 //
68 //                              assertEquals(CPkeys.get(i).toLowerCase(), CapabilitiesNames.get(i).toLowerCase());// Compare keys to values, Should it be checked as Case sensitive????
69 //
70 //                              //System.out.println(String.format("Value of key: %s , Value of capability: %s", keys.get(i).toLowerCase(), Capabilities.get(i).toLowerCase()));
71 //                              //System.out.println(String.format("Value of key: %s , Value of capability: %s", ActualValues.get(i).toLowerCase(), Capabilities.get(i).toLowerCase()));
72 //                              //System.out.println(String.format("*******%d*******",i));
73 //                      }
74 //
75 //                      for (int i = 0; i < CPkeys.size(); i++) {
76 //                              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.
77 //                      }
78 //
79 //                      assertEquals(fdntCsarHelper_Data.get("FDNT").get("capabilities").size(), CapabilitiesNames.size()); // Compare capabilities qty expected vs actual
80 //              }
81
82     //Added by QA - Check for Capabilities in VF level (Capabilities Types and Properties).
83     //@Test
84 //              public void testCapabilitiesofVFTypes_Properties() throws SdcToscaParserException {
85 //                      List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
86 //                      String sName = serviceVfList.get(0).getName();
87 //                      assertEquals(sName,fdntCsarHelper_Data.get("FDNT").get("VF Name").get(0));
88 //                      Map<String, CapabilityAssignment> lCapabilitys = serviceVfList.get(0).getCapabilities().getAll();
89 //
90 //                      List<String> CPkeys = new ArrayList<>(lCapabilitys.keySet());
91 //                      List<String> CPPropkeys = new ArrayList<>(lCapabilitys.keySet());
92 //                      List<String> CapabilitiesTypes = new ArrayList<String>(CPkeys.size());
93 //
94 //                      //int iKeysSize = keys.size(); //for debug
95 //
96 //                      for (int i = 0; i < CPkeys.size(); i++) {
97 //
98 //                              CapabilityAssignment cCp = lCapabilitys.get(CPkeys.get(i));
99 //                              CapabilityTypeDef CpDef = cCp.getDefinition();
100 //                              CapabilitiesTypes.add(CpDef.getEntityType());
101 //
102 //                              //LinkedHashMap<String,Object> lProperties = cCp.getDefinition().getProperties();
103 //                              LinkedHashMap<String, Property> lPropertiesR = cCp.getProperties();
104 //
105 //                              List<String> CP_Propkeys = new ArrayList<>(lPropertiesR.keySet());
106 //
107 //                              for (int j = 0; j < CP_Propkeys.size(); j++) {
108 //
109 //                              Property p = lPropertiesR.get(CP_Propkeys.get(j));
110 //
111 //                              if(p !=  null){
112 //                                      String sPType = p.getEntityType();
113 //                                      Boolean bPRequired = p.isRequired();
114 //
115 //                                      System.out.println(sPType + "  " + bPRequired);
116 //
117 //                                      }
118 //
119 //                      }
120 //
121 //                      }
122 //
123 //                      for (int i = 0; i < CPkeys.size(); i++) {
124 //
125 //                      }
126 //
127 //                      assertEquals(fdntCsarHelper_Data.get("FDNT").get("capabilitiesTypes").size(), CapabilitiesTypes.size()); // Compare capabilities qty expected vs actual
128 //              }
129
130     //@Test // - BUG 283387
131     public void testRequirmentsofVF() throws SdcToscaParserException {
132         List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
133         String sName = serviceVfList.get(0).getName();
134         assertEquals(sName, "FDNT 1");
135
136         List<String> ActualReqsValues = new ArrayList<>(Arrays.asList());
137
138         List<RequirementAssignment> lRequirements = serviceVfList.get(0).getRequirements().getAll();
139
140         assertEquals(fdntCsarHelper_Data.get("FDNT").get("requirements").size(), lRequirements.size()); //
141
142         // Continue from here after bug is fixed ! ! ! !  - Test the Requirements values
143     }
144
145 }