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.*;
34 import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
35 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
37 import java.util.LinkedList;
38 import java.util.List;
40 import java.util.Optional;
42 public class ComponentInstanceInputPropertyDeceleratorTest {
45 ComponentInstanceInputPropertyDeclarator testSubject;
48 private ComponentInstanceBusinessLogic componentInstanceBusinessLogicMock;
51 private ToscaOperationFacade toscaOperationFacadeMock;
55 MockitoAnnotations.initMocks(this);
59 public void testCreateDeclaredProperty() throws Exception {
60 PropertyDataDefinition prop = new PropertyDataDefinition();
61 ComponentInstanceInput result;
64 result = Deencapsulation.invoke(testSubject, "createDeclaredProperty", prop);
68 public void testUpdatePropertiesValues() throws Exception {
70 Component component = new Resource();
71 String cmptInstanceId = "";
72 List<ComponentInstanceInput> properties = new LinkedList<>();
73 Either<?, StorageOperationStatus> result;
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()));
81 result = Deencapsulation.invoke(testSubject, "updatePropertiesValues", component, cmptInstanceId, properties);
85 public void testResolvePropertiesOwner() throws Exception {
86 Component component = new Resource();
87 String propertiesOwnerId = "mock";
88 Optional<ComponentInstance> result;
91 result = Deencapsulation.invoke(testSubject, "resolvePropertiesOwner", component, propertiesOwnerId);
95 public void testAddPropertiesListToInput() throws Exception {
96 ComponentInstanceInput declaredProp = null;
97 PropertyDataDefinition originalProp = null;
98 InputDefinition input = null;
101 Deencapsulation.invoke(testSubject, "addPropertiesListToInput", new ComponentInstanceInput(),
102 new InputDefinition());
106 public void testUnDeclarePropertiesAsInputs() throws Exception {
107 Component component = null;
108 InputDefinition input = new InputDefinition();
109 StorageOperationStatus result;
111 Mockito.when(componentInstanceBusinessLogicMock
112 .getComponentInstanceInputsByInputId(Mockito.any(Component.class), Mockito.anyString()))
113 .thenReturn(new LinkedList());
115 result = testSubject.unDeclarePropertiesAsInputs(component, input);