From bb090e1254eacc95d7bd1dd45f6311967f81af86 Mon Sep 17 00:00:00 2001 From: Jan Srnicek Date: Mon, 24 Oct 2016 13:02:59 +0200 Subject: HONEYCOMB-255 - Cutting identifiers to prevent failing of reverts Mapping allready processes changes for reverting by InstanceIdentifier instead of using KeyedInstanceIdentifier(to prevent failing to identify handleable nodes) Modified logging to prevent double/triple logging of detailed cause of failed bulk update Reusing WriteContext for revert(removed try with resource to prevent closing of write context before revert) Change-Id: Ie939ebe443629f9cdad5b5b449aa8c5dac40ea67 Signed-off-by: Jan Srnicek Signed-off-by: Maros Marsalek --- .../data/impl/ModifiableDataTreeDelegatorTest.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'infra/data-impl/src/test') diff --git a/infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ModifiableDataTreeDelegatorTest.java b/infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ModifiableDataTreeDelegatorTest.java index 0a7c85b3b..322328508 100644 --- a/infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ModifiableDataTreeDelegatorTest.java +++ b/infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ModifiableDataTreeDelegatorTest.java @@ -49,6 +49,8 @@ import java.util.HashMap; import java.util.Map; import org.junit.Before; import org.junit.Test; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; import org.mockito.Mock; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; @@ -76,6 +78,9 @@ public class ModifiableDataTreeDelegatorTest { @Mock private org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction tx; + @Captor + private ArgumentCaptor writeContextCaptor; + private ModifiableDataTreeManager configDataTree; static final InstanceIdentifier DEFAULT_ID = InstanceIdentifier.create(DataObject.class); @@ -149,12 +154,11 @@ public class ModifiableDataTreeDelegatorTest { dataModification.write(ModificationDiffTest.NESTED_LIST_ID, nestedList); dataModification.validate(); dataModification.commit(); - fail("WriterRegistry.BulkUpdateException was expected"); - } catch (WriterRegistry.BulkUpdateException e) { + fail("WriterRegistry.RevertSuccessException was expected"); + } catch (WriterRegistry.Reverter.RevertSuccessException e) { verify(writer).update(any(WriterRegistry.DataObjectUpdates.class), any(WriteContext.class)); assertThat(e.getFailedIds(), hasItem(DEFAULT_ID)); - verify(reverter).revert(); - assertEquals(failedOnUpdateException, e.getCause()); + verify(reverter).revert(any(WriteContext.class)); } } @@ -171,7 +175,7 @@ public class ModifiableDataTreeDelegatorTest { // Fail on revert: final TranslationException failedOnRevertException = new TranslationException("revert failed"); doThrow(new WriterRegistry.Reverter.RevertFailedException(Collections.emptySet(), failedOnRevertException)) - .when(reverter).revert(); + .when(reverter).revert(any(WriteContext.class)); try { // Run the test @@ -182,7 +186,7 @@ public class ModifiableDataTreeDelegatorTest { fail("WriterRegistry.Reverter.RevertFailedException was expected"); } catch (WriterRegistry.Reverter.RevertFailedException e) { verify(writer).update(any(WriterRegistry.DataObjectUpdates.class), any(WriteContext.class)); - verify(reverter).revert(); + verify(reverter).revert(any(WriteContext.class)); assertEquals(failedOnRevertException, e.getCause()); } } -- cgit 1.2.3-korg