1 package org.openecomp.sdc.enrichment.impl.tosca;
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);
9 private ComponentDao componentDaoMock;
12 private ComponentDependencyModelDao componentDependencyDaoMock;
15 private static ComponentQuestionnaireData componentQuestionnaireData;
18 public void setUp() throws Exception {
19 MockitoAnnotations.initMocks(this);
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" +
32 componentEntity.setQuestionnaireData
33 ("{\"highAvailabilityAndLoadBalancing\":{\"isComponentMandatory\" : \"NO\"," +
34 "\"highAvailabilityMode\":\"geo-activeactive\"},\"compute\":{\"numOfVMs\" " +
35 ":{\"maximum\" : 5, \"minimum\" : 0}}}");
37 List<ComponentEntity> entitites = new ArrayList<ComponentEntity>();
38 entitites.add(componentEntity);
40 doReturn(entitites).when(componentDaoMock).listCompositionAndQuestionnaire(VSP_ID, VERSION01);
42 final Map<String, Map<String, Object>> propertiesfromCompQuestionnaire =
43 componentQuestionnaireData.getPropertiesfromCompQuestionnaire(VSP_ID, VERSION01);
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);
54 final Map<String, String> sourceToTargetComponent =
55 componentQuestionnaireData.getSourceToTargetComponent();
57 Assert.assertEquals("be", sourceToTargetComponent.get("ID1"));
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");
68 ComponentDependencyModelEntity targetComponent = new ComponentDependencyModelEntity(VSP_ID,
70 targetComponent.setSourceComponentId("Comp1");
71 targetComponent.setTargetComponentId("Comp3");
72 targetComponent.setRelation("dependsOn");
74 List<ComponentDependencyModelEntity> entitites = new ArrayList<ComponentDependencyModelEntity>();
75 entitites.add(sourceComponent);
76 entitites.add(targetComponent);
78 doReturn(entitites).when(componentDependencyDaoMock).list(new ComponentDependencyModelEntity
79 (VSP_ID, VERSION01, null));
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);
88 List<String> expectedTargets = new ArrayList<String>();
89 expectedTargets.add("be"); expectedTargets.add("smp");
91 Assert.assertEquals(dependencies.get("fe"), expectedTargets);