package org.opendaylight.mdsal.binding.dom.adapter;
import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.anyCollection;
+import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION;
-import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ExecutionException;
import org.junit.Test;
.build());
domTx.commit().get();
- final var captor = ArgumentCaptor.forClass(Collection.class);
+ final var captor = ArgumentCaptor.forClass(List.class);
verify(listener).onDataTreeChanged(captor.capture());
- Collection<DataTreeModification<Container>> capture = captor.getValue();
+ List<DataTreeModification<Container>> capture = captor.getValue();
assertEquals(1, capture.size());
- final DataTreeModification<Container> change = capture.iterator().next();
+ final DataTreeModification<Container> change = capture.get(0);
assertEquals(CONTAINER_TID, change.getRootPath());
final DataObjectModification<Container> changedContainer = change.getRootNode();
- assertEquals(new NodeStep<>(Container.class), changedContainer.getIdentifier());
- assertEquals(ModificationType.SUBTREE_MODIFIED, changedContainer.getModificationType());
+ assertEquals(new NodeStep<>(Container.class), changedContainer.step());
+ assertEquals(ModificationType.SUBTREE_MODIFIED, changedContainer.modificationType());
- final Container containerAfter = changedContainer.getDataAfter();
+ final Container containerAfter = changedContainer.dataAfter();
assertEquals(new ContainerBuilder()
.setKeyed(List.of(
new KeyedBuilder().setFoo("foo").withKey(new KeyedKey("foo")).build(),
new KeyedBuilder().setFoo("bar").withKey(new KeyedKey("bar")).build()))
.build(), containerAfter);
- final Collection<? extends DataObjectModification<?>> changedChildren = changedContainer.getModifiedChildren();
+ final var changedChildren = changedContainer.modifiedChildren();
assertEquals(2, changedChildren.size());
- final Iterator<? extends DataObjectModification<?>> it = changedChildren.iterator();
+ final var it = changedChildren.iterator();
final DataObjectModification<?> changedChild1 = it.next();
- assertEquals(ModificationType.WRITE, changedChild1.getModificationType());
- assertEquals(List.of(), changedChild1.getModifiedChildren());
- final Keyed child1After = (Keyed) changedChild1.getDataAfter();
+ assertEquals(ModificationType.WRITE, changedChild1.modificationType());
+ assertEquals(List.of(), changedChild1.modifiedChildren());
+ final Keyed child1After = (Keyed) changedChild1.dataAfter();
assertEquals("foo", child1After.getFoo());
final DataObjectModification<?> changedChild2 = it.next();
- assertEquals(ModificationType.WRITE, changedChild2.getModificationType());
- assertEquals(List.of(), changedChild2.getModifiedChildren());
- final Keyed child2After = (Keyed) changedChild2.getDataAfter();
+ assertEquals(ModificationType.WRITE, changedChild2.modificationType());
+ assertEquals(List.of(), changedChild2.modifiedChildren());
+ final Keyed child2After = (Keyed) changedChild2.dataAfter();
assertEquals("bar", child2After.getFoo());
}
.build());
domTx.commit().get();
- final var captor = ArgumentCaptor.forClass(Collection.class);
+ final var captor = ArgumentCaptor.forClass(List.class);
verify(listener).onDataTreeChanged(captor.capture());
- Collection<DataTreeModification<Container>> capture = captor.getValue();
+ List<DataTreeModification<Container>> capture = captor.getValue();
assertEquals(1, capture.size());
- final DataTreeModification<Container> change = capture.iterator().next();
+ final DataTreeModification<Container> change = capture.get(0);
assertEquals(CONTAINER_TID, change.getRootPath());
final DataObjectModification<Container> changedContainer = change.getRootNode();
- assertEquals(new NodeStep<>(Container.class), changedContainer.getIdentifier());
- assertEquals(ModificationType.WRITE, changedContainer.getModificationType());
+ assertEquals(new NodeStep<>(Container.class), changedContainer.step());
+ assertEquals(ModificationType.WRITE, changedContainer.modificationType());
- final Container containerAfter = changedContainer.getDataAfter();
+ final Container containerAfter = changedContainer.dataAfter();
assertEquals(new ContainerBuilder()
.setUnkeyed(List.of(
new UnkeyedBuilder().setFoo("foo").build(),
new UnkeyedBuilder().setFoo("bar").build()))
.build(), containerAfter);
- final Collection<? extends DataObjectModification<?>> changedChildren = changedContainer.getModifiedChildren();
+ final var changedChildren = changedContainer.modifiedChildren();
assertEquals(0, changedChildren.size());
}
public void testChoiceDataTreeModificationAddressable() throws InterruptedException, ExecutionException {
final DataTreeChangeListener<WithChoice> listener = assertWrittenWithChoice();
- doNothing().when(listener).onDataTreeChanged(anyCollection());
+ doNothing().when(listener).onDataTreeChanged(anyList());
final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(CONFIGURATION, ADDRESSABLE_CASE, new AddressableBuilder().build());
writeTx.commit().get();
- final var captor = ArgumentCaptor.forClass(Collection.class);
+ final var captor = ArgumentCaptor.forClass(List.class);
verify(listener).onDataTreeChanged(captor.capture());
- Collection<DataTreeModification<WithChoice>> capture = captor.getValue();
+ List<DataTreeModification<WithChoice>> capture = captor.getValue();
assertEquals(1, capture.size());
final DataTreeModification<WithChoice> choiceChange = capture.iterator().next();
assertEquals(CHOICE_CONTAINER_TID, choiceChange.getRootPath());
final DataObjectModification<WithChoice> changedContainer = choiceChange.getRootNode();
- assertEquals(ModificationType.SUBTREE_MODIFIED, changedContainer.getModificationType());
- assertEquals(new NodeStep<>(WithChoice.class), changedContainer.getIdentifier());
+ assertEquals(ModificationType.SUBTREE_MODIFIED, changedContainer.modificationType());
+ assertEquals(new NodeStep<>(WithChoice.class), changedContainer.step());
- final Collection<? extends DataObjectModification<?>> choiceChildren = changedContainer.getModifiedChildren();
+ final var choiceChildren = changedContainer.modifiedChildren();
assertEquals(1, choiceChildren.size());
- final DataObjectModification<Addressable> changedCase = (DataObjectModification<Addressable>) choiceChildren
- .iterator().next();
- assertEquals(ModificationType.WRITE, changedCase.getModificationType());
- assertEquals(new NodeStep<>(Addressable.class), changedCase.getIdentifier());
- assertEquals(new AddressableBuilder().build(), changedCase.getDataAfter());
+ final var changedCase = (DataObjectModification<Addressable>) choiceChildren.iterator().next();
+ assertEquals(ModificationType.WRITE, changedCase.modificationType());
+ assertEquals(new NodeStep<>(Addressable.class), changedCase.step());
+ assertEquals(new AddressableBuilder().build(), changedCase.dataAfter());
}
@Test
final DataTreeChangeListener<AddressableCont> listener = assertWrittenContainer(AddressableCont.QNAME,
AddressableCont.class, new AddressableContBuilder().build());
- doNothing().when(listener).onDataTreeChanged(anyCollection());
+ doNothing().when(listener).onDataTreeChanged(anyList());
final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(CONFIGURATION, ADDRESSABLE_CONTAINER.child(AddressableChild.class),
new AddressableChildBuilder().build());
writeTx.commit().get();
- final var captor = ArgumentCaptor.forClass(Collection.class);
+ final var captor = ArgumentCaptor.forClass(List.class);
verify(listener).onDataTreeChanged(captor.capture());
- Collection<DataTreeModification<AddressableCont>> capture = captor.getValue();
+ final List<DataTreeModification<AddressableCont>> capture = captor.getValue();
assertEquals(1, capture.size());
final DataTreeModification<AddressableCont> contChange = capture.iterator().next();
assertEquals(ADDRESSABLE_CONTAINER_TID, contChange.getRootPath());
final DataObjectModification<AddressableCont> changedContainer = contChange.getRootNode();
- assertEquals(ModificationType.SUBTREE_MODIFIED, changedContainer.getModificationType());
- assertEquals(new NodeStep<>(AddressableCont.class), changedContainer.getIdentifier());
+ assertEquals(ModificationType.SUBTREE_MODIFIED, changedContainer.modificationType());
+ assertEquals(new NodeStep<>(AddressableCont.class), changedContainer.step());
- final Collection<? extends DataObjectModification<?>> contChildren = changedContainer.getModifiedChildren();
+ final var contChildren = changedContainer.modifiedChildren();
assertEquals(1, contChildren.size());
- final DataObjectModification<Addressable> changedChild = (DataObjectModification<Addressable>) contChildren
- .iterator().next();
- assertEquals(ModificationType.WRITE, changedChild.getModificationType());
- assertEquals(new NodeStep<>(AddressableChild.class), changedChild.getIdentifier());
- assertEquals(new AddressableChildBuilder().build(), changedChild.getDataAfter());
+ final var changedChild = (DataObjectModification<Addressable>) contChildren.iterator().next();
+ assertEquals(ModificationType.WRITE, changedChild.modificationType());
+ assertEquals(new NodeStep<>(AddressableChild.class), changedChild.step());
+ assertEquals(new AddressableChildBuilder().build(), changedChild.dataAfter());
}
@Test
final DataTreeChangeListener<UnaddressableCont> listener = assertWrittenContainer(UnaddressableCont.QNAME,
UnaddressableCont.class, new UnaddressableContBuilder().build());
- doNothing().when(listener).onDataTreeChanged(anyCollection());
+ doNothing().when(listener).onDataTreeChanged(anyList());
final DOMDataTreeWriteTransaction domTx = getDomBroker().newWriteOnlyTransaction();
domTx.put(CONFIGURATION, YangInstanceIdentifier.of(UNADDRESSABLE_CONTAINER_NID)
ImmutableNodes.leafNode(BAZ_QNAME, "baz"));
domTx.commit().get();
- final var captor = ArgumentCaptor.forClass(Collection.class);
+ final var captor = ArgumentCaptor.forClass(List.class);
verify(listener).onDataTreeChanged(captor.capture());
- Collection<DataTreeModification<UnaddressableCont>> capture = captor.getValue();
+ List<DataTreeModification<UnaddressableCont>> capture = captor.getValue();
assertEquals(1, capture.size());
final DataTreeModification<UnaddressableCont> contChange = capture.iterator().next();
assertEquals(UNADDRESSABLE_CONTAINER_TID, contChange.getRootPath());
final DataObjectModification<UnaddressableCont> changedContainer = contChange.getRootNode();
- assertEquals(ModificationType.WRITE, changedContainer.getModificationType());
- assertEquals(new NodeStep<>(UnaddressableCont.class), changedContainer.getIdentifier());
+ assertEquals(ModificationType.WRITE, changedContainer.modificationType());
+ assertEquals(new NodeStep<>(UnaddressableCont.class), changedContainer.step());
- final Collection<? extends DataObjectModification<?>> contChildren = changedContainer.getModifiedChildren();
+ final var contChildren = changedContainer.modifiedChildren();
assertEquals(0, contChildren.size());
}
public void testChoiceDataTreeModificationUnaddressable() throws InterruptedException, ExecutionException {
final DataTreeChangeListener<WithChoice> listener = assertWrittenWithChoice();
- doNothing().when(listener).onDataTreeChanged(anyCollection());
+ doNothing().when(listener).onDataTreeChanged(anyList());
final DOMDataTreeWriteTransaction domTx = getDomBroker().newWriteOnlyTransaction();
domTx.put(CONFIGURATION, YangInstanceIdentifier.of(CHOICE_CONTAINER_NID).node(Foo.QNAME),
.build());
domTx.commit().get();
- final var captor = ArgumentCaptor.forClass(Collection.class);
+ final var captor = ArgumentCaptor.forClass(List.class);
verify(listener).onDataTreeChanged(captor.capture());
- Collection<DataTreeModification<WithChoice>> capture = captor.getValue();
+ List<DataTreeModification<WithChoice>> capture = captor.getValue();
assertEquals(1, capture.size());
- final DataTreeModification<WithChoice> choiceChange = capture.iterator().next();
+ final DataTreeModification<WithChoice> choiceChange = capture.get(0);
assertEquals(CHOICE_CONTAINER_TID, choiceChange.getRootPath());
final DataObjectModification<WithChoice> changedContainer = choiceChange.getRootNode();
// Should be write
- assertEquals(ModificationType.WRITE, changedContainer.getModificationType());
- assertEquals(new NodeStep<>(WithChoice.class), changedContainer.getIdentifier());
+ assertEquals(ModificationType.WRITE, changedContainer.modificationType());
+ assertEquals(new NodeStep<>(WithChoice.class), changedContainer.step());
- final Collection<? extends DataObjectModification<?>> choiceChildren = changedContainer.getModifiedChildren();
+ final var choiceChildren = changedContainer.modifiedChildren();
assertEquals(0, choiceChildren.size());
}
final Class<T> bindingClass, final T expected)
throws InterruptedException, ExecutionException {
final DataTreeChangeListener<T> listener = mock(DataTreeChangeListener.class);
- doNothing().when(listener).onDataTreeChanged(anyCollection());
+ doNothing().when(listener).onDataTreeChanged(anyList());
final DataTreeIdentifier<T> dti = DataTreeIdentifier.of(CONFIGURATION, InstanceIdentifier.create(bindingClass));
getDataBroker().registerDataTreeChangeListener(dti, listener);
ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(qname)).build());
domTx.commit().get();
- final var captor = ArgumentCaptor.forClass(Collection.class);
+ final var captor = ArgumentCaptor.forClass(List.class);
verify(listener).onDataTreeChanged(captor.capture());
- Collection<DataTreeModification<T>> capture = captor.getValue();
+ List<DataTreeModification<T>> capture = captor.getValue();
assertEquals(1, capture.size());
final DataTreeModification<T> change = capture.iterator().next();
assertEquals(dti, change.getRootPath());
final DataObjectModification<T> changedContainer = change.getRootNode();
- assertEquals(ModificationType.WRITE, changedContainer.getModificationType());
- assertEquals(new NodeStep<>(bindingClass), changedContainer.getIdentifier());
+ assertEquals(ModificationType.WRITE, changedContainer.modificationType());
+ assertEquals(new NodeStep<>(bindingClass), changedContainer.step());
- final T containerAfter = changedContainer.getDataAfter();
+ final T containerAfter = changedContainer.dataAfter();
assertEquals(expected, containerAfter);
// No further modifications should occur
- assertEquals(List.of(), changedContainer.getModifiedChildren());
+ assertEquals(List.of(), changedContainer.modifiedChildren());
reset(listener);
- doNothing().when(listener).onDataTreeChanged(anyCollection());
+ doNothing().when(listener).onDataTreeChanged(anyList());
return listener;
}
private DataTreeChangeListener<WithChoice> assertWrittenWithChoice() throws InterruptedException,
ExecutionException {
final DataTreeChangeListener<WithChoice> listener = mock(DataTreeChangeListener.class);
- doNothing().when(listener).onDataTreeChanged(anyCollection());
+ doNothing().when(listener).onDataTreeChanged(anyList());
getDataBroker().registerDataTreeChangeListener(CHOICE_CONTAINER_TID, listener);
final DOMDataTreeWriteTransaction domTx = getDomBroker().newWriteOnlyTransaction();
.build());
domTx.commit().get();
- final var captor = ArgumentCaptor.forClass(Collection.class);
+ final var captor = ArgumentCaptor.forClass(List.class);
verify(listener).onDataTreeChanged(captor.capture());
- Collection<DataTreeModification<WithChoice>> capture = captor.getValue();
+ List<DataTreeModification<WithChoice>> capture = captor.getValue();
assertEquals(1, capture.size());
final DataTreeModification<WithChoice> change = capture.iterator().next();
assertEquals(CHOICE_CONTAINER_TID, change.getRootPath());
final DataObjectModification<WithChoice> changedContainer = change.getRootNode();
- assertEquals(ModificationType.WRITE, changedContainer.getModificationType());
- assertEquals(new NodeStep<>(WithChoice.class), changedContainer.getIdentifier());
+ assertEquals(ModificationType.WRITE, changedContainer.modificationType());
+ assertEquals(new NodeStep<>(WithChoice.class), changedContainer.step());
- final WithChoice containerAfter = changedContainer.getDataAfter();
+ final WithChoice containerAfter = changedContainer.dataAfter();
assertEquals(new WithChoiceBuilder().build(), containerAfter);
// No further modifications should occur
- assertEquals(List.of(), changedContainer.getModifiedChildren());
+ assertEquals(List.of(), changedContainer.modifiedChildren());
reset(listener);
- doNothing().when(listener).onDataTreeChanged(anyCollection());
+ doNothing().when(listener).onDataTreeChanged(anyList());
return listener;
}