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 failed replication event for slaveA
dispatcher.gerritEvent(Setup.createRefReplicatedEvent("someProject", "refs/changes/1/1/1", "someGerritServer",
"slaveA", RefReplicated.FAILED_STATUS));
//send replication event for slaveC
dispatcher.gerritEvent(Setup.createRefReplicatedEvent("someProject", "refs/changes/1/1/1", "someGerritServer",
"slaveC", RefReplicated.SUCCEEDED_STATUS));
assertNotNull("the item should be blocked", cause);
assertTrue("Should have returned a WaitingForReplication as CauseOfBlockage",
cause instanceof WaitingForReplication);
assertTrue(cause.getShortDescription().contains("slaveA"));
//send success replication event for slaveA
dispatcher.gerritEvent(Setup.createRefReplicatedEvent("someProject", "refs/changes/1/1/1", "someGerritServer",
"slaveA", RefReplicated.SUCCEEDED_STATUS));