@Test(dataProvider = "steps") public void testMarkAsDone(StepEntity[] steps, TaskEntity.State state) throws Exception { TestTaskCommand command = new TestTaskCommand(apiFeXenonRestClient, photonControllerXenonRestClient, hostClient, housekeeperClient, taskBackend, stepCommandFactory, task, deployerClient, deployerXenonClient, housekeeperXenonClient); for (StepEntity step : steps) { task.addStep(step); doReturn(new TestStepCommand(command, stepBackend, step)) .when(stepCommandFactory).createCommand(command, step); } command.markAsDone(); TaskEntity found = taskBackend.findById(task.getId()); assertThat(found, notNullValue()); assertThat(found.getState(), is(state)); }
@Override protected void markAsDone() throws TaskNotFoundException { entityLockBackend.clearTaskLocks(task); for (StepEntity step : getTask().getSteps()) { if (!step.getState().equals(StepEntity.State.COMPLETED)) { logger.info("Step {} is incomplete. Skip marking task {} as done", step, task.getId()); return; } } taskBackend.markTaskAsDone(task); }
TaskCommand extends BaseCommand { @Override protected void markAsDone() throws TaskNotFoundException { entityLockBackend.clearTaskLocks(task); for (StepEntity step : getTask().getSteps()) { if (!step.getState().equals(StepEntity.State.COMPLETED)) { logger.info("Step {} is incomplete. Skip marking task {} as done", step, task.getId()); return; } } taskBackend.markTaskAsDone(task); } }
TaskCommand extends BaseCommand { @Override protected void markAsDone() throws TaskNotFoundException { entityLockBackend.clearTaskLocks(task); for (StepEntity step : getTask().getSteps()) { if (!step.getState().equals(StepEntity.State.COMPLETED)) { logger.info("Step {} is incomplete. Skip marking task {} as done", step, task.getId()); return; } } taskBackend.markTaskAsDone(task); } @Inject  TaskCommand(
      ApiFeXenonRestClient xenonClient,
      PhotonControllerXenonRestClient photonControllerXenonRestClient,
      HostClient hostClient,
      HousekeeperClient housekeeperClient,
      DeployerClient deployerClient,
      com.vmware.photon.controller.api.frontend.backends.clients.DeployerClient deployerXenonClient,
      com.vmware.photon.controller.api.frontend.backends.clients.HousekeeperClient housekeeperXenonClient,
      EntityLockBackend entityLockBackend,
      @Assisted TaskEntity task); }
TaskCommand extends BaseCommand { @Override protected void markAsDone() throws TaskNotFoundException { entityLockBackend.clearTaskLocks(task); for (StepEntity step : getTask().getSteps()) { if (!step.getState().equals(StepEntity.State.COMPLETED)) { logger.info("Step {} is incomplete. Skip marking task {} as done", step, task.getId()); return; } } taskBackend.markTaskAsDone(task); } @Inject  TaskCommand(
      ApiFeXenonRestClient xenonClient,
      PhotonControllerXenonRestClient photonControllerXenonRestClient,
      HostClient hostClient,
      HousekeeperClient housekeeperClient,
      DeployerClient deployerClient,
      com.vmware.photon.controller.api.frontend.backends.clients.DeployerClient deployerXenonClient,
      com.vmware.photon.controller.api.frontend.backends.clients.HousekeeperClient housekeeperXenonClient,
      EntityLockBackend entityLockBackend,
      @Assisted TaskEntity task); void markAllStepsAsFailed(Throwable t); TaskEntity getTask(); Resource getResource(); void setResource(Resource resource); String getReservation(); void setReservation(String reservation); HostClient getHostClient(); ApiFeXenonRestClient getApiFeXenonRestClient(); PhotonControllerXenonRestClient getPhotonControllerXenonRestClient(); HousekeeperClient getHousekeeperClient(); com.vmware.photon.controller.api.frontend.backends.clients.HousekeeperClient getHousekeeperXenonClient(); DeployerClient getDeployerClient(); com.vmware.photon.controller.api.frontend.backends.clients.DeployerClient getDeployerXenonClient(); HostClient getHostClient(VmEntity vm); HostClient getHostClient(VmEntity vm, boolean useCachedHostInfo); HostClient findHost(BaseDiskEntity disk); String lookupAgentId(String hostIp); }
TaskCommand extends BaseCommand { @Override protected void markAsDone() throws TaskNotFoundException { entityLockBackend.clearTaskLocks(task); for (StepEntity step : getTask().getSteps()) { if (!step.getState().equals(StepEntity.State.COMPLETED)) { logger.info("Step {} is incomplete. Skip marking task {} as done", step, task.getId()); return; } } taskBackend.markTaskAsDone(task); } @Inject  TaskCommand(
      ApiFeXenonRestClient xenonClient,
      PhotonControllerXenonRestClient photonControllerXenonRestClient,
      HostClient hostClient,
      HousekeeperClient housekeeperClient,
      DeployerClient deployerClient,
      com.vmware.photon.controller.api.frontend.backends.clients.DeployerClient deployerXenonClient,
      com.vmware.photon.controller.api.frontend.backends.clients.HousekeeperClient housekeeperXenonClient,
      EntityLockBackend entityLockBackend,
      @Assisted TaskEntity task); void markAllStepsAsFailed(Throwable t); TaskEntity getTask(); Resource getResource(); void setResource(Resource resource); String getReservation(); void setReservation(String reservation); HostClient getHostClient(); ApiFeXenonRestClient getApiFeXenonRestClient(); PhotonControllerXenonRestClient getPhotonControllerXenonRestClient(); HousekeeperClient getHousekeeperClient(); com.vmware.photon.controller.api.frontend.backends.clients.HousekeeperClient getHousekeeperXenonClient(); DeployerClient getDeployerClient(); com.vmware.photon.controller.api.frontend.backends.clients.DeployerClient getDeployerXenonClient(); HostClient getHostClient(VmEntity vm); HostClient getHostClient(VmEntity vm, boolean useCachedHostInfo); HostClient findHost(BaseDiskEntity disk); String lookupAgentId(String hostIp);  }