@Override
      public Object answer(InvocationOnMock invocation) throws Throwable {
        Long taskId = (Long) invocation.getArguments()[0];
        for (Stage stage : stages) {
          for (HostRoleCommand command : stage.getOrderedHostRoleCommands()) {
            if (taskId.equals(command.getTaskId())) {
              return command;
            }
          }
        }
        return null;
      }
Verifies that ActionScheduler allows to execute background tasks in parallel
ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java