2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdc.be.components.property;
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;
41 import java.util.LinkedList;
42 import java.util.List;
44 import java.util.Optional;
46 public class ComponentInstanceInputPropertyDeceleratorTest {
49 ComponentInstanceInputPropertyDeclarator testSubject;
52 private ComponentInstanceBusinessLogic componentInstanceBusinessLogicMock;
55 private ToscaOperationFacade toscaOperationFacadeMock;
59 MockitoAnnotations.openMocks(this);
63 public void testCreateDeclaredProperty() throws Exception {
64 PropertyDataDefinition prop = new PropertyDataDefinition();
65 ComponentInstanceInput result;
68 result = Deencapsulation.invoke(testSubject, "createDeclaredProperty", prop);
72 public void testUpdatePropertiesValues() throws Exception {
74 Component component = new Resource();
75 String cmptInstanceId = "";
76 List<ComponentInstanceInput> properties = new LinkedList<>();
77 Either<?, StorageOperationStatus> result;
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()));
85 result = Deencapsulation.invoke(testSubject, "updatePropertiesValues", component, cmptInstanceId, properties);
89 public void testResolvePropertiesOwner() throws Exception {
90 Component component = new Resource();
91 String propertiesOwnerId = "mock";
92 Optional<ComponentInstance> result;
95 result = Deencapsulation.invoke(testSubject, "resolvePropertiesOwner", component, propertiesOwnerId);
99 public void testAddPropertiesListToInput() throws Exception {
100 ComponentInstanceInput declaredProp = null;
101 PropertyDataDefinition originalProp = null;
102 InputDefinition input = null;
105 Deencapsulation.invoke(testSubject, "addPropertiesListToInput", new ComponentInstanceInput(),
106 new InputDefinition());
110 public void testUnDeclarePropertiesAsInputs() throws Exception {
111 Component component = null;
112 InputDefinition input = new InputDefinition();
113 StorageOperationStatus result;
115 Mockito.when(componentInstanceBusinessLogicMock
116 .getComponentInstanceInputsByInputId(Mockito.any(Component.class), Mockito.anyString()))
117 .thenReturn(new LinkedList());
119 result = testSubject.unDeclarePropertiesAsInputs(component, input);