The collection of changes needs to be considered to be ordered. This
patch codifies that by using a List. This has the up side of making it
easier to access first/last item as well as to navigate around.
Change-Id: If747e0000f8a9bb33d934b84c0c078d56d4c6126
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
import static java.util.Objects.requireNonNull;
import com.google.common.collect.ForwardingObject;
import static java.util.Objects.requireNonNull;
import com.google.common.collect.ForwardingObject;
-import com.google.common.collect.Iterables;
-import java.util.Collection;
import org.opendaylight.yangtools.yang.binding.DataObject;
final class DataChangeListenerAdapter<T extends DataObject> extends ForwardingObject
import org.opendaylight.yangtools.yang.binding.DataObject;
final class DataChangeListenerAdapter<T extends DataObject> extends ForwardingObject
- public void onDataTreeChanged(final Collection<DataTreeModification<T>> changes) {
- delegate.dataChanged(changes.iterator().next().getRootNode().dataBefore(),
- Iterables.getLast(changes).getRootNode().dataAfter());
+ public void onDataTreeChanged(final List<DataTreeModification<T>> changes) {
+ delegate.dataChanged(changes.get(0).getRootNode().dataBefore(),
+ changes.get(changes.size() - 1).getRootNode().dataAfter());
import static java.util.Objects.requireNonNull;
import com.google.common.collect.ForwardingObject;
import static java.util.Objects.requireNonNull;
import com.google.common.collect.ForwardingObject;
-import com.google.common.collect.Iterables;
-import java.util.Collection;
import org.opendaylight.yangtools.yang.binding.DataObject;
final class DataListenerAdapter<T extends DataObject> extends ForwardingObject
import org.opendaylight.yangtools.yang.binding.DataObject;
final class DataListenerAdapter<T extends DataObject> extends ForwardingObject
- public void onDataTreeChanged(final Collection<DataTreeModification<T>> changes) {
- delegate.dataChangedTo(Iterables.getLast(changes).getRootNode().dataAfter());
+ public void onDataTreeChanged(final List<DataTreeModification<T>> changes) {
+ delegate.dataChangedTo(changes.get(changes.size() - 1).getRootNode().dataAfter());
*/
package org.opendaylight.mdsal.binding.api;
*/
package org.opendaylight.mdsal.binding.api;
-import java.util.Collection;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.binding.DataObject;
/**
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.binding.DataObject;
/**
- * Interface implemented by classes interested in receiving notifications about
- * data tree changes. It provides a cursor-based view of the change, which has potentially
- * lower overhead and allow more flexible consumption of change event.
+ * Interface implemented by classes interested in receiving notifications about changes to a data tree. It provides
+ * a cursor-based view of the change, which has potentially lower overhead and allow more flexible consumption of change
+ * events.
*/
public interface DataTreeChangeListener<T extends DataObject> {
/**
*/
public interface DataTreeChangeListener<T extends DataObject> {
/**
- * Invoked when there was data change for the supplied path, which was used
- * to register this listener.
+ * Invoked when there was data change for the supplied path, which was used to register this listener.
- * This method may be also invoked during registration of the listener if
- * there is any pre-existing data in the conceptual data tree for supplied
- * path. This initial event will contain all pre-existing data as created.
+ * This method may be also invoked during registration of the listener if there is any pre-existing data in the
+ * conceptual data tree for supplied path. This initial event will contain all pre-existing data as created.
*
* <p>
* Note: If there is no pre-existing data, the method {@link #onInitialData} will be invoked.
*
* <p>
*
* <p>
* Note: If there is no pre-existing data, the method {@link #onInitialData} will be invoked.
*
* <p>
- * A data change event may be triggered spuriously, e.g. such that data before
- * and after compare as equal. Implementations of this interface are expected
- * to recover from such events. Event producers are expected to exert reasonable
- * effort to suppress such events.
+ * A data change event may be triggered spuriously, e.g. such that data before and after compare as equal.
+ * Implementations of this interface are expected to recover from such events. Event producers are expected to exert
+ * reasonable effort to suppress such events.
- * In other words, it is completely acceptable to observe
- * a {@link DataObjectModification}, while the state observed before and
- * after- data items compare as equal.
+ * In other words, it is completely acceptable to observe a {@link DataObjectModification}, while the state observed
+ * before and after- data items compare as equal.
- * @param changes Collection of change events, may not be null or empty.
+ * @param changes List of change events, may not be null or empty.
- void onDataTreeChanged(@NonNull Collection<DataTreeModification<T>> changes);
+ void onDataTreeChanged(@NonNull List<DataTreeModification<T>> changes);
- * Invoked only once during registration of the listener if there was no data in the conceptual data tree
- * for the supplied path, which was used to register this listener, and after this
- * {@link #onDataTreeChanged(Collection)} would always be invoked for data changes.
+ * Invoked only once during registration of the listener if there was no data in the conceptual data tree for the
+ * supplied path, which was used to register this listener, and after this {@link #onDataTreeChanged(List)} would
+ * always be invoked for data changes.
- * Default implementation does nothing and is appropriate for users who do not care about ascertaining
- * initial state.
+ * Default implementation does nothing and is appropriate for users who do not care about ascertaining initial
+ * state.
- // FIXME: 8.0.0: this method should be non-default
+ // FIXME: 14.0.0: this method should be non-default
default void onInitialData() {
//no-op
}
default void onInitialData() {
//no-op
}
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
-import java.util.Collection;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@Mock
private BindingDOMCodecServices services;
@Mock
private BindingDOMCodecServices services;
- @SuppressWarnings("rawtypes")
- private ListenerRegistration mockDOMReg;
+ private Registration mockDOMReg;
@Before
public void setUp() {
@Before
public void setUp() {
private static final class TestClusteredDataTreeChangeListener implements ClusteredDataTreeChangeListener<Top> {
@Override
private static final class TestClusteredDataTreeChangeListener implements ClusteredDataTreeChangeListener<Top> {
@Override
- public void onDataTreeChanged(final Collection<DataTreeModification<Top>> changes) {
+ public void onDataTreeChanged(final List<DataTreeModification<Top>> changes) {
// No-op
}
}
private static final class TestDataTreeChangeListener implements DataTreeChangeListener<Top> {
@Override
// No-op
}
}
private static final class TestDataTreeChangeListener implements DataTreeChangeListener<Top> {
@Override
- public void onDataTreeChanged(final Collection<DataTreeModification<Top>> changes) {
+ public void onDataTreeChanged(final List<DataTreeModification<Top>> changes) {
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.verify;
-import java.util.Collection;
import org.junit.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.junit.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
@Mock
private DataTreeChangeListener<ListItem> listener;
@Captor
@Mock
private DataTreeChangeListener<ListItem> listener;
@Captor
- private ArgumentCaptor<Collection<DataTreeModification<ListItem>>> captor;
+ private ArgumentCaptor<List<DataTreeModification<ListItem>>> captor;
@Test
void testDataTreeChangeListener() {
final var dataBroker = getDataBroker();
final var wildCard = InstanceIdentifier.builder(ListenerTest.class).child(ListItem.class).build();
@Test
void testDataTreeChangeListener() {
final var dataBroker = getDataBroker();
final var wildCard = InstanceIdentifier.builder(ListenerTest.class).child(ListItem.class).build();
- final var reg = dataBroker.registerDataTreeChangeListener(
- DataTreeIdentifier.of(LogicalDatastoreType.OPERATIONAL, wildCard), listener);
+ try (var reg = dataBroker.registerDataTreeChangeListener(
+ DataTreeIdentifier.of(LogicalDatastoreType.OPERATIONAL, wildCard), listener)) {
+ final var item = writeListItem();
- final var item = writeListItem();
+ verify(listener, timeout(100)).onDataTreeChanged(captor.capture());
- verify(listener, timeout(100)).onDataTreeChanged(captor.capture());
-
- final var mods = captor.getValue();
- assertEquals(1, mods.size());
- assertEquals(item, mods.iterator().next().getRootNode().getDataAfter());
+ final var mods = captor.getValue();
+ assertEquals(1, mods.size());
+ assertEquals(item, mods.get(0).getRootNode().dataAfter());
+ }
}
private ListItem writeListItem() {
}
private ListItem writeListItem() {
import com.google.common.collect.Iterables;
import com.google.common.util.concurrent.SettableFuture;
import java.util.Collection;
import com.google.common.collect.Iterables;
import com.google.common.util.concurrent.SettableFuture;
import java.util.Collection;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
private BindingDOMDataBrokerAdapter dataBrokerImpl;
private static final class EventCapturingListener<T extends DataObject> implements DataTreeChangeListener<T> {
private BindingDOMDataBrokerAdapter dataBrokerImpl;
private static final class EventCapturingListener<T extends DataObject> implements DataTreeChangeListener<T> {
-
- private SettableFuture<Collection<DataTreeModification<T>>> futureChanges = SettableFuture.create();
+ private SettableFuture<List<DataTreeModification<T>>> futureChanges = SettableFuture.create();
- public void onDataTreeChanged(final Collection<DataTreeModification<T>> changes) {
+ public void onDataTreeChanged(final List<DataTreeModification<T>> changes) {
futureChanges.set(changes);
futureChanges.set(changes);
}
Collection<DataTreeModification<T>> nextEvent() throws Exception {
}
Collection<DataTreeModification<T>> nextEvent() throws Exception {
- final Collection<DataTreeModification<T>> result = futureChanges.get(200,TimeUnit.MILLISECONDS);
+ final var result = futureChanges.get(200,TimeUnit.MILLISECONDS);
futureChanges = SettableFuture.create();
return result;
}
futureChanges = SettableFuture.create();
return result;
}
package org.opendaylight.mdsal.binding.dom.adapter;
import static org.junit.Assert.assertEquals;
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 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;
import java.util.List;
import java.util.concurrent.ExecutionException;
import org.junit.Test;
.build());
domTx.commit().get();
.build());
domTx.commit().get();
- final var captor = ArgumentCaptor.forClass(Collection.class);
+ final var captor = ArgumentCaptor.forClass(List.class);
verify(listener).onDataTreeChanged(captor.capture());
verify(listener).onDataTreeChanged(captor.capture());
- Collection<DataTreeModification<Container>> capture = captor.getValue();
+ List<DataTreeModification<Container>> capture = captor.getValue();
assertEquals(1, capture.size());
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(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);
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());
assertEquals(2, changedChildren.size());
- final Iterator<? extends DataObjectModification<?>> it = changedChildren.iterator();
+ final var it = changedChildren.iterator();
final DataObjectModification<?> changedChild1 = it.next();
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("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());
}
assertEquals("bar", child2After.getFoo());
}
.build());
domTx.commit().get();
.build());
domTx.commit().get();
- final var captor = ArgumentCaptor.forClass(Collection.class);
+ final var captor = ArgumentCaptor.forClass(List.class);
verify(listener).onDataTreeChanged(captor.capture());
verify(listener).onDataTreeChanged(captor.capture());
- Collection<DataTreeModification<Container>> capture = captor.getValue();
+ List<DataTreeModification<Container>> capture = captor.getValue();
assertEquals(1, capture.size());
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(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);
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());
}
assertEquals(0, changedChildren.size());
}
public void testChoiceDataTreeModificationAddressable() throws InterruptedException, ExecutionException {
final DataTreeChangeListener<WithChoice> listener = assertWrittenWithChoice();
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 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());
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(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());
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());
final DataTreeChangeListener<AddressableCont> listener = assertWrittenContainer(AddressableCont.QNAME,
AddressableCont.class, new AddressableContBuilder().build());
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 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());
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(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());
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());
final DataTreeChangeListener<UnaddressableCont> listener = assertWrittenContainer(UnaddressableCont.QNAME,
UnaddressableCont.class, new UnaddressableContBuilder().build());
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)
final DOMDataTreeWriteTransaction domTx = getDomBroker().newWriteOnlyTransaction();
domTx.put(CONFIGURATION, YangInstanceIdentifier.of(UNADDRESSABLE_CONTAINER_NID)
ImmutableNodes.leafNode(BAZ_QNAME, "baz"));
domTx.commit().get();
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());
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(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());
}
assertEquals(0, contChildren.size());
}
public void testChoiceDataTreeModificationUnaddressable() throws InterruptedException, ExecutionException {
final DataTreeChangeListener<WithChoice> listener = assertWrittenWithChoice();
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),
final DOMDataTreeWriteTransaction domTx = getDomBroker().newWriteOnlyTransaction();
domTx.put(CONFIGURATION, YangInstanceIdentifier.of(CHOICE_CONTAINER_NID).node(Foo.QNAME),
.build());
domTx.commit().get();
.build());
domTx.commit().get();
- final var captor = ArgumentCaptor.forClass(Collection.class);
+ final var captor = ArgumentCaptor.forClass(List.class);
verify(listener).onDataTreeChanged(captor.capture());
verify(listener).onDataTreeChanged(captor.capture());
- Collection<DataTreeModification<WithChoice>> capture = captor.getValue();
+ List<DataTreeModification<WithChoice>> capture = captor.getValue();
assertEquals(1, capture.size());
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(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());
}
assertEquals(0, choiceChildren.size());
}
final Class<T> bindingClass, final T expected)
throws InterruptedException, ExecutionException {
final DataTreeChangeListener<T> listener = mock(DataTreeChangeListener.class);
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);
final DataTreeIdentifier<T> dti = DataTreeIdentifier.of(CONFIGURATION, InstanceIdentifier.create(bindingClass));
getDataBroker().registerDataTreeChangeListener(dti, listener);
ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(qname)).build());
domTx.commit().get();
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());
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(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(expected, containerAfter);
// No further modifications should occur
- assertEquals(List.of(), changedContainer.getModifiedChildren());
+ assertEquals(List.of(), changedContainer.modifiedChildren());
- 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);
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();
getDataBroker().registerDataTreeChangeListener(CHOICE_CONTAINER_TID, listener);
final DOMDataTreeWriteTransaction domTx = getDomBroker().newWriteOnlyTransaction();
.build());
domTx.commit().get();
.build());
domTx.commit().get();
- final var captor = ArgumentCaptor.forClass(Collection.class);
+ final var captor = ArgumentCaptor.forClass(List.class);
verify(listener).onDataTreeChanged(captor.capture());
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(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(new WithChoiceBuilder().build(), containerAfter);
// No further modifications should occur
- assertEquals(List.of(), changedContainer.getModifiedChildren());
+ assertEquals(List.of(), changedContainer.modifiedChildren());
- doNothing().when(listener).onDataTreeChanged(anyCollection());
+ doNothing().when(listener).onDataTreeChanged(anyList());
import com.google.common.util.concurrent.Uninterruptibles;
import java.util.ArrayDeque;
import java.util.Arrays;
import com.google.common.util.concurrent.Uninterruptibles;
import java.util.ArrayDeque;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import org.eclipse.jdt.annotation.NonNull;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import org.eclipse.jdt.annotation.NonNull;
private boolean synced;
@Override
private boolean synced;
@Override
- public synchronized void onDataTreeChanged(final Collection<DataTreeModification<T>> changes) {
+ public synchronized void onDataTreeChanged(final List<DataTreeModification<T>> changes) {
accumulatedChanges.addAll(changes);
synced = true;
}
accumulatedChanges.addAll(changes);
synced = true;
}