Added oparent to sdc main
[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.*;
34 import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
35 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
36
37 import java.util.LinkedList;
38 import java.util.List;
39 import java.util.Map;
40 import java.util.Optional;
41
42 public class ComponentInstanceInputPropertyDeceleratorTest {
43
44         @InjectMocks
45         ComponentInstanceInputPropertyDeclarator testSubject;
46
47         @Mock
48         private ComponentInstanceBusinessLogic componentInstanceBusinessLogicMock;
49
50         @Mock
51         private ToscaOperationFacade toscaOperationFacadeMock;
52
53         @Before
54         public void setUp() {
55                 MockitoAnnotations.initMocks(this);
56         }
57
58         @Test
59         public void testCreateDeclaredProperty() throws Exception {
60                 PropertyDataDefinition prop = new PropertyDataDefinition();
61                 ComponentInstanceInput result;
62
63                 // default test
64                 result = Deencapsulation.invoke(testSubject, "createDeclaredProperty", prop);
65         }
66
67         @Test
68         public void testUpdatePropertiesValues() throws Exception {
69                 ;
70                 Component component = new Resource();
71                 String cmptInstanceId = "";
72                 List<ComponentInstanceInput> properties = new LinkedList<>();
73                 Either<?, StorageOperationStatus> result;
74
75                 Component containerComponent;
76                 Map<String, List<ComponentInstanceInput>> instProperties;
77                 Mockito.when(toscaOperationFacadeMock.addComponentInstanceInputsToComponent(Mockito.any(Component.class),
78                                 Mockito.any(Map.class))).thenReturn(Either.left(new Resource()));
79
80                 // default test
81                 result = Deencapsulation.invoke(testSubject, "updatePropertiesValues", component, cmptInstanceId, properties);
82         }
83
84         @Test
85         public void testResolvePropertiesOwner() throws Exception {
86                 Component component = new Resource();
87                 String propertiesOwnerId = "mock";
88                 Optional<ComponentInstance> result;
89
90                 // default test
91                 result = Deencapsulation.invoke(testSubject, "resolvePropertiesOwner", component, propertiesOwnerId);
92         }
93
94         @Test
95         public void testAddPropertiesListToInput() throws Exception {
96                 ComponentInstanceInput declaredProp = null;
97                 PropertyDataDefinition originalProp = null;
98                 InputDefinition input = null;
99
100                 // default test
101                 Deencapsulation.invoke(testSubject, "addPropertiesListToInput", new ComponentInstanceInput(),
102                                 new InputDefinition());
103         }
104
105         @Test
106         public void testUnDeclarePropertiesAsInputs() throws Exception {
107                 Component component = null;
108                 InputDefinition input = new InputDefinition();
109                 StorageOperationStatus result;
110
111                 Mockito.when(componentInstanceBusinessLogicMock
112                                 .getComponentInstanceInputsByInputId(Mockito.any(Component.class), Mockito.anyString()))
113                                 .thenReturn(new LinkedList());
114                 // default test
115                 result = testSubject.unDeclarePropertiesAsInputs(component, input);
116         }
117 }