@Test
public void testDelayedEntityOwnerSelectionWhenMaxPeerRequestsReceived() {

    testLog.info("testDelayedEntityOwnerSelectionWhenMaxPeerRequestsReceived starting");
    ShardTestKit kit = new ShardTestKit(getSystem());
    EntityOwnerSelectionStrategyConfig.Builder builder = EntityOwnerSelectionStrategyConfig.newBuilder()
            .addStrategy(ENTITY_TYPE, LastCandidateSelectionStrategy.class, 500);
    ShardIdentifier leaderId = newShardId(LOCAL_MEMBER_NAME);
    ShardIdentifier peerId = newShardId(PEER_MEMBER_1_NAME);
    TestActorRef<TestEntityOwnershipShard> peer = actorFactory.createTestActor(TestEntityOwnershipShard.props(
            newShardBuilder(peerId, peerMap(leaderId.toString()), PEER_MEMBER_1_NAME)), peerId.toString());
    peer.underlyingActor().startDroppingMessagesOfType(ElectionTimeout.class);
    TestActorRef<EntityOwnershipShard> leader = actorFactory.createTestActor(
            newShardProps(leaderId, peerMap(peerId.toString()), LOCAL_MEMBER_NAME, builder.build()),
            leaderId.toString());
    ShardTestKit.waitUntilLeader(leader);
    DOMEntity entity = new DOMEntity(ENTITY_TYPE, ENTITY_ID1);
    // Add a remote candidate
    peer.tell(new RegisterCandidateLocal(entity), kit.getRef());
    kit.expectMsgClass(SuccessReply.class);
    // Register local
    leader.tell(new RegisterCandidateLocal(entity), kit.getRef());
    kit.expectMsgClass(SuccessReply.class);
    // Verify the local candidate becomes owner
    verifyCommittedEntityCandidate(leader, entity.getType(), entity.getIdentifier(), PEER_MEMBER_1_NAME);
    verifyCommittedEntityCandidate(leader, entity.getType(), entity.getIdentifier(), LOCAL_MEMBER_NAME);
    verifyOwner(leader, entity.getType(), entity.getIdentifier(), LOCAL_MEMBER_NAME);
    testLog.info("testDelayedEntityOwnerSelectionWhenMaxPeerRequestsReceived ending");
}