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