aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-model/src/test
diff options
context:
space:
mode:
authorSatoshi Fujii <fujii-satoshi@jp.fujitsu.com>2019-05-20 16:00:56 +0900
committerOren Kleks <orenkle@amdocs.com>2019-05-20 12:37:00 +0000
commitc0b223d4fa51947c1aad771cae210678554aff3e (patch)
treefc6a6625dd32b9ef19bdc87042583383d4ed6855 /catalog-model/src/test
parent258900e4a46d7e414e526e7322b0d6319fdb79a8 (diff)
Fixed declared properties are not updated properly
Change-Id: I3712f9656d7cdeb8fa9c4212b2dd1496043c1006 Issue-ID: SDC-2314 Signed-off-by: Satoshi Fujii <fujii-satoshi@jp.fujitsu.com>
Diffstat (limited to 'catalog-model/src/test')
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacadeTest.java42
1 files changed, 42 insertions, 0 deletions
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacadeTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacadeTest.java
index 0eb0b3c6d2..b43b632ad1 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacadeTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacadeTest.java
@@ -51,6 +51,7 @@ import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.ComponentParametersView;
@@ -82,6 +83,8 @@ import java.util.Arrays;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyMap;
@@ -91,6 +94,12 @@ import static org.mockito.ArgumentMatchers.eq;
@RunWith(MockitoJUnitRunner.class)
public class ToscaOperationFacadeTest {
+ private static final String COMPONENT_ID = "componentId";
+ private static final String PROPERTY1_NAME = "prop1";
+ private static final String PROPERTY1_TYPE = "string";
+ private static final String PROPERTY2_NAME = "prop2";
+ private static final String PROPERTY2_TYPE = "integer";
+
@InjectMocks
private ToscaOperationFacade testInstance;
@@ -103,6 +112,9 @@ public class ToscaOperationFacadeTest {
@Mock
private NodeTypeOperation nodeTypeOperation;
+ @Mock
+ private NodeTemplateOperation nodeTemplateOperationMock;
+
@Before
public void setUp() throws Exception {
testInstance = new ToscaOperationFacade();
@@ -584,6 +596,36 @@ public class ToscaOperationFacadeTest {
assertEquals(datatype, result);
}
+ @Test
+ public void testAddComponentInstancePropertiesToComponent() {
+ // set up component object
+ Component component = new Resource();
+ component.setUniqueId(COMPONENT_ID);
+ List<ComponentInstanceProperty> instanceProps = new ArrayList<>();
+ ComponentInstanceProperty instanceProp = new ComponentInstanceProperty();
+ instanceProp.setName(PROPERTY1_NAME);
+ instanceProp.setType(PROPERTY1_TYPE);
+ instanceProps.add(instanceProp);
+ instanceProp = new ComponentInstanceProperty();
+ instanceProp.setName(PROPERTY2_NAME);
+ instanceProp.setType(PROPERTY2_TYPE);
+ instanceProps.add(instanceProp);
+ Map<String, List<ComponentInstanceProperty>> instancePropsMap =
+ Collections.singletonMap(COMPONENT_ID, instanceProps);
+ component.setComponentInstancesProperties(Collections.singletonMap(COMPONENT_ID, new ArrayList<>()));
+
+ when(nodeTemplateOperationMock.addComponentInstanceProperty(any(), any(), any()))
+ .thenReturn(StorageOperationStatus.OK);
+
+ Either<Map<String, List<ComponentInstanceProperty>>, StorageOperationStatus> result =
+ testInstance.addComponentInstancePropertiesToComponent(component, instancePropsMap);
+ assertTrue(result.isLeft());
+ verify(nodeTemplateOperationMock, times(2)).addComponentInstanceProperty(any(), any(), any());
+ List<ComponentInstanceProperty> resultProps = result.left().value().get(COMPONENT_ID);
+ assertTrue(resultProps.stream().anyMatch(e -> e.getName().equals(PROPERTY1_NAME)));
+ assertTrue(resultProps.stream().anyMatch(e -> e.getName().equals(PROPERTY2_NAME)));
+ }
+
private Either<PolicyDefinition, StorageOperationStatus> associatePolicyToComponentWithStatus(StorageOperationStatus status) {
PolicyDefinition policy = new PolicyDefinition();
String componentId = "componentId";