Added oparent to sdc main
[sdc.git] / openecomp-be / lib / openecomp-sdc-enrichment-lib / openecomp-sdc-enrichment-impl / src / test / java / org / openecomp / sdc / enrichment / impl / tosca / ComponentQuestionnaireDataTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 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.openecomp.sdc.enrichment.impl.tosca;
22
23 public class ComponentQuestionnaireDataTest {
24   /*private static String VSP_ID = "vspId";
25   public static final Version VERSION01 = new Version(0, 1);
26   private static final Version VERSION10 = new Version(1, 0);
27
28   @Mock
29   private ComponentDao componentDaoMock;
30
31   @Mock
32   private ComponentDependencyModelDao componentDependencyDaoMock;
33
34   @InjectMocks
35   private static ComponentQuestionnaireData componentQuestionnaireData;
36
37   @BeforeMethod
38   public void setUp() throws Exception {
39     MockitoAnnotations.initMocks(this);
40   }
41
42   @Test
43   public void testGetData() {
44     ComponentEntity componentEntity = new ComponentEntity(VSP_ID, VERSION01,"ID1" );
45     componentEntity.setCompositionData("{\n" +
46         "  \"name\": \"org.openecomp.resource.vfc.nodes.heat.be\",\n" +
47         "  \"displayName\": \"be\",\n" +
48         "  \"vfcCode\": \"be_1\",\n" +
49         "  \"nfcCode\": \"code\",\n" +
50         "  \"nfcFunction\": \"desc\"\n" +
51         "}");
52     componentEntity.setQuestionnaireData
53         ("{\"highAvailabilityAndLoadBalancing\":{\"isComponentMandatory\" : \"NO\"," +
54             "\"highAvailabilityMode\":\"geo-activeactive\"},\"compute\":{\"numOfVMs\" " +
55             ":{\"maximum\" : 5, \"minimum\" : 0}}}");
56
57     List<ComponentEntity> entitites = new ArrayList<ComponentEntity>();
58     entitites.add(componentEntity);
59
60     doReturn(entitites).when(componentDaoMock).listCompositionAndQuestionnaire(VSP_ID, VERSION01);
61
62     final Map<String, Map<String, Object>> propertiesfromCompQuestionnaire =
63         componentQuestionnaireData.getPropertiesfromCompQuestionnaire(VSP_ID, VERSION01);
64
65     final Map<String, Object> be = propertiesfromCompQuestionnaire.get("be");
66     Assert.assertEquals(be.get(VFC_NAMING_CODE) , "be_1");
67     Assert.assertEquals(be.get(VFC_CODE), "code");
68     Assert.assertEquals(be.get(VFC_FUNCTION), "desc");
69     Assert.assertEquals(be.get(MANDATORY) ,"NO");
70     Assert.assertEquals(be.get(HIGH_AVAIL_MODE) ,"geo-activeactive");
71     Assert.assertEquals(be.get(MIN_INSTANCES) ,null);
72     Assert.assertEquals(be.get(MAX_INSTANCES) ,5);
73
74     final Map<String, String> sourceToTargetComponent =
75         componentQuestionnaireData.getSourceToTargetComponent();
76
77     Assert.assertEquals("be", sourceToTargetComponent.get("ID1"));
78   }
79
80
81   @Test
82   public void testPopulateDepnendency() {
83     ComponentDependencyModelEntity sourceComponent = new ComponentDependencyModelEntity(VSP_ID, VERSION01,"ID1" );
84     sourceComponent.setSourceComponentId("Comp1");
85     sourceComponent.setTargetComponentId("Comp2");
86     sourceComponent.setRelation("dependsOn");
87
88     ComponentDependencyModelEntity targetComponent = new ComponentDependencyModelEntity(VSP_ID,
89         VERSION01,"ID2" );
90     targetComponent.setSourceComponentId("Comp1");
91     targetComponent.setTargetComponentId("Comp3");
92     targetComponent.setRelation("dependsOn");
93
94     List<ComponentDependencyModelEntity> entitites = new ArrayList<ComponentDependencyModelEntity>();
95     entitites.add(sourceComponent);
96     entitites.add(targetComponent);
97
98     doReturn(entitites).when(componentDependencyDaoMock).list(new ComponentDependencyModelEntity
99         (VSP_ID, VERSION01, null));
100
101     final Map<String, String> sourceToTargetComponent = new HashMap<String, String>();
102     sourceToTargetComponent.put("Comp1", "fe");
103     sourceToTargetComponent.put("Comp2", "be");
104     sourceToTargetComponent.put("Comp3", "smp");
105     final Map<String, List<String>> dependencies =
106         componentQuestionnaireData.populateDependencies(VSP_ID, VERSION01, sourceToTargetComponent);
107
108     List<String> expectedTargets =  new ArrayList<String>();
109     expectedTargets.add("be"); expectedTargets.add("smp");
110
111     Assert.assertEquals(dependencies.get("fe"), expectedTargets);
112
113
114
115   }
116 */
117 }