private void assertBackup(final int syncBackups, final int asyncBackups, int expectedResult) throws Exception { final DummyBackupAwareOperation backupAwareOp = makeOperation(syncBackups, asyncBackups); int result = backupHandler.backup(backupAwareOp); assertEquals(expectedResult, result); assertTrueEventually( new AssertTask() { @Override public void run() throws Exception { Integer completed = backupCompletedMap.get(backupAwareOp.backupKey); if (completed == null) { completed = 0; } int totalBackups = min(BACKUPS, syncBackups + asyncBackups); assertEquals(new Integer(totalBackups), completed); } }); }