summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/resource/ResourceDataMergeBusinessLogicTest.java
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2018-03-04 14:53:33 +0200
committerMichael Lando <ml636r@att.com>2018-03-07 13:19:05 +0000
commita5445100050e49e83f73424198d73cd72d672a4d (patch)
treecacf4df817df31be23e4e790d1dda857bdae061e /catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/resource/ResourceDataMergeBusinessLogicTest.java
parent51157f92c21976cba4914c378aaa3cba49826931 (diff)
Sync Integ to Master
Change-Id: I71e3acc26fa612127756ac04073a522b9cc6cd74 Issue-ID: SDC-977 Signed-off-by: Gitelman, Tal (tg851x) <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.java65
1 files changed, 23 insertions, 42 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
index 8e7949f108..0590c7e500 100644
--- 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
@@ -1,82 +1,63 @@
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.junit.runner.RunWith;
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.mockito.junit.MockitoJUnitRunner;
+import org.openecomp.sdc.be.components.merge.instance.ComponentsMergeCommand;
import org.openecomp.sdc.be.components.utils.ObjectGenerator;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.model.Resource;
+import java.util.Arrays;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
public class ResourceDataMergeBusinessLogicTest {
@InjectMocks
private ResourceDataMergeBusinessLogic testInstance;
@Mock
- private ComponentInstanceInputsMergeBL instanceInputsValueMergeBLMock;
+ private ComponentsMergeCommand commandA;
@Mock
- private ComponentInstancePropertiesMergeBL instancePropertiesValueMergeBLMock;
+ private ComponentsMergeCommand commandB;
@Mock
- private ComponentInputsMergeBL inputsValueMergeBLMock;
+ private ComponentsMergeCommand commandC;
@Before
public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
+ testInstance = new ResourceDataMergeBusinessLogic(Arrays.asList(commandA, commandB, commandC));
}
@Test
- public void mergeResourceInputs_allMergeClassesAreCalled() throws Exception {
+ public void mergeResources_allMergeClassesAreCalled() {
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);
+ when(commandA.mergeComponents(oldResource, newResource)).thenReturn(ActionStatus.OK);
+ when(commandB.mergeComponents(oldResource, newResource)).thenReturn(ActionStatus.OK);
+ when(commandC.mergeComponents(oldResource, newResource)).thenReturn(ActionStatus.OK);
ActionStatus actionStatus = testInstance.mergeResourceEntities(oldResource, newResource);
assertEquals(ActionStatus.OK, actionStatus);
}
@Test
- public void mergeResourceInputs_failToMergeProperties_dontCallOtherMergeMethods() throws Exception {
+ public void mergeResources_mergeCommandFailed_dontCallOtherMergeMethods() {
Resource oldResource = ObjectGenerator.buildBasicResource();
Resource newResource = ObjectGenerator.buildBasicResource();
- when(instancePropertiesValueMergeBLMock.mergeComponentInstancesProperties(oldResource, newResource)).thenReturn(ActionStatus.GENERAL_ERROR);
+ when(commandA.mergeComponents(oldResource, newResource)).thenReturn(ActionStatus.GENERAL_ERROR);
ActionStatus actionStatus = testInstance.mergeResourceEntities(oldResource, newResource);
assertEquals(ActionStatus.GENERAL_ERROR, actionStatus);
- verifyZeroInteractions(instanceInputsValueMergeBLMock, inputsValueMergeBLMock);
+ verify(commandA).description();
+ verifyZeroInteractions(commandB, commandC);
}
- @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