Improve testing stability
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / components / property / ComponentInstanceInputPropertyDeceleratorTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.be.components.property;
22
23 import fj.data.Either;
24 import mockit.Deencapsulation;
25 import org.junit.Before;
26 import org.junit.Test;
27 import org.mockito.InjectMocks;
28 import org.mockito.Mock;
29 import org.mockito.Mockito;
30 import org.mockito.MockitoAnnotations;
31 import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
32 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
33 import org.openecomp.sdc.be.model.Component;
34 import org.openecomp.sdc.be.model.ComponentInstance;
35 import org.openecomp.sdc.be.model.ComponentInstanceInput;
36 import org.openecomp.sdc.be.model.InputDefinition;
37 import org.openecomp.sdc.be.model.Resource;
38 import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
39 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
40
41 import java.util.LinkedList;
42 import java.util.List;
43 import java.util.Map;
44 import java.util.Optional;
45
46 public class ComponentInstanceInputPropertyDeceleratorTest {
47
48         @InjectMocks
49         ComponentInstanceInputPropertyDeclarator testSubject;
50
51         @Mock
52         private ComponentInstanceBusinessLogic componentInstanceBusinessLogicMock;
53
54         @Mock
55         private ToscaOperationFacade toscaOperationFacadeMock;
56
57         @Before
58         public void setUp() {
59                 MockitoAnnotations.openMocks(this);
60         }
61
62         @Test
63         public void testCreateDeclaredProperty() throws Exception {
64                 PropertyDataDefinition prop = new PropertyDataDefinition();
65                 ComponentInstanceInput result;
66
67                 // default test
68                 result = Deencapsulation.invoke(testSubject, "createDeclaredProperty", prop);
69         }
70
71         @Test
72         public void testUpdatePropertiesValues() throws Exception {
73                 ;
74                 Component component = new Resource();
75                 String cmptInstanceId = "";
76                 List<ComponentInstanceInput> properties = new LinkedList<>();
77                 Either<?, StorageOperationStatus> result;
78
79                 Component containerComponent;
80                 Map<String, List<ComponentInstanceInput>> instProperties;
81                 Mockito.when(toscaOperationFacadeMock.addComponentInstanceInputsToComponent(Mockito.any(Component.class),
82                                 Mockito.any(Map.class))).thenReturn(Either.left(new Resource()));
83
84                 // default test
85                 result = Deencapsulation.invoke(testSubject, "updatePropertiesValues", component, cmptInstanceId, properties);
86         }
87
88         @Test
89         public void testResolvePropertiesOwner() throws Exception {
90                 Component component = new Resource();
91                 String propertiesOwnerId = "mock";
92                 Optional<ComponentInstance> result;
93
94                 // default test
95                 result = Deencapsulation.invoke(testSubject, "resolvePropertiesOwner", component, propertiesOwnerId);
96         }
97
98         @Test
99         public void testAddPropertiesListToInput() throws Exception {
100                 ComponentInstanceInput declaredProp = null;
101                 PropertyDataDefinition originalProp = null;
102                 InputDefinition input = null;
103
104                 // default test
105                 Deencapsulation.invoke(testSubject, "addPropertiesListToInput", new ComponentInstanceInput(),
106                                 new InputDefinition());
107         }
108
109         @Test
110         public void testUnDeclarePropertiesAsInputs() throws Exception {
111                 Component component = null;
112                 InputDefinition input = new InputDefinition();
113                 StorageOperationStatus result;
114
115                 Mockito.when(componentInstanceBusinessLogicMock
116                                 .getComponentInstanceInputsByInputId(Mockito.any(Component.class), Mockito.anyString()))
117                                 .thenReturn(new LinkedList());
118                 // default test
119                 result = testSubject.unDeclarePropertiesAsInputs(component, input);
120         }
121 }