aboutsummaryrefslogtreecommitdiffstats
path: root/sdc-tosca/src/test/java/org/onap/sdc/impl/ToscaParserSubsMappingsTest.java
blob: 83ee5bd2150545c3255612e3c7362a6aeb678b8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*-
 * ============LICENSE_START=======================================================
 * sdc-tosca
 * ================================================================================
 * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=========================================================
 */

package org.onap.sdc.impl;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
import org.onap.sdc.toscaparser.api.NodeTemplate;
import org.onap.sdc.toscaparser.api.RequirementAssignment;

@ExtendWith({SdcToscaParserBasicTest.class})
 class ToscaParserSubsMappingsTest extends SdcToscaParserBasicTest {

    //region getServiceSubstitutionMappingsTypeName
    @Test
    public void testGetServiceSubstitutionMappingsTypeName() {
        String serviceSubstitutionMappingsTypeName = fdntCsarHelper.getServiceSubstitutionMappingsTypeName();
        assertEquals("org.openecomp.service.ServiceFdnt", serviceSubstitutionMappingsTypeName);
    }

    @Test
    public void testServiceSubstitutionMappingsTypeName() {
        String substitutionMappingsTypeName = rainyCsarHelperMultiVfs.getServiceSubstitutionMappingsTypeName();
        assertNull(substitutionMappingsTypeName);
    }
    //endregion

    //Added by QA - Check for Capabilities in VF level (Capabilities QTY and Names).
    //@Test // - BUG 283369
//		public void testCapabilitiesofVFNames_QTY() throws SdcToscaParserException {
//			List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
//			String sName = serviceVfList.get(0).getName();
//			assertEquals(sName,fdntCsarHelper_Data.get("FDNT").get("VF Name").get(0));
//			Map<String, CapabilityAssignment> lCapabilitys = serviceVfList.get(0).getCapabilities().getAll();
//			List<String> CPkeys = new ArrayList<>(lCapabilitys.keySet());
//			List<String> CapabilitiesNames = new ArrayList<String>(CPkeys.size());
//
//			for (int i = 0; i < CPkeys.size(); i++) {
//
//				CapabilityAssignment cCp = lCapabilitys.get(CPkeys.get(i));
//
//				CapabilitiesNames.add(cCp.getName());
//
//				assertEquals(CPkeys.get(i).toLowerCase(), CapabilitiesNames.get(i).toLowerCase());// Compare keys to values, Should it be checked as Case sensitive????
//
//				//System.out.println(String.format("Value of key: %s , Value of capability: %s", keys.get(i).toLowerCase(), Capabilities.get(i).toLowerCase()));
//				//System.out.println(String.format("Value of key: %s , Value of capability: %s", ActualValues.get(i).toLowerCase(), Capabilities.get(i).toLowerCase()));
//				//System.out.println(String.format("*******%d*******",i));
//			}
//
//			for (int i = 0; i < CPkeys.size(); i++) {
//				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.
//			}
//
//			assertEquals(fdntCsarHelper_Data.get("FDNT").get("capabilities").size(), CapabilitiesNames.size()); // Compare capabilities qty expected vs actual
//		}

    //Added by QA - Check for Capabilities in VF level (Capabilities Types and Properties).
    //@Test
//		public void testCapabilitiesofVFTypes_Properties() throws SdcToscaParserException {
//			List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
//			String sName = serviceVfList.get(0).getName();
//			assertEquals(sName,fdntCsarHelper_Data.get("FDNT").get("VF Name").get(0));
//			Map<String, CapabilityAssignment> lCapabilitys = serviceVfList.get(0).getCapabilities().getAll();
//
//			List<String> CPkeys = new ArrayList<>(lCapabilitys.keySet());
//			List<String> CPPropkeys = new ArrayList<>(lCapabilitys.keySet());
//			List<String> CapabilitiesTypes = new ArrayList<String>(CPkeys.size());
//
//			//int iKeysSize = keys.size(); //for debug
//
//			for (int i = 0; i < CPkeys.size(); i++) {
//
//				CapabilityAssignment cCp = lCapabilitys.get(CPkeys.get(i));
//				CapabilityTypeDef CpDef = cCp.getDefinition();
//				CapabilitiesTypes.add(CpDef.getEntityType());
//
//				//LinkedHashMap<String,Object> lProperties = cCp.getDefinition().getProperties();
//				LinkedHashMap<String, Property> lPropertiesR = cCp.getProperties();
//
//	  			List<String> CP_Propkeys = new ArrayList<>(lPropertiesR.keySet());
//
//	  			for (int j = 0; j < CP_Propkeys.size(); j++) {
//
//	  			Property p = lPropertiesR.get(CP_Propkeys.get(j));
//
//				if(p !=  null){
//	  				String sPType = p.getEntityType();
//	  				Boolean bPRequired = p.isRequired();
//
//	  				System.out.println(sPType + "  " + bPRequired);
//
//					}
//
//			}
//
//			}
//
//			for (int i = 0; i < CPkeys.size(); i++) {
//
//			}
//
//			assertEquals(fdntCsarHelper_Data.get("FDNT").get("capabilitiesTypes").size(), CapabilitiesTypes.size()); // Compare capabilities qty expected vs actual
//		}

    //@Test // - BUG 283387
    public void testRequirmentsofVF() throws SdcToscaParserException {
        List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
        String sName = serviceVfList.get(0).getName();
        assertEquals(sName, "FDNT 1");

        List<String> ActualReqsValues = new ArrayList<>(Arrays.asList());

        List<RequirementAssignment> lRequirements = serviceVfList.get(0).getRequirements().getAll();

        assertEquals(fdntCsarHelper_Data.get("FDNT").get("requirements").size(), lRequirements.size()); //

        // Continue from here after bug is fixed ! ! ! !  - Test the Requirements values
    }

}