c9ad33247b6473a74ad5dd637bdef58a3ab7c81d
[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.testng.Assert.assertEquals;
24 import static org.testng.Assert.assertNull;
25
26 import java.util.*;
27
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;
36
37 //import static org.junit.Assert.assertEquals;
38 //import static org.junit.Assert.assertNull;
39
40 public class ToscaParserSubsMappingsTest extends SdcToscaParserBasicTest {
41
42     //region getServiceSubstitutionMappingsTypeName
43     @Test
44     public void testGetServiceSubstitutionMappingsTypeName() {
45         String serviceSubstitutionMappingsTypeName = fdntCsarHelper.getServiceSubstitutionMappingsTypeName();
46         assertEquals("org.openecomp.service.ServiceFdnt", serviceSubstitutionMappingsTypeName);
47     }
48
49     @Test
50     public void testServiceSubstitutionMappingsTypeName() {
51         String substitutionMappingsTypeName = rainyCsarHelperMultiVfs.getServiceSubstitutionMappingsTypeName();
52         assertNull(substitutionMappingsTypeName);
53     }
54     //endregion
55     
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());
65 //
66 //                      for (int i = 0; i < CPkeys.size(); i++) {
67 //
68 //                              CapabilityAssignment cCp = lCapabilitys.get(CPkeys.get(i));
69 //
70 //                              CapabilitiesNames.add(cCp.getName());
71 //
72 //                              assertEquals(CPkeys.get(i).toLowerCase(), CapabilitiesNames.get(i).toLowerCase());// Compare keys to values, Should it be checked as Case sensitive????
73 //
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));
77 //                      }
78 //
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.
81 //                      }
82 //
83 //                      assertEquals(fdntCsarHelper_Data.get("FDNT").get("capabilities").size(), CapabilitiesNames.size()); // Compare capabilities qty expected vs actual
84 //              }
85                 
86         //Added by QA - Check for Capabilities in VF level (Capabilities Types and Properties).
87                 //@Test 
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();
93 //
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());
97 //
98 //                      //int iKeysSize = keys.size(); //for debug
99 //
100 //                      for (int i = 0; i < CPkeys.size(); i++) {
101 //
102 //                              CapabilityAssignment cCp = lCapabilitys.get(CPkeys.get(i));
103 //                              CapabilityTypeDef CpDef = cCp.getDefinition();
104 //                              CapabilitiesTypes.add(CpDef.getEntityType());
105 //
106 //                              //LinkedHashMap<String,Object> lProperties = cCp.getDefinition().getProperties();
107 //                              LinkedHashMap<String, Property> lPropertiesR = cCp.getProperties();
108 //
109 //                              List<String> CP_Propkeys = new ArrayList<>(lPropertiesR.keySet());
110 //
111 //                              for (int j = 0; j < CP_Propkeys.size(); j++) {
112 //
113 //                              Property p = lPropertiesR.get(CP_Propkeys.get(j));
114 //
115 //                              if(p !=  null){
116 //                                      String sPType = p.getEntityType();
117 //                                      Boolean bPRequired = p.isRequired();
118 //
119 //                                      System.out.println(sPType + "  " + bPRequired);
120 //
121 //                                      }
122 //
123 //                      }
124 //
125 //                      }
126 //
127 //                      for (int i = 0; i < CPkeys.size(); i++) {
128 //
129 //                      }
130 //
131 //                      assertEquals(fdntCsarHelper_Data.get("FDNT").get("capabilitiesTypes").size(), CapabilitiesTypes.size()); // Compare capabilities qty expected vs actual
132 //              }
133                 
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");
139                         
140                         List<String> ActualReqsValues = new ArrayList<>(Arrays.asList( ));
141                         
142                         List<RequirementAssignment> lRequirements = serviceVfList.get(0).getRequirements().getAll();
143                         
144                         assertEquals(fdntCsarHelper_Data.get("FDNT").get("requirements").size(),lRequirements.size()); //
145                         
146                         // Continue from here after bug is fixed ! ! ! !  - Test the Requirements values
147                 }
148
149 }