+
+ private static void assertSnapshotEquals(final String prefix, final Snapshot expected, final Snapshot actual) {
+ assertEquals(prefix + " lastIndex", expected.getLastIndex(), actual.getLastIndex());
+ assertEquals(prefix + " lastTerm", expected.getLastTerm(), actual.getLastTerm());
+ assertEquals(prefix + " lastAppliedIndex", expected.getLastAppliedIndex(), actual.getLastAppliedIndex());
+ assertEquals(prefix + " lastAppliedTerm", expected.getLastAppliedTerm(), actual.getLastAppliedTerm());
+ assertEquals(prefix + " unAppliedEntries", expected.getUnAppliedEntries(), actual.getUnAppliedEntries());
+ assertEquals(prefix + " electionTerm", expected.getElectionTerm(), actual.getElectionTerm());
+ assertEquals(prefix + " electionVotedFor", expected.getElectionVotedFor(), actual.getElectionVotedFor());
+ assertEquals(prefix + " Root node", ((ShardSnapshotState)expected.getState()).getSnapshot().getRootNode(),
+ ((ShardSnapshotState)actual.getState()).getSnapshot().getRootNode());
+ }
+
+ private static ShardManagerSnapshot newShardManagerSnapshot(final String... shards) {
+ return new ShardManagerSnapshot(Arrays.asList(shards), Collections.emptyMap());
+ }
+
+ private static Snapshot newSnapshot(final YangInstanceIdentifier path, final NormalizedNode<?, ?> node)
+ throws Exception {
+ DataTree dataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL,
+ SchemaContextHelper.full());
+ AbstractShardTest.writeToStore(dataTree, path, node);
+ NormalizedNode<?, ?> root = AbstractShardTest.readStore(dataTree, YangInstanceIdentifier.empty());
+
+ return Snapshot.create(new ShardSnapshotState(new MetadataShardDataTreeSnapshot(root)),
+ Collections.<ReplicatedLogEntry>emptyList(), 2, 1, 2, 1, 1, "member-1", null);
+ }