aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireDataTest.java
blob: 55ee0911d3bdba0e8b6d4a5ac0cc2814bfb2e4be (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
/*-
 * ============LICENSE_START=======================================================
 * SDC
 * ================================================================================
 * Copyright (C) 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.openecomp.sdc.enrichment.impl.tosca;

public class ComponentQuestionnaireDataTest {
  /*private static String VSP_ID = "vspId";
  public static final Version VERSION01 = new Version(0, 1);
  private static final Version VERSION10 = new Version(1, 0);

  @Mock
  private ComponentDao componentDaoMock;

  @Mock
  private ComponentDependencyModelDao componentDependencyDaoMock;

  @InjectMocks
  private static ComponentQuestionnaireData componentQuestionnaireData;

  @BeforeMethod
  public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
  }

  @Test
  public void testGetData() {
    ComponentEntity componentEntity = new ComponentEntity(VSP_ID, VERSION01,"ID1" );
    componentEntity.setCompositionData("{\n" +
        "  \"name\": \"org.openecomp.resource.vfc.nodes.heat.be\",\n" +
        "  \"displayName\": \"be\",\n" +
        "  \"vfcCode\": \"be_1\",\n" +
        "  \"nfcCode\": \"code\",\n" +
        "  \"nfcFunction\": \"desc\"\n" +
        "}");
    componentEntity.setQuestionnaireData
        ("{\"highAvailabilityAndLoadBalancing\":{\"isComponentMandatory\" : \"NO\"," +
            "\"highAvailabilityMode\":\"geo-activeactive\"},\"compute\":{\"numOfVMs\" " +
            ":{\"maximum\" : 5, \"minimum\" : 0}}}");

    List<ComponentEntity> entitites = new ArrayList<ComponentEntity>();
    entitites.add(componentEntity);

    doReturn(entitites).when(componentDaoMock).listCompositionAndQuestionnaire(VSP_ID, VERSION01);

    final Map<String, Map<String, Object>> propertiesfromCompQuestionnaire =
        componentQuestionnaireData.getPropertiesfromCompQuestionnaire(VSP_ID, VERSION01);

    final Map<String, Object> be = propertiesfromCompQuestionnaire.get("be");
    Assert.assertEquals(be.get(VFC_NAMING_CODE) , "be_1");
    Assert.assertEquals(be.get(VFC_CODE), "code");
    Assert.assertEquals(be.get(VFC_FUNCTION), "desc");
    Assert.assertEquals(be.get(MANDATORY) ,"NO");
    Assert.assertEquals(be.get(HIGH_AVAIL_MODE) ,"geo-activeactive");
    Assert.assertEquals(be.get(MIN_INSTANCES) ,null);
    Assert.assertEquals(be.get(MAX_INSTANCES) ,5);

    final Map<String, String> sourceToTargetComponent =
        componentQuestionnaireData.getSourceToTargetComponent();

    Assert.assertEquals("be", sourceToTargetComponent.get("ID1"));
  }


  @Test
  public void testPopulateDepnendency() {
    ComponentDependencyModelEntity sourceComponent = new ComponentDependencyModelEntity(VSP_ID, VERSION01,"ID1" );
    sourceComponent.setSourceComponentId("Comp1");
    sourceComponent.setTargetComponentId("Comp2");
    sourceComponent.setRelation("dependsOn");

    ComponentDependencyModelEntity targetComponent = new ComponentDependencyModelEntity(VSP_ID,
        VERSION01,"ID2" );
    targetComponent.setSourceComponentId("Comp1");
    targetComponent.setTargetComponentId("Comp3");
    targetComponent.setRelation("dependsOn");

    List<ComponentDependencyModelEntity> entitites = new ArrayList<ComponentDependencyModelEntity>();
    entitites.add(sourceComponent);
    entitites.add(targetComponent);

    doReturn(entitites).when(componentDependencyDaoMock).list(new ComponentDependencyModelEntity
        (VSP_ID, VERSION01, null));

    final Map<String, String> sourceToTargetComponent = new HashMap<String, String>();
    sourceToTargetComponent.put("Comp1", "fe");
    sourceToTargetComponent.put("Comp2", "be");
    sourceToTargetComponent.put("Comp3", "smp");
    final Map<String, List<String>> dependencies =
        componentQuestionnaireData.populateDependencies(VSP_ID, VERSION01, sourceToTargetComponent);

    List<String> expectedTargets =  new ArrayList<String>();
    expectedTargets.add("be"); expectedTargets.add("smp");

    Assert.assertEquals(dependencies.get("fe"), expectedTargets);



  }
*/
}