summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/resource/ResourceDataMergeBusinessLogicTest.java
diff options
context:
space:
mode:
authorTal Gitelman <tg851x@intl.att.com>2017-12-10 18:55:03 +0200
committerTal Gitelman <tg851x@intl.att.com>2017-12-10 19:33:38 +0200
commit51d50f0ef642e0f996a1c8b8d2ef4838bdfec892 (patch)
tree3ac236a864d74d19b0f5c9020891a7a7e5c31b44 /catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/resource/ResourceDataMergeBusinessLogicTest.java
parentb5cc2e0695f195716d6ccdc65e73807a6632ec70 (diff)
Final commit to master merge from
Change-Id: Ib464f9a8828437c86fe6def8af238aaf83473507 Issue-ID: SDC-714 Signed-off-by: Tal Gitelman <tg851x@intl.att.com>
Diffstat (limited to 'catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/resource/ResourceDataMergeBusinessLogicTest.java')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/resource/ResourceDataMergeBusinessLogicTest.java82
1 files changed, 82 insertions, 0 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/resource/ResourceDataMergeBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/resource/ResourceDataMergeBusinessLogicTest.java
new file mode 100644
index 0000000000..8e7949f108
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/resource/ResourceDataMergeBusinessLogicTest.java
@@ -0,0 +1,82 @@
+package org.openecomp.sdc.be.components.merge.resource;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.when;
+
+import java.util.Collections;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.be.components.merge.input.ComponentInputsMergeBL;
+import org.openecomp.sdc.be.components.merge.property.ComponentInstanceInputsMergeBL;
+import org.openecomp.sdc.be.components.merge.property.ComponentInstancePropertiesMergeBL;
+import org.openecomp.sdc.be.components.utils.ObjectGenerator;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.model.Resource;
+
+public class ResourceDataMergeBusinessLogicTest {
+
+ @InjectMocks
+ private ResourceDataMergeBusinessLogic testInstance;
+
+ @Mock
+ private ComponentInstanceInputsMergeBL instanceInputsValueMergeBLMock;
+
+ @Mock
+ private ComponentInstancePropertiesMergeBL instancePropertiesValueMergeBLMock;
+
+ @Mock
+ private ComponentInputsMergeBL inputsValueMergeBLMock;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void mergeResourceInputs_allMergeClassesAreCalled() throws Exception {
+ Resource oldResource = ObjectGenerator.buildBasicResource();
+ Resource newResource = ObjectGenerator.buildBasicResource();
+ when(instancePropertiesValueMergeBLMock.mergeComponentInstancesProperties(oldResource, newResource)).thenReturn(ActionStatus.OK);
+ when(instanceInputsValueMergeBLMock.mergeComponentInstancesInputs(oldResource, newResource)).thenReturn(ActionStatus.OK);
+ when(inputsValueMergeBLMock.mergeAndRedeclareComponentInputs(oldResource, newResource, Collections.emptyList())).thenReturn(ActionStatus.OK);
+ ActionStatus actionStatus = testInstance.mergeResourceEntities(oldResource, newResource);
+ assertEquals(ActionStatus.OK, actionStatus);
+ }
+
+ @Test
+ public void mergeResourceInputs_failToMergeProperties_dontCallOtherMergeMethods() throws Exception {
+ Resource oldResource = ObjectGenerator.buildBasicResource();
+ Resource newResource = ObjectGenerator.buildBasicResource();
+ when(instancePropertiesValueMergeBLMock.mergeComponentInstancesProperties(oldResource, newResource)).thenReturn(ActionStatus.GENERAL_ERROR);
+ ActionStatus actionStatus = testInstance.mergeResourceEntities(oldResource, newResource);
+ assertEquals(ActionStatus.GENERAL_ERROR, actionStatus);
+ verifyZeroInteractions(instanceInputsValueMergeBLMock, inputsValueMergeBLMock);
+ }
+
+ @Test
+ public void mergeResourceInputs_failToMergeInstanceInputs_dontCallOtherMergeMethods() throws Exception {
+ Resource oldResource = ObjectGenerator.buildBasicResource();
+ Resource newResource = ObjectGenerator.buildBasicResource();
+ when(instancePropertiesValueMergeBLMock.mergeComponentInstancesProperties(oldResource, newResource)).thenReturn(ActionStatus.OK);
+ when(instanceInputsValueMergeBLMock.mergeComponentInstancesInputs(oldResource, newResource)).thenReturn(ActionStatus.GENERAL_ERROR);
+ ActionStatus actionStatus = testInstance.mergeResourceEntities(oldResource, newResource);
+ assertEquals(ActionStatus.GENERAL_ERROR, actionStatus);
+ verifyZeroInteractions(inputsValueMergeBLMock);
+ }
+
+ @Test
+ public void mergeResourceInputs_failedToMergeInputs() throws Exception {
+ Resource oldResource = ObjectGenerator.buildBasicResource();
+ Resource newResource = ObjectGenerator.buildBasicResource();
+ when(instancePropertiesValueMergeBLMock.mergeComponentInstancesProperties(oldResource, newResource)).thenReturn(ActionStatus.OK);
+ when(instanceInputsValueMergeBLMock.mergeComponentInstancesInputs(oldResource, newResource)).thenReturn(ActionStatus.OK);
+ when(inputsValueMergeBLMock.mergeAndRedeclareComponentInputs(oldResource, newResource, Collections.emptyList())).thenReturn(ActionStatus.GENERAL_ERROR);
+ ActionStatus actionStatus = testInstance.mergeResourceEntities(oldResource, newResource);
+ assertEquals(ActionStatus.GENERAL_ERROR, actionStatus);
+ }
+} \ No newline at end of file