-
- shard.tell(PoisonPill.getInstance(), ActorRef.noSender());
- }
-
- @Test
- public void testApplyStateWithCandidatePayload() throws Exception {
-
- ShardTestKit testkit = new ShardTestKit(getSystem());
-
- final TestActorRef<Shard> shard = TestActorRef.create(getSystem(), newShardProps(), "testApplyState");
-
- testkit.waitUntilLeader(shard);
-
- final NormalizedNode<?, ?> node = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
- final DataTreeCandidate candidate = DataTreeCandidates.fromNormalizedNode(TestModel.TEST_PATH, node);
-
- final ApplyState applyState = new ApplyState(null, "test", new ReplicatedLogImplEntry(1, 2,
- DataTreeCandidatePayload.create(candidate)));
-
- shard.underlyingActor().onReceiveCommand(applyState);
-
- final NormalizedNode<?,?> actual = readStore(shard, TestModel.TEST_PATH);
- assertEquals("Applied state", node, actual);
-
- shard.tell(PoisonPill.getInstance(), ActorRef.noSender());
- }
-
- DataTree setupInMemorySnapshotStore() throws DataValidationFailedException {
- final DataTree testStore = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL);
- testStore.setSchemaContext(SCHEMA_CONTEXT);
-
- writeToStore(testStore, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
-
- final NormalizedNode<?, ?> root = readStore(testStore, YangInstanceIdentifier.builder().build());
-
- InMemorySnapshotStore.addSnapshot(shardID.toString(), Snapshot.create(
- SerializationUtils.serializeNormalizedNode(root),
- Collections.<ReplicatedLogEntry>emptyList(), 0, 1, -1, -1));
- return testStore;
- }
-
- private static DataTreeCandidatePayload payloadForModification(final DataTree source, final DataTreeModification mod) throws DataValidationFailedException {
- source.validate(mod);
- final DataTreeCandidate candidate = source.prepare(mod);
- source.commit(candidate);
- return DataTreeCandidatePayload.create(candidate);