@Test public void testExecute() throws Throwable { StepEntity[] steps = new StepEntity[]{ createStep("step-1", StepEntity.State.COMPLETED), createDisableStep("step-2", StepEntity.State.QUEUED), createStep("step-3", StepEntity.State.QUEUED) }; TestStepCommand[] stepCommands = new TestStepCommand[steps.length]; TestTaskCommand command = new TestTaskCommand(apiFeXenonRestClient, photonControllerXenonRestClient, hostClient, housekeeperClient, taskBackend, stepCommandFactory, task, deployerClient, deployerXenonClient, housekeeperXenonClient); for (int i = 0; i < steps.length; i++) { StepEntity step = steps[i]; task.addStep(step); stepCommands[i] = new TestStepCommand(command, stepBackend, step); doReturn(stepCommands[i]).when(stepCommandFactory).createCommand(command, step); } command.execute(); assertThat(command.performed, is(true)); assertThat(stepCommands[0].performed, is(false)); assertThat(stepCommands[1].performed, is(false)); assertThat(stepCommands[2].performed, is(true)); }
@Override protected void execute() throws ApiFeException, InterruptedException, RpcException { steps = getTask().getSteps(); for (StepEntity step : steps) { if (!step.getState().equals(StepEntity.State.QUEUED) || step.isDisabled()) { logger.info("Skip running step {}", step); continue; } StepCommand cmd = stepCommandFactory.createCommand(this, step); cmd.run(); if (step.getState() != StepEntity.State.COMPLETED) { throw new TaskNotCompletedException(step); } } }
TaskCommand extends BaseCommand { @Override protected void execute() throws ApiFeException, InterruptedException, RpcException { steps = getTask().getSteps(); for (StepEntity step : steps) { if (!step.getState().equals(StepEntity.State.QUEUED) || step.isDisabled()) { logger.info("Skip running step {}", step); continue; } StepCommand cmd = stepCommandFactory.createCommand(this, step); cmd.run(); if (step.getState() != StepEntity.State.COMPLETED) { throw new TaskNotCompletedException(step); } } } }
TaskCommand extends BaseCommand { @Override protected void execute() throws ApiFeException, InterruptedException, RpcException { steps = getTask().getSteps(); for (StepEntity step : steps) { if (!step.getState().equals(StepEntity.State.QUEUED) || step.isDisabled()) { logger.info("Skip running step {}", step); continue; } StepCommand cmd = stepCommandFactory.createCommand(this, step); cmd.run(); if (step.getState() != StepEntity.State.COMPLETED) { throw new TaskNotCompletedException(step); } } } @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 execute() throws ApiFeException, InterruptedException, RpcException { steps = getTask().getSteps(); for (StepEntity step : steps) { if (!step.getState().equals(StepEntity.State.QUEUED) || step.isDisabled()) { logger.info("Skip running step {}", step); continue; } StepCommand cmd = stepCommandFactory.createCommand(this, step); cmd.run(); if (step.getState() != StepEntity.State.COMPLETED) { throw new TaskNotCompletedException(step); } } } @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 execute() throws ApiFeException, InterruptedException, RpcException { steps = getTask().getSteps(); for (StepEntity step : steps) { if (!step.getState().equals(StepEntity.State.QUEUED) || step.isDisabled()) { logger.info("Skip running step {}", step); continue; } StepCommand cmd = stepCommandFactory.createCommand(this, step); cmd.run(); if (step.getState() != StepEntity.State.COMPLETED) { throw new TaskNotCompletedException(step); } } } @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);  }