Refactor Register*ListenerReply classes
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / DataTreeChangeListenerProxyTest.java
index 8cf0d83a79dcfa6239e1b783352173264e924ab2..927f9297979453589d2e2fa59c96ce82910df3c1 100644 (file)
@@ -29,12 +29,12 @@ import org.junit.Test;
 import org.mockito.stubbing.Answer;
 import org.opendaylight.controller.cluster.datastore.config.Configuration;
 import org.opendaylight.controller.cluster.datastore.exceptions.NotInitializedException;
-import org.opendaylight.controller.cluster.datastore.messages.CloseDataTreeChangeListenerRegistration;
+import org.opendaylight.controller.cluster.datastore.messages.CloseDataTreeNotificationListenerRegistration;
 import org.opendaylight.controller.cluster.datastore.messages.FindLocalShard;
 import org.opendaylight.controller.cluster.datastore.messages.LocalShardFound;
 import org.opendaylight.controller.cluster.datastore.messages.LocalShardNotFound;
 import org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeChangeListener;
-import org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeChangeListenerReply;
+import org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeNotificationListenerReply;
 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
 import org.opendaylight.controller.cluster.datastore.utils.Dispatchers;
 import org.opendaylight.controller.cluster.raft.utils.DoNothingActor;
@@ -56,14 +56,14 @@ public class DataTreeChangeListenerProxyTest extends AbstractActorTest {
                 ActorContext actorContext = new ActorContext(getSystem(), getRef(), mock(ClusterWrapper.class),
                         mock(Configuration.class));
 
+                final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
                 final DataTreeChangeListenerProxy<DOMDataTreeChangeListener> proxy = new DataTreeChangeListenerProxy<>(
-                        actorContext, mockListener);
+                        actorContext, mockListener, path);
 
-                final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
                 new Thread() {
                     @Override
                     public void run() {
-                        proxy.init("shard-1", path);
+                        proxy.init("shard-1");
                     }
 
                 }.start();
@@ -79,7 +79,7 @@ public class DataTreeChangeListenerProxyTest extends AbstractActorTest {
                 Assert.assertEquals("getPath", path, registerMsg.getPath());
                 Assert.assertEquals("isRegisterOnAllInstances", false, registerMsg.isRegisterOnAllInstances());
 
-                reply(new RegisterDataTreeChangeListenerReply(getRef()));
+                reply(new RegisterDataTreeNotificationListenerReply(getRef()));
 
                 for (int i = 0; i < 20 * 5 && proxy.getListenerRegistrationActor() == null; i++) {
                     Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS);
@@ -93,7 +93,7 @@ public class DataTreeChangeListenerProxyTest extends AbstractActorTest {
                 proxy.close();
 
                 // The listener registration actor should get a Close message
-                expectMsgClass(timeout, CloseDataTreeChangeListenerRegistration.class);
+                expectMsgClass(timeout, CloseDataTreeNotificationListenerRegistration.class);
 
                 // The DataChangeListener actor should be terminated
                 expectMsgClass(timeout, Terminated.class);
@@ -115,14 +115,14 @@ public class DataTreeChangeListenerProxyTest extends AbstractActorTest {
                 ClusteredDOMDataTreeChangeListener mockClusteredListener = mock(
                         ClusteredDOMDataTreeChangeListener.class);
 
+                final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
                 final DataTreeChangeListenerProxy<ClusteredDOMDataTreeChangeListener> proxy =
-                        new DataTreeChangeListenerProxy<>(actorContext, mockClusteredListener);
+                        new DataTreeChangeListenerProxy<>(actorContext, mockClusteredListener, path);
 
-                final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
                 new Thread() {
                     @Override
                     public void run() {
-                        proxy.init("shard-1", path);
+                        proxy.init("shard-1");
                     }
 
                 }.start();
@@ -150,14 +150,14 @@ public class DataTreeChangeListenerProxyTest extends AbstractActorTest {
                 ActorContext actorContext = new ActorContext(getSystem(), getRef(), mock(ClusterWrapper.class),
                         mock(Configuration.class));
 
+                final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
                 final DataTreeChangeListenerProxy<DOMDataTreeChangeListener> proxy = new DataTreeChangeListenerProxy<>(
-                        actorContext, mockListener);
+                        actorContext, mockListener, path);
 
-                final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
                 new Thread() {
                     @Override
                     public void run() {
-                        proxy.init("shard-1", path);
+                        proxy.init("shard-1");
                     }
 
                 }.start();
@@ -182,14 +182,14 @@ public class DataTreeChangeListenerProxyTest extends AbstractActorTest {
                 ActorContext actorContext = new ActorContext(getSystem(), getRef(), mock(ClusterWrapper.class),
                         mock(Configuration.class));
 
+                final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
                 final DataTreeChangeListenerProxy<DOMDataTreeChangeListener> proxy = new DataTreeChangeListenerProxy<>(
-                        actorContext, mockListener);
+                        actorContext, mockListener, path);
 
-                final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
                 new Thread() {
                     @Override
                     public void run() {
-                        proxy.init("shard-1", path);
+                        proxy.init("shard-1");
                     }
 
                 }.start();
@@ -226,11 +226,12 @@ public class DataTreeChangeListenerProxyTest extends AbstractActorTest {
                 final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
 
                 doReturn(executor).when(actorContext).getClientDispatcher();
+                doReturn(DatastoreContext.newBuilder().build()).when(actorContext).getDatastoreContext();
                 doReturn(mockActorSystem).when(actorContext).getActorSystem();
 
                 String shardName = "shard-1";
                 final DataTreeChangeListenerProxy<DOMDataTreeChangeListener> proxy = new DataTreeChangeListenerProxy<>(
-                        actorContext, mockListener);
+                        actorContext, mockListener, path);
 
                 doReturn(duration("5 seconds")).when(actorContext).getOperationDuration();
                 doReturn(Futures.successful(getRef())).when(actorContext).findLocalShardAsync(eq(shardName));
@@ -238,7 +239,7 @@ public class DataTreeChangeListenerProxyTest extends AbstractActorTest {
                         .executeOperationAsync(any(ActorRef.class), any(Object.class), any(Timeout.class));
                 doReturn(mock(DatastoreContext.class)).when(actorContext).getDatastoreContext();
 
-                proxy.init("shard-1", path);
+                proxy.init("shard-1");
 
                 Assert.assertEquals("getListenerRegistrationActor", null, proxy.getListenerRegistrationActor());
 
@@ -265,19 +266,19 @@ public class DataTreeChangeListenerProxyTest extends AbstractActorTest {
                 doReturn(Futures.successful(getRef())).when(actorContext).findLocalShardAsync(eq(shardName));
 
                 final DataTreeChangeListenerProxy<DOMDataTreeChangeListener> proxy = new DataTreeChangeListenerProxy<>(
-                        actorContext, mockListener);
+                        actorContext, mockListener, YangInstanceIdentifier.of(TestModel.TEST_QNAME));
 
                 Answer<Future<Object>> answer = invocation -> {
                     proxy.close();
-                    return Futures.successful((Object) new RegisterDataTreeChangeListenerReply(getRef()));
+                    return Futures.successful((Object) new RegisterDataTreeNotificationListenerReply(getRef()));
                 };
 
                 doAnswer(answer).when(actorContext).executeOperationAsync(any(ActorRef.class), any(Object.class),
                         any(Timeout.class));
 
-                proxy.init(shardName, YangInstanceIdentifier.of(TestModel.TEST_QNAME));
+                proxy.init(shardName);
 
-                expectMsgClass(duration("5 seconds"), CloseDataTreeChangeListenerRegistration.class);
+                expectMsgClass(duration("5 seconds"), CloseDataTreeNotificationListenerRegistration.class);
 
                 Assert.assertEquals("getListenerRegistrationActor", null, proxy.getListenerRegistrationActor());
             }