ReconnectActor extends AbstractActor { public static Props props(final ActorRef connectionShardRegion, final MongoReadJournal readJournal) { return Props.create(ReconnectActor.class, connectionShardRegion, readJournal); } @SuppressWarnings("unused") private  ReconnectActor(final ActorRef connectionShardRegion,
            final Supplier<Source<String, NotUsed>> currentPersistenceIdsSourceSupplier); @SuppressWarnings("unused") private  ReconnectActor(final ActorRef connectionShardRegion, final MongoReadJournal readJournal); static Props props(final ActorRef connectionShardRegion, final MongoReadJournal readJournal); @Override void preStart(); @Override void postStop(); @Override Receive createReceive(); static final String ACTOR_NAME; }
@Test public void testRecoverConnections() { new TestKit(actorSystem) {{ final TestProbe probe = new TestProbe(actorSystem); final ConnectionId connectionId1 = ConnectionId.of("connection-1"); final ConnectionId connectionId2 = ConnectionId.of("connection-2"); final ConnectionId connectionId3 = ConnectionId.of("connection-3"); final Props props = ReconnectActor.props(probe.ref(), () -> Source.from(Arrays.asList( ConnectionPersistenceActor.PERSISTENCE_ID_PREFIX + connectionId1, "invalid:" + connectionId2, ConnectionPersistenceActor.PERSISTENCE_ID_PREFIX + connectionId3))); actorSystem.actorOf(props); final RetrieveConnectionStatus msg1 = probe.expectMsgClass(RetrieveConnectionStatus.class); assertThat((CharSequence) msg1.getConnectionEntityId()).isEqualTo(connectionId1); final RetrieveConnectionStatus msg2 = probe.expectMsgClass(RetrieveConnectionStatus.class); assertThat((CharSequence) msg2.getConnectionEntityId()).isEqualTo(connectionId3); }}; }
@Test public void testRecoverConnectionsIsNotStartedTwice() { new TestKit(actorSystem) {{ final TestProbe probe = new TestProbe(actorSystem); final Props props = ReconnectActor.props(probe.ref(), () -> Source.from(Arrays.asList( ConnectionPersistenceActor.PERSISTENCE_ID_PREFIX + "connection-1", ConnectionPersistenceActor.PERSISTENCE_ID_PREFIX + "connection-2", ConnectionPersistenceActor.PERSISTENCE_ID_PREFIX + "connection-3"))); final ActorRef reconnectActor = actorSystem.actorOf(props); reconnectActor.tell(ReconnectActor.ReconnectMessages.START_RECONNECT, getRef()); probe.expectMsgClass(RetrieveConnectionStatus.class); probe.expectMsgClass(RetrieveConnectionStatus.class); probe.expectMsgClass(RetrieveConnectionStatus.class); probe.expectNoMessage(); }}; }