}
private TaskExecTO execSyncTask(final Long taskId, final int maxWaitSeconds,
final boolean dryRun) {
TaskTO taskTO = taskService.read(TaskType.SYNCHRONIZATION, taskId);
assertNotNull(taskTO);
assertNotNull(taskTO.getExecutions());
int preSyncSize = taskTO.getExecutions().size();
TaskExecTO execution = taskService.execute(taskTO.getId(), dryRun);
assertEquals("JOB_FIRED", execution.getStatus());
int i = 0;
int maxit = maxWaitSeconds;
// wait for sync completion (executions incremented)
do {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
}
taskTO = taskService.read(TaskType.SYNCHRONIZATION, taskTO.getId());
assertNotNull(taskTO);
assertNotNull(taskTO.getExecutions());
i++;
} while (preSyncSize == taskTO.getExecutions().size() && i < maxit);
if (i == maxit) {
fail("Timeout when executing task " + taskId);
}
return taskTO.getExecutions().get(0);
}