@Test public void testSuccess() { TestKit kit = new TestKit(getSystem()); List<String> shardList = Arrays.asList("shard1", "shard2", "shard3"); ShardManagerSnapshot shardManagerSnapshot = new ShardManagerSnapshot(shardList, Collections.emptyMap()); ActorRef replyActor = getSystem().actorOf(ShardManagerGetSnapshotReplyActor.props( shardList, "config", shardManagerSnapshot, kit.getRef(), "shard-manager", FiniteDuration.create(100, TimeUnit.SECONDS)), "testSuccess"); kit.watch(replyActor); ByteState shard1SnapshotState = ByteState.of(new byte[]{1,2,3}); replyActor.tell(new GetSnapshotReply(ShardIdentifier.create("shard1", MEMBER_1, "config").toString(), Snapshot.create(shard1SnapshotState, Collections.<ReplicatedLogEntry>emptyList(), 2, 1, 2, 1, 1, "member-1", null)), ActorRef.noSender()); ByteState shard2SnapshotState = ByteState.of(new byte[]{4,5,6}); replyActor.tell(new GetSnapshotReply(ShardIdentifier.create("shard2", MEMBER_1, "config").toString(), Snapshot.create(shard2SnapshotState, Collections.<ReplicatedLogEntry>emptyList(), 2, 1, 2, 1, 1, "member-1", null)), ActorRef.noSender()); kit.expectNoMessage(Duration.ofMillis(500)); ByteState shard3SnapshotState = ByteState.of(new byte[]{7,8,9}); replyActor.tell(new GetSnapshotReply(ShardIdentifier.create("shard3", MEMBER_1, "config").toString(), Snapshot.create(shard3SnapshotState, Collections.<ReplicatedLogEntry>emptyList(), 2, 1, 2, 1, 1, "member-1", null)), ActorRef.noSender()); DatastoreSnapshot datastoreSnapshot = kit.expectMsgClass(DatastoreSnapshot.class); assertEquals("getType", "config", datastoreSnapshot.getType()); assertEquals("getShardManagerSnapshot", shardManagerSnapshot.getShardList(), datastoreSnapshot.getShardManagerSnapshot().getShardList()); List<ShardSnapshot> shardSnapshots = datastoreSnapshot.getShardSnapshots(); assertEquals("ShardSnapshot size", 3, shardSnapshots.size()); assertEquals("ShardSnapshot 1 getName", "shard1", shardSnapshots.get(0).getName()); assertEquals("ShardSnapshot 1 getSnapshot", shard1SnapshotState, shardSnapshots.get(0).getSnapshot().getState()); assertEquals("ShardSnapshot 2 getName", "shard2", shardSnapshots.get(1).getName()); assertEquals("ShardSnapshot 2 getSnapshot", shard2SnapshotState, shardSnapshots.get(1).getSnapshot().getState()); assertEquals("ShardSnapshot 3 getName", "shard3", shardSnapshots.get(2).getName()); assertEquals("ShardSnapshot 3 getSnapshot", shard3SnapshotState, shardSnapshots.get(2).getSnapshot().getState()); kit.expectMsgClass(Terminated.class); }
public static Props props(final Collection<String> shardNames, final String datastoreType, final ShardManagerSnapshot shardManagerSnapshot, final ActorRef replyToActor, final String id, final FiniteDuration receiveTimeout) { return Props.create(ShardManagerGetSnapshotReplyActor.class, new Params(shardNames, datastoreType, shardManagerSnapshot, replyToActor, id, receiveTimeout)); }
ShardManagerGetSnapshotReplyActor extends UntypedAbstractActor { public static Props props(final Collection<String> shardNames, final String datastoreType, final ShardManagerSnapshot shardManagerSnapshot, final ActorRef replyToActor, final String id, final FiniteDuration receiveTimeout) { return Props.create(ShardManagerGetSnapshotReplyActor.class, new Params(shardNames, datastoreType, shardManagerSnapshot, replyToActor, id, receiveTimeout)); } }
ShardManagerGetSnapshotReplyActor extends UntypedAbstractActor { public static Props props(final Collection<String> shardNames, final String datastoreType, final ShardManagerSnapshot shardManagerSnapshot, final ActorRef replyToActor, final String id, final FiniteDuration receiveTimeout) { return Props.create(ShardManagerGetSnapshotReplyActor.class, new Params(shardNames, datastoreType, shardManagerSnapshot, replyToActor, id, receiveTimeout)); } private  ShardManagerGetSnapshotReplyActor(final Params params); }
ShardManagerGetSnapshotReplyActor extends UntypedAbstractActor { public static Props props(final Collection<String> shardNames, final String datastoreType, final ShardManagerSnapshot shardManagerSnapshot, final ActorRef replyToActor, final String id, final FiniteDuration receiveTimeout) { return Props.create(ShardManagerGetSnapshotReplyActor.class, new Params(shardNames, datastoreType, shardManagerSnapshot, replyToActor, id, receiveTimeout)); } private  ShardManagerGetSnapshotReplyActor(final Params params); @Override void onReceive(final Object message); static Props props(final Collection<String> shardNames, final String datastoreType,
            final ShardManagerSnapshot shardManagerSnapshot, final ActorRef replyToActor, final String id,
            final FiniteDuration receiveTimeout); }
ShardManagerGetSnapshotReplyActor extends UntypedAbstractActor { public static Props props(final Collection<String> shardNames, final String datastoreType, final ShardManagerSnapshot shardManagerSnapshot, final ActorRef replyToActor, final String id, final FiniteDuration receiveTimeout) { return Props.create(ShardManagerGetSnapshotReplyActor.class, new Params(shardNames, datastoreType, shardManagerSnapshot, replyToActor, id, receiveTimeout)); } private  ShardManagerGetSnapshotReplyActor(final Params params); @Override void onReceive(final Object message); static Props props(final Collection<String> shardNames, final String datastoreType,
            final ShardManagerSnapshot shardManagerSnapshot, final ActorRef replyToActor, final String id,
            final FiniteDuration receiveTimeout);  }