Search in sources :

Example 6 with EnableNotification

use of org.opendaylight.controller.cluster.datastore.messages.EnableNotification in project controller by opendaylight.

the class DataTreeChangeListenerActorTest method testDataChangedWhenNotificationsAreEnabled.

@Test
public void testDataChangedWhenNotificationsAreEnabled() {
    new TestKit(getSystem()) {

        {
            final DataTreeCandidate mockTreeCandidate = Mockito.mock(DataTreeCandidate.class);
            final ImmutableList<DataTreeCandidate> mockCandidates = ImmutableList.of(mockTreeCandidate);
            final DOMDataTreeChangeListener mockListener = Mockito.mock(DOMDataTreeChangeListener.class);
            final Props props = DataTreeChangeListenerActor.props(mockListener, TEST_PATH);
            final ActorRef subject = getSystem().actorOf(props, "testDataTreeChangedNotificationsEnabled");
            // Let the DataChangeListener know that notifications should be
            // enabled
            subject.tell(new EnableNotification(true, "test"), getRef());
            subject.tell(new DataTreeChanged(mockCandidates), getRef());
            expectMsgClass(DataTreeChangedReply.class);
            Mockito.verify(mockListener).onDataTreeChanged(mockCandidates);
        }
    };
}
Also used : DataTreeCandidate(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate) EnableNotification(org.opendaylight.controller.cluster.datastore.messages.EnableNotification) DataTreeChanged(org.opendaylight.controller.cluster.datastore.messages.DataTreeChanged) DOMDataTreeChangeListener(org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener) ActorRef(akka.actor.ActorRef) TestKit(akka.testkit.javadsl.TestKit) Props(akka.actor.Props) Test(org.junit.Test)

Aggregations

EnableNotification (org.opendaylight.controller.cluster.datastore.messages.EnableNotification)6 ActorRef (akka.actor.ActorRef)4 Props (akka.actor.Props)4 TestKit (akka.testkit.javadsl.TestKit)4 Test (org.junit.Test)4 ActorSelection (akka.actor.ActorSelection)2 DataChanged (org.opendaylight.controller.cluster.datastore.messages.DataChanged)2 DataTreeChanged (org.opendaylight.controller.cluster.datastore.messages.DataTreeChanged)2 AsyncDataChangeEvent (org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent)2 AsyncDataChangeListener (org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener)2 DOMDataTreeChangeListener (org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener)2 DataTreeCandidate (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate)2