diff options
author | Michael Lando <ml636r@att.com> | 2018-07-29 16:13:45 +0300 |
---|---|---|
committer | Michael Lando <ml636r@att.com> | 2018-07-29 16:20:34 +0300 |
commit | 5b593496b8f1b8e8be8d7d2dbcc223332e65a49b (patch) | |
tree | 2f9dfc45191e723da69cf74be7829784e9741b94 /catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/resource/ResourceDataMergeBusinessLogicTest.java | |
parent | 9200382f2ce7b4bb729aa287d0878004b2d2b4f9 (diff) |
re base code
Change-Id: I12a5ca14a6d8a87e9316b9ff362eb131105f98a5
Issue-ID: SDC-1566
Signed-off-by: Michael Lando <ml636r@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.java | 35 |
1 files changed, 22 insertions, 13 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 a43e1e68ca..90784a4cbe 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,23 +1,21 @@ package org.openecomp.sdc.be.components.merge.resource; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; - -import java.util.Arrays; - +import fj.data.Either; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; -import org.openecomp.sdc.be.components.merge.instance.ComponentsMergeCommand; +import org.openecomp.sdc.be.components.merge.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 static java.util.Arrays.asList; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.*; + @RunWith(MockitoJUnitRunner.class) public class ResourceDataMergeBusinessLogicTest { @@ -25,6 +23,9 @@ public class ResourceDataMergeBusinessLogicTest { private ResourceDataMergeBusinessLogic testInstance; @Mock + private MergeCommandsFactory mergeCommandsFactory; + + @Mock private ComponentsMergeCommand commandA; @Mock @@ -33,15 +34,25 @@ public class ResourceDataMergeBusinessLogicTest { @Mock private ComponentsMergeCommand commandC; + private Resource oldResource, newResource; + @Before public void setUp() throws Exception { - testInstance = new ResourceDataMergeBusinessLogic(Arrays.asList(commandA, commandB, commandC)); + oldResource = ObjectGenerator.buildBasicResource(); + newResource = ObjectGenerator.buildBasicResource(); + when(mergeCommandsFactory.getMergeCommands(oldResource, newResource)).thenReturn(Either.left(asList(commandA, commandB, commandC))); + } + + @Test + public void whenCommandsFactoryFails_propagateTheFailure() { + when(mergeCommandsFactory.getMergeCommands(oldResource, newResource)).thenReturn(Either.right(ActionStatus.GENERAL_ERROR)); + ActionStatus actionStatus = testInstance.mergeResourceEntities(oldResource, newResource); + assertEquals(ActionStatus.GENERAL_ERROR, actionStatus); + verifyZeroInteractions(commandA, commandB, commandC); } @Test public void mergeResources_allMergeClassesAreCalled() { - Resource oldResource = ObjectGenerator.buildBasicResource(); - Resource newResource = ObjectGenerator.buildBasicResource(); when(commandA.mergeComponents(oldResource, newResource)).thenReturn(ActionStatus.OK); when(commandB.mergeComponents(oldResource, newResource)).thenReturn(ActionStatus.OK); when(commandC.mergeComponents(oldResource, newResource)).thenReturn(ActionStatus.OK); @@ -51,8 +62,6 @@ public class ResourceDataMergeBusinessLogicTest { @Test public void mergeResources_mergeCommandFailed_dontCallOtherMergeMethods() { - Resource oldResource = ObjectGenerator.buildBasicResource(); - Resource newResource = ObjectGenerator.buildBasicResource(); when(commandA.mergeComponents(oldResource, newResource)).thenReturn(ActionStatus.GENERAL_ERROR); ActionStatus actionStatus = testInstance.mergeResourceEntities(oldResource, newResource); assertEquals(ActionStatus.GENERAL_ERROR, actionStatus); |