summaryrefslogtreecommitdiffstats
path: root/infra/data-impl/src/test
diff options
context:
space:
mode:
authorJan Srnicek <jsrnicek@cisco.com>2016-10-24 13:02:59 +0200
committerMaros Marsalek <mmarsale@cisco.com>2016-10-24 17:33:24 +0200
commitbb090e1254eacc95d7bd1dd45f6311967f81af86 (patch)
tree101df09cd4b8adad9d083a00442aecf90e9d9948 /infra/data-impl/src/test
parent81c7ae0e263515b5bf8acb59b06d61ba446b8f0b (diff)
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 <jsrnicek@cisco.com> Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'infra/data-impl/src/test')
-rw-r--r--infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ModifiableDataTreeDelegatorTest.java16
1 files changed, 10 insertions, 6 deletions
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<WriteContext> 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());
}
}