DataTreeNotificationListenerRegistrationActor extends AbstractUntypedActor { public static Props props() { return Props.create(DataTreeNotificationListenerRegistrationActor.class); }  static Props props();  }
@Test public void testOnReceiveCloseListenerRegistrationAfterSetRegistration() { final ActorRef subject = getSystem().actorOf(DataTreeNotificationListenerRegistrationActor.props(), "testOnReceiveCloseListenerRegistrationAfterSetRegistration"); kit.watch(subject); subject.tell(new DataTreeNotificationListenerRegistrationActor.SetRegistration(mockListenerReg, mockOnClose), ActorRef.noSender()); subject.tell(CloseDataTreeNotificationListenerRegistration.getInstance(), kit.getRef()); kit.expectMsgClass(Duration.ofSeconds(5), CloseDataTreeNotificationListenerRegistrationReply.class); verify(mockListenerReg, timeout(5000)).close(); verify(mockOnClose, timeout(5000)).run(); kit.expectTerminated(Duration.ofSeconds(5), subject); }
@Test public void testOnReceiveCloseListenerRegistrationBeforeSetRegistration() { final ActorRef subject = getSystem().actorOf(DataTreeNotificationListenerRegistrationActor.props(), "testOnReceiveSetRegistrationAfterPriorClose"); kit.watch(subject); subject.tell(CloseDataTreeNotificationListenerRegistration.getInstance(), kit.getRef()); kit.expectMsgClass(Duration.ofSeconds(5), CloseDataTreeNotificationListenerRegistrationReply.class); subject.tell(new DataTreeNotificationListenerRegistrationActor.SetRegistration(mockListenerReg, mockOnClose), ActorRef.noSender()); verify(mockListenerReg, timeout(5000)).close(); verify(mockOnClose, timeout(5000)).run(); kit.expectTerminated(Duration.ofSeconds(5), subject); }
@Test public void testOnReceiveSetRegistrationAfterPriorClose() { DataTreeNotificationListenerRegistrationActor.killDelay = 1000; final ListenerRegistration<?> mockListenerReg2 = mock(ListenerRegistration.class); final Runnable mockOnClose2 = mock(Runnable.class); final ActorRef subject = getSystem().actorOf(DataTreeNotificationListenerRegistrationActor.props(), "testOnReceiveSetRegistrationAfterPriorClose"); kit.watch(subject); subject.tell(new DataTreeNotificationListenerRegistrationActor.SetRegistration(mockListenerReg, mockOnClose), ActorRef.noSender()); subject.tell(CloseDataTreeNotificationListenerRegistration.getInstance(), ActorRef.noSender()); subject.tell(new DataTreeNotificationListenerRegistrationActor.SetRegistration(mockListenerReg2, mockOnClose2), ActorRef.noSender()); verify(mockListenerReg, timeout(5000)).close(); verify(mockOnClose, timeout(5000)).run(); verify(mockListenerReg2, timeout(5000)).close(); verify(mockOnClose2, timeout(5000)).run(); kit.expectTerminated(Duration.ofSeconds(5), subject); }