From eecd1059188582486cfd39cce2c047dc43b5f8aa Mon Sep 17 00:00:00 2001 From: shrek2000 Date: Tue, 3 Dec 2019 08:40:41 +0200 Subject: Increase code coverage test ZusammenConnector Issue-ID: SDC-2690 Signed-off-by: shrek2000 Change-Id: I301f7718c09491c34207908819370193b2c74b01 Signed-off-by: shrek2000 --- .../persistence/ZusammenConnectorTest.java | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'zusammen-lib/src') diff --git a/zusammen-lib/src/test/java/org/onap/sdc/common/zusammen/persistence/ZusammenConnectorTest.java b/zusammen-lib/src/test/java/org/onap/sdc/common/zusammen/persistence/ZusammenConnectorTest.java index ff5ac54..b65cdc9 100644 --- a/zusammen-lib/src/test/java/org/onap/sdc/common/zusammen/persistence/ZusammenConnectorTest.java +++ b/zusammen-lib/src/test/java/org/onap/sdc/common/zusammen/persistence/ZusammenConnectorTest.java @@ -43,6 +43,7 @@ import com.amdocs.zusammen.datatypes.item.ItemVersion; import com.amdocs.zusammen.datatypes.item.ItemVersionData; import com.amdocs.zusammen.datatypes.item.ItemVersionStatus; import com.amdocs.zusammen.datatypes.item.SynchronizationStatus; +import com.amdocs.zusammen.datatypes.itemversion.ItemVersionRevisions; import com.amdocs.zusammen.datatypes.itemversion.Tag; import com.amdocs.zusammen.datatypes.response.ErrorCode; import com.amdocs.zusammen.datatypes.response.Module; @@ -315,6 +316,58 @@ public class ZusammenConnectorTest { } + + @Test + public void testResetVersionRevision() { + ItemVersionAdaptor itemAdaptor = mock(ItemVersionAdaptor.class); + ItemVersionAdaptor itemVersionAdaptor = spy(itemAdaptor); + Response response = new Response<>(null); + Id id = new Id(); + when(versionAdaptorFactoryMock.createInterface(sessionContext)).thenReturn(itemVersionAdaptor); + when(itemVersionAdaptor.resetRevision(sessionContext, id, id, id)).thenReturn(response); + zusammenConnector.resetVersionRevision(sessionContext, id, id, id); + verify(itemVersionAdaptor).resetRevision(sessionContext, id, id, id); + + } + + @Test + public void testRevertVersionRevision() { + ItemVersionAdaptor itemAdaptor = mock(ItemVersionAdaptor.class); + ItemVersionAdaptor itemVersionAdaptor = spy(itemAdaptor); + Response response = new Response<>(null); + when(versionAdaptorFactoryMock.createInterface(sessionContext)).thenReturn(itemVersionAdaptor); + Id id = new Id(); + when(itemVersionAdaptor.revertRevision(sessionContext, id, id, id)).thenReturn(response); + zusammenConnector.revertVersionRevision(sessionContext, id, id, id); + verify(itemVersionAdaptor).revertRevision(sessionContext, id, id, id); + } + + + @Test + public void testListVersionRevisions() { + ItemVersionAdaptor itemAdaptor = mock(ItemVersionAdaptor.class); + ItemVersionRevisions itemVersionRevisions = new ItemVersionRevisions(); + Response response = new Response<>(itemVersionRevisions); + when(versionAdaptorFactoryMock.createInterface(sessionContext)).thenReturn(itemAdaptor); + Id id = new Id(); + when(itemAdaptor.listRevisions(sessionContext, id, id)).thenReturn(response); + ItemVersionRevisions itemVersionRevisions1 = zusammenConnector.listVersionRevisions(sessionContext, id, id); + assertEquals(itemVersionRevisions, itemVersionRevisions1); + } + + @Test + public void testPublishVersion() { + ItemVersionAdaptor itemVersionAdaptor = spy(ItemVersionAdaptor.class); + Response response = new Response<>(null); + when(versionAdaptorFactoryMock.createInterface(sessionContext)).thenReturn(itemVersionAdaptor); + Id id = new Id(); + String blaBla = "bla bla"; + when(itemVersionAdaptor.publish(sessionContext, id, id, blaBla)).thenReturn(response); + zusammenConnector.publishVersion(sessionContext, id, id, blaBla); + verify(itemVersionAdaptor).publish(sessionContext, id, id, blaBla); + } + + private void setResponseErrorReturnCode(Response response) { response.setReturnCode(new ReturnCode(ErrorCode.CL_ELEMENT_GET, Module.ZSTM, "bla bla", null)); } -- cgit 1.2.3-korg