2 * ============LICENSE_START=======================================================
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
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.openecomp.sdc.enrichment.impl.tosca;
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);
29 private ComponentDao componentDaoMock;
32 private ComponentDependencyModelDao componentDependencyDaoMock;
35 private static ComponentQuestionnaireData componentQuestionnaireData;
38 public void setUp() throws Exception {
39 MockitoAnnotations.openMocks(this);
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" +
52 componentEntity.setQuestionnaireData
53 ("{\"highAvailabilityAndLoadBalancing\":{\"isComponentMandatory\" : \"NO\"," +
54 "\"highAvailabilityMode\":\"geo-activeactive\"},\"compute\":{\"numOfVMs\" " +
55 ":{\"maximum\" : 5, \"minimum\" : 0}}}");
57 List<ComponentEntity> entitites = new ArrayList<ComponentEntity>();
58 entitites.add(componentEntity);
60 doReturn(entitites).when(componentDaoMock).listCompositionAndQuestionnaire(VSP_ID, VERSION01);
62 final Map<String, Map<String, Object>> propertiesfromCompQuestionnaire =
63 componentQuestionnaireData.getPropertiesfromCompQuestionnaire(VSP_ID, VERSION01);
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);
74 final Map<String, String> sourceToTargetComponent =
75 componentQuestionnaireData.getSourceToTargetComponent();
77 Assert.assertEquals("be", sourceToTargetComponent.get("ID1"));
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");
88 ComponentDependencyModelEntity targetComponent = new ComponentDependencyModelEntity(VSP_ID,
90 targetComponent.setSourceComponentId("Comp1");
91 targetComponent.setTargetComponentId("Comp3");
92 targetComponent.setRelation("dependsOn");
94 List<ComponentDependencyModelEntity> entitites = new ArrayList<ComponentDependencyModelEntity>();
95 entitites.add(sourceComponent);
96 entitites.add(targetComponent);
98 doReturn(entitites).when(componentDependencyDaoMock).list(new ComponentDependencyModelEntity
99 (VSP_ID, VERSION01, null));
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);
108 List<String> expectedTargets = new ArrayList<String>();
109 expectedTargets.add("be"); expectedTargets.add("smp");
111 Assert.assertEquals(dependencies.get("fe"), expectedTargets);