SystemResumeStepCmd extends StepCommand { @Override protected void execute() throws ApiFeException, InterruptedException, RpcException { try { logger.info("Resuming APIFE service..."); DeploymentService.State state = new DeploymentService.State(); state.state = DeploymentState.READY; state.documentSelfLink = DeploymentServiceFactory.SELF_LINK + "/" + deploymentId; com.vmware.xenon.common.Operation operation = taskCommand.getApiFeXenonRestClient().patch(state.documentSelfLink, state, EnumSet.of(XenonClient.HeaderOption.HEADER_OPTION_FULL_QUORUM)); logger.info("Resumed APIFE service..."); } catch (DocumentNotFoundException ex) { throw new InternalException(ex); } } SystemResumeStepCmd(TaskCommand taskCommand,
                             StepBackend stepBackend,
                             StepEntity step
                             );  static final String DEPLOYMENT_ID_RESOURCE_KEY; }
@Test public void testSuccessAlreadyReadyState() throws Throwable { command.execute(); DeploymentEntity deploymentEntity = deploymentBackend.findById(initialDeploymentEntity.getId()); assertEquals(deploymentEntity.getState(), DeploymentState.READY); }
@Test public void testSuccessPausedState() throws Throwable { SystemPauseStepCmd pCommand = spy(new SystemPauseStepCmd(taskCommand, stepBackend, step)); pCommand.execute(); DeploymentEntity deploymentEntity = deploymentBackend.findById(initialDeploymentEntity.getId()); assertEquals(deploymentEntity.getState(), DeploymentState.PAUSED); command.execute(); deploymentEntity = deploymentBackend.findById(initialDeploymentEntity.getId()); assertEquals(deploymentEntity.getState(), DeploymentState.READY); }
@Test public void testSuccessBackgroudPausedState() throws Throwable { SystemPauseBackgroundTasksStepCmd bpCommand = spy(new SystemPauseBackgroundTasksStepCmd(taskCommand, stepBackend, step)); bpCommand.execute(); DeploymentEntity deploymentEntity = deploymentBackend.findById(initialDeploymentEntity.getId()); assertEquals(deploymentEntity.getState(), DeploymentState.BACKGROUND_PAUSED); command.execute(); deploymentEntity = deploymentBackend.findById(initialDeploymentEntity.getId()); assertEquals(deploymentEntity.getState(), DeploymentState.READY); }
@Test(expectedExceptions = InternalException.class) public void testError() throws Throwable { step = new StepEntity(); step.setId("step-1"); command = spy(new SystemResumeStepCmd(taskCommand, stepBackend, step)); command.execute(); }