re base code
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / components / property / PropertyDecelerationOrchestratorTest.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.model.*;
12 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
13
14 import java.util.*;
15
16 public class PropertyDecelerationOrchestratorTest {
17
18         @InjectMocks
19         PropertyDeclarationOrchestrator testSubject;
20
21         @Mock
22         List<PropertyDeclarator> propertyDeceleratorsMock;
23         
24         @Mock
25         private ComponentInstanceInputPropertyDeclarator componentInstanceInputPropertyDecelerator;
26         @Mock
27         private ComponentInstancePropertyDeclarator componentInstancePropertyDecelerator;
28         @Mock
29         private PolicyPropertyDeclarator policyPropertyDecelerator;
30
31         @Before
32         public void setUp() throws Exception {
33
34                 MockitoAnnotations.initMocks(this);
35         }
36
37         @Test(expected = IllegalStateException.class)
38         public void testDeclarePropertiesToInputs() throws Exception {
39                 Component component = new Resource();
40                 ComponentInstInputsMap componentInstInputsMap = new ComponentInstInputsMap();
41                 Either<List<InputDefinition>, StorageOperationStatus> result;
42
43                 // default test
44                 result = testSubject.declarePropertiesToInputs(component, componentInstInputsMap);
45         }
46
47         @Test
48         public void testUnDeclarePropertiesAsInputs() throws Exception {
49                 Component component = new Resource();
50                 InputDefinition inputToDelete = new InputDefinition();
51                 StorageOperationStatus result;
52
53                 Iterator<PropertyDeclarator> mockIter = Mockito.mock(Iterator.class);
54                 Mockito.when(propertyDeceleratorsMock.iterator()).thenReturn(mockIter);
55                 Mockito.when(mockIter.hasNext()).thenReturn(false);
56                 
57                 // default test
58                 result = testSubject.unDeclarePropertiesAsInputs(component, inputToDelete);
59         }
60
61         @Test(expected = IllegalStateException.class)
62         public void testGetPropertyDecelerator() throws Exception {
63                 ComponentInstInputsMap componentInstInputsMap = new ComponentInstInputsMap();
64                 PropertyDeclarator result;
65
66                 // default test
67                 result = Deencapsulation.invoke(testSubject, "getPropertyDeclarator", componentInstInputsMap);
68         }
69
70         @Test
71         public void testGetPropertyDeceleratorWithInputsMap() throws Exception {
72                 ComponentInstInputsMap componentInstInputsMap = new ComponentInstInputsMap();
73                 Map<String, List<ComponentInstancePropInput>> componentInstanceInputsMap = new HashMap<>();
74                 List<ComponentInstancePropInput> value = new LinkedList<>();
75                 componentInstanceInputsMap.put("mock", value);
76                 componentInstInputsMap.setComponentInstanceInputsMap(componentInstanceInputsMap);
77                 PropertyDeclarator result;
78
79                 // default test
80                 result = Deencapsulation.invoke(testSubject, "getPropertyDeclarator", componentInstInputsMap);
81         }
82
83         @Test
84         public void testGetPropertyDeceleratorWithCIProperties() throws Exception {
85                 ComponentInstInputsMap componentInstInputsMap = new ComponentInstInputsMap();
86                 Map<String, List<ComponentInstancePropInput>> componentInstanceProperties = new HashMap<>();
87                 List<ComponentInstancePropInput> value = new LinkedList<>();
88                 componentInstanceProperties.put("mock", value);
89                 componentInstInputsMap.setComponentInstancePropInput(componentInstanceProperties);
90                 PropertyDeclarator result;
91
92                 // default test
93                 result = Deencapsulation.invoke(testSubject, "getPropertyDeclarator", componentInstInputsMap);
94         }
95
96         @Test
97         public void testGetPropertyDeceleratorWithCIPolicy() throws Exception {
98                 ComponentInstInputsMap componentInstInputsMap = new ComponentInstInputsMap();
99                 Map<String, List<ComponentInstancePropInput>> policyProperties = new HashMap<>();
100                 List<ComponentInstancePropInput> value = new LinkedList<>();
101                 policyProperties.put("mock", value);
102                 componentInstInputsMap.setPolicyProperties(policyProperties);
103                 PropertyDeclarator result;
104
105                 // default test
106                 result = Deencapsulation.invoke(testSubject, "getPropertyDeclarator", componentInstInputsMap);
107         }
108 }