From 567247ad5a1ba1c8aff3cb2b47211f7c68f0545d Mon Sep 17 00:00:00 2001 From: Maros Marsalek Date: Wed, 9 Nov 2016 09:44:26 +0100 Subject: HONEYCOMB-170 Add more information to RevertFailedEx Change-Id: I6b24a1d061c94d57730b20cde4c5b3c39444b119 Signed-off-by: Maros Marsalek --- .../write/registry/BulkUpdateExceptionTest.java | 11 ++++++++--- .../write/registry/RevertFailedExceptionTest.java | 19 ++++++++++++++++++- 2 files changed, 26 insertions(+), 4 deletions(-) (limited to 'infra/translate-api/src/test') diff --git a/infra/translate-api/src/test/java/io/fd/honeycomb/translate/write/registry/BulkUpdateExceptionTest.java b/infra/translate-api/src/test/java/io/fd/honeycomb/translate/write/registry/BulkUpdateExceptionTest.java index ae0c36d5b..9623db5bc 100644 --- a/infra/translate-api/src/test/java/io/fd/honeycomb/translate/write/registry/BulkUpdateExceptionTest.java +++ b/infra/translate-api/src/test/java/io/fd/honeycomb/translate/write/registry/BulkUpdateExceptionTest.java @@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.verify; import com.google.common.collect.Sets; +import io.fd.honeycomb.translate.write.DataObjectUpdate; import io.fd.honeycomb.translate.write.WriteContext; import java.util.HashSet; import org.junit.Before; @@ -35,9 +36,12 @@ public class BulkUpdateExceptionTest { @Mock private WriteContext writeContext; - @Mock private WriterRegistry.Reverter reverter; + @Mock + private DataObject before; + @Mock + private DataObject after; @Before public void setUp() throws Exception { @@ -48,9 +52,10 @@ public class BulkUpdateExceptionTest { public void testRevert() throws Exception { final HashSet> failedIds = Sets.newHashSet(id); final WriterRegistry.BulkUpdateException bulkUpdateException = - new WriterRegistry.BulkUpdateException(failedIds, reverter, new RuntimeException()); + new WriterRegistry.BulkUpdateException(id, DataObjectUpdate.create(id, before, after), + failedIds, reverter, new RuntimeException()); - assertEquals(failedIds, bulkUpdateException.getFailedIds()); + assertEquals(failedIds, bulkUpdateException.getUnrevertedSubtrees()); bulkUpdateException.revertChanges(writeContext); verify(reverter).revert(writeContext); diff --git a/infra/translate-api/src/test/java/io/fd/honeycomb/translate/write/registry/RevertFailedExceptionTest.java b/infra/translate-api/src/test/java/io/fd/honeycomb/translate/write/registry/RevertFailedExceptionTest.java index 721941d1e..6502235d0 100644 --- a/infra/translate-api/src/test/java/io/fd/honeycomb/translate/write/registry/RevertFailedExceptionTest.java +++ b/infra/translate-api/src/test/java/io/fd/honeycomb/translate/write/registry/RevertFailedExceptionTest.java @@ -19,20 +19,37 @@ package io.fd.honeycomb.translate.write.registry; import static org.junit.Assert.assertEquals; import com.google.common.collect.Sets; +import io.fd.honeycomb.translate.write.DataObjectUpdate; import java.util.Set; +import org.junit.Before; import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class RevertFailedExceptionTest { private InstanceIdentifier id = InstanceIdentifier.create(DataObject.class); + @Mock + private WriterRegistry.Reverter reverter; + @Mock + private DataObject before; + @Mock + private DataObject after; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + } @Test public void testNonRevert() throws Exception { final Set> notReverted = Sets.newHashSet(id); final WriterRegistry.Reverter.RevertFailedException revertFailedException = - new WriterRegistry.Reverter.RevertFailedException(notReverted, new RuntimeException()); + new WriterRegistry.Reverter.RevertFailedException( + new WriterRegistry.BulkUpdateException(id, DataObjectUpdate.create(id, before, after), + notReverted, reverter, new RuntimeException())); assertEquals(notReverted, revertFailedException.getNotRevertedChanges()); } } \ No newline at end of file -- cgit 1.2.3-korg