@Test
public void testReadyLocalTransactionWithThreePhaseCommit() {

    final ShardTestKit testKit = new ShardTestKit(getSystem());
    final TestActorRef<Shard> shard = actorFactory.createTestActor(
        newShardProps().withDispatcher(Dispatchers.DefaultDispatcherId()),
        "testReadyLocalTransactionWithThreePhaseCommit");
    ShardTestKit.waitUntilLeader(shard);
    final ShardDataTree dataStore = shard.underlyingActor().getDataStore();
    final DataTreeModification modification = dataStore.newModification();
    final ContainerNode writeData = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
    new WriteModification(TestModel.TEST_PATH, writeData).apply(modification);
    final MapNode mergeData = ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
            .addChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 42))
            .build();
    new MergeModification(TestModel.OUTER_LIST_PATH, mergeData).apply(modification);
    final TransactionIdentifier txId = nextTransactionId();
    modification.ready();
    final ReadyLocalTransaction readyMessage =
            new ReadyLocalTransaction(txId, modification, false, Optional.empty());
    shard.tell(readyMessage, testKit.getRef());
    testKit.expectMsgClass(ReadyTransactionReply.class);
    // Send the CanCommitTransaction message.
    shard.tell(new CanCommitTransaction(txId, CURRENT_VERSION).toSerializable(), testKit.getRef());
    final CanCommitTransactionReply canCommitReply = CanCommitTransactionReply
            .fromSerializable(testKit.expectMsgClass(CanCommitTransactionReply.class));
    assertTrue("Can commit", canCommitReply.getCanCommit());
    // Send the CanCommitTransaction message.
    shard.tell(new CommitTransaction(txId, CURRENT_VERSION).toSerializable(), testKit.getRef());
    testKit.expectMsgClass(CommitTransactionReply.class);
    final NormalizedNode<?, ?> actualNode = readStore(shard, TestModel.OUTER_LIST_PATH);
    assertEquals(TestModel.OUTER_LIST_QNAME.getLocalName(), mergeData, actualNode);
}