Upgrade SDC from Titan to Janus Graph
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / components / property / ComponentInstanceInputPropertyDeceleratorTest.java
1 package org.openecomp.sdc.be.components.property;
2
3 import fj.data.Either;
4 import mockit.Deencapsulation;
5 import org.junit.Before;
6 import org.junit.Test;
7 import org.mockito.InjectMocks;
8 import org.mockito.Mock;
9 import org.mockito.Mockito;
10 import org.mockito.MockitoAnnotations;
11 import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
12 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
13 import org.openecomp.sdc.be.model.*;
14 import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
15 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
16
17 import java.util.LinkedList;
18 import java.util.List;
19 import java.util.Map;
20 import java.util.Optional;
21
22 public class ComponentInstanceInputPropertyDeceleratorTest {
23
24         @InjectMocks
25         ComponentInstanceInputPropertyDeclarator testSubject;
26
27         @Mock
28         private ComponentInstanceBusinessLogic componentInstanceBusinessLogicMock;
29
30         @Mock
31         private ToscaOperationFacade toscaOperationFacadeMock;
32
33         @Before
34         public void setUp() {
35                 MockitoAnnotations.initMocks(this);
36         }
37
38         @Test
39         public void testCreateDeclaredProperty() throws Exception {
40                 PropertyDataDefinition prop = new PropertyDataDefinition();
41                 ComponentInstanceInput result;
42
43                 // default test
44                 result = Deencapsulation.invoke(testSubject, "createDeclaredProperty", prop);
45         }
46
47         @Test
48         public void testUpdatePropertiesValues() throws Exception {
49                 ;
50                 Component component = new Resource();
51                 String cmptInstanceId = "";
52                 List<ComponentInstanceInput> properties = new LinkedList<>();
53                 Either<?, StorageOperationStatus> result;
54
55                 Component containerComponent;
56                 Map<String, List<ComponentInstanceInput>> instProperties;
57                 Mockito.when(toscaOperationFacadeMock.addComponentInstanceInputsToComponent(Mockito.any(Component.class),
58                                 Mockito.any(Map.class))).thenReturn(Either.left(new Resource()));
59
60                 // default test
61                 result = Deencapsulation.invoke(testSubject, "updatePropertiesValues", component, cmptInstanceId, properties);
62         }
63
64         @Test
65         public void testResolvePropertiesOwner() throws Exception {
66                 Component component = new Resource();
67                 String propertiesOwnerId = "mock";
68                 Optional<ComponentInstance> result;
69
70                 // default test
71                 result = Deencapsulation.invoke(testSubject, "resolvePropertiesOwner", component, propertiesOwnerId);
72         }
73
74         @Test
75         public void testAddPropertiesListToInput() throws Exception {
76                 ComponentInstanceInput declaredProp = null;
77                 PropertyDataDefinition originalProp = null;
78                 InputDefinition input = null;
79
80                 // default test
81                 Deencapsulation.invoke(testSubject, "addPropertiesListToInput", new ComponentInstanceInput(),
82                                 new InputDefinition());
83         }
84
85         @Test
86         public void testUnDeclarePropertiesAsInputs() throws Exception {
87                 Component component = null;
88                 InputDefinition input = new InputDefinition();
89                 StorageOperationStatus result;
90
91                 Mockito.when(componentInstanceBusinessLogicMock
92                                 .getComponentInstanceInputsByInputId(Mockito.any(Component.class), Mockito.anyString()))
93                                 .thenReturn(new LinkedList());
94                 // default test
95                 result = testSubject.unDeclarePropertiesAsInputs(component, input);
96         }
97 }