*/
@Test
public void shouldBlockItemUntilPatchsetIsReplicatedToAllSlaves() {
PatchsetCreated patchsetCreated = Setup.createPatchsetCreated("someGerritServer", "someProject",
"refs/changes/1/1/1");
Item item = createItem(patchsetCreated, new String[] {"slaveA", "slaveB", "slaveC"});
//item is blocked
CauseOfBlockage cause = dispatcher.canRun(item);
assertNotNull("the item should be blocked", cause);
assertTrue("Should have returned a WaitingForReplication as CauseOfBlockage",
cause instanceof WaitingForReplication);
assertTrue(cause.getShortDescription().contains("slaveA"));
assertTrue(cause.getShortDescription().contains("slaveB"));
assertTrue(cause.getShortDescription().contains("slaveC"));
//send replication event for slaveB
dispatcher.gerritEvent(Setup.createRefReplicatedEvent("someProject", "refs/changes/1/1/1", "someGerritServer",
"slaveB", RefReplicated.SUCCEEDED_STATUS));
//item is still blocked
cause = dispatcher.canRun(item);
assertNotNull("the item should be blocked", cause);
assertTrue("Should have returned a WaitingForReplication as CauseOfBlockage",
cause instanceof WaitingForReplication);
assertTrue(cause.getShortDescription().contains("slaveA"));
assertFalse(cause.getShortDescription().contains("slaveB"));
assertTrue(cause.getShortDescription().contains("slaveC"));
//send replication event for slaveA
dispatcher.gerritEvent(Setup.createRefReplicatedEvent("someProject", "refs/changes/1/1/1", "someGerritServer",
"slaveA", RefReplicated.SUCCEEDED_STATUS));
//item is still blocked
cause = dispatcher.canRun(item);
assertNotNull("the item should be blocked", cause);
assertTrue("Should have returned a WaitingForReplication as CauseOfBlockage",
cause instanceof WaitingForReplication);
assertFalse(cause.getShortDescription().contains("slaveA"));
assertFalse(cause.getShortDescription().contains("slaveB"));
assertTrue(cause.getShortDescription().contains("slaveC"));
//send replication event for slaveC
dispatcher.gerritEvent(Setup.createRefReplicatedEvent("someProject", "refs/changes/1/1/1", "someGerritServer",
"slaveC", RefReplicated.SUCCEEDED_STATUS));
assertNull("Item should not be blocked", dispatcher.canRun(item));
assertNull("Item should not be tagged with replicationFailedAction",
item.getAction(ReplicationFailedAction.class));
verify(queueMock, times(1)).maintain();
}