+
+ @Test
+ public void testOnSnapshotOfferWithServerConfiguration() {
+ long electionTerm = 2;
+ String electionVotedFor = "member-2";
+ ServerConfigurationPayload serverPayload = new ServerConfigurationPayload(Arrays.asList(
+ new ServerInfo(localId, true),
+ new ServerInfo("follower1", true),
+ new ServerInfo("follower2", true)));
+
+ MockSnapshotState snapshotState = new MockSnapshotState(Arrays.asList(new MockPayload("1")));
+ Snapshot snapshot = Snapshot.create(snapshotState, Collections.<ReplicatedLogEntry>emptyList(),
+ -1, -1, -1, -1, electionTerm, electionVotedFor, serverPayload);
+
+ SnapshotMetadata metadata = new SnapshotMetadata("test", 6, 12345);
+ SnapshotOffer snapshotOffer = new SnapshotOffer(metadata , snapshot);
+
+ sendMessageToSupport(snapshotOffer);
+
+ assertEquals("Journal log size", 0, context.getReplicatedLog().size());
+ assertEquals("Election term", electionTerm, context.getTermInformation().getCurrentTerm());
+ assertEquals("Election votedFor", electionVotedFor, context.getTermInformation().getVotedFor());
+ assertTrue("Dynamic server configuration", context.isDynamicServerConfigurationInUse());
+ assertEquals("Peer List", Sets.newHashSet("follower1", "follower2"),
+ Sets.newHashSet(context.getPeerIds()));
+ }