@Test public void testGetRequestStatusResponse() { ActionManager actionManager = createStrictMock(ActionManager.class); Stage stage1 = createNiceMock(Stage.class); Stage stage2 = createNiceMock(Stage.class); HostRoleCommand command1 = createNiceMock(HostRoleCommand.class); Role role = createNiceMock(Role.class); List<Stage> stages = new ArrayList<Stage>(); RoleCommand roleCommand = RoleCommand.INSTALL; HostRoleStatus status = HostRoleStatus.IN_PROGRESS; stages.add(stage1); stages.add(stage2); List<HostRoleCommand> hostRoleCommands = new ArrayList<HostRoleCommand>(); hostRoleCommands.add(command1); expect(actionManager.getRequestTasks(100)).andReturn(hostRoleCommands); expect(actionManager.getRequestContext(100)).andReturn("test"); expect(command1.getTaskId()).andReturn(1L); expect(command1.getRoleCommand()).andReturn(roleCommand); expect(command1.getRole()).andReturn(role); expect(command1.getStatus()).andReturn(status); replay(actionManager, stage1, stage2, command1, role); RequestStageContainer requestStages = new RequestStageContainer(100L, stages, null, actionManager); RequestStatusResponse response = requestStages.getRequestStatusResponse(); assertEquals(100, response.getRequestId()); List<ShortTaskStatus> tasks = response.getTasks(); assertEquals(1, tasks.size()); ShortTaskStatus task = tasks.get(0); assertEquals(1, task.getTaskId()); assertEquals(roleCommand.toString(), task.getCommand()); assertEquals(status.toString(), task.getStatus()); assertEquals("test", response.getRequestContext()); verify(actionManager, stage1, stage2, command1, role); }
public RequestStatusResponse getRequestStatusResponse() { RequestStatusResponse response = null; if (! stages.isEmpty()) { response = new RequestStatusResponse(id); List<HostRoleCommand> hostRoleCommands = actionManager.getRequestTasks(id); response.setRequestContext(actionManager.getRequestContext(id)); List<ShortTaskStatus> tasks = new ArrayList<ShortTaskStatus>(); for (HostRoleCommand hostRoleCommand : hostRoleCommands) { tasks.add(new ShortTaskStatus(hostRoleCommand)); } response.setTasks(tasks); } return response; }
RequestStageContainer { public RequestStatusResponse getRequestStatusResponse() { RequestStatusResponse response = null; if (! stages.isEmpty()) { response = new RequestStatusResponse(id); List<HostRoleCommand> hostRoleCommands = actionManager.getRequestTasks(id); response.setRequestContext(actionManager.getRequestContext(id)); List<ShortTaskStatus> tasks = new ArrayList<ShortTaskStatus>(); for (HostRoleCommand hostRoleCommand : hostRoleCommands) { tasks.add(new ShortTaskStatus(hostRoleCommand)); } response.setTasks(tasks); } return response; } }
RequestStageContainer { public RequestStatusResponse getRequestStatusResponse() { RequestStatusResponse response = null; if (! stages.isEmpty()) { response = new RequestStatusResponse(id); List<HostRoleCommand> hostRoleCommands = actionManager.getRequestTasks(id); response.setRequestContext(actionManager.getRequestContext(id)); List<ShortTaskStatus> tasks = new ArrayList<ShortTaskStatus>(); for (HostRoleCommand hostRoleCommand : hostRoleCommands) { tasks.add(new ShortTaskStatus(hostRoleCommand)); } response.setTasks(tasks); } return response; } RequestStageContainer(Long id, List<Stage> stages, RequestFactory factory, ActionManager manager);  RequestStageContainer(Long id, List<Stage> stages, RequestFactory factory, ActionManager manager,
                               ExecuteActionRequest actionRequest); }
RequestStageContainer { public RequestStatusResponse getRequestStatusResponse() { RequestStatusResponse response = null; if (! stages.isEmpty()) { response = new RequestStatusResponse(id); List<HostRoleCommand> hostRoleCommands = actionManager.getRequestTasks(id); response.setRequestContext(actionManager.getRequestContext(id)); List<ShortTaskStatus> tasks = new ArrayList<ShortTaskStatus>(); for (HostRoleCommand hostRoleCommand : hostRoleCommands) { tasks.add(new ShortTaskStatus(hostRoleCommand)); } response.setTasks(tasks); } return response; } RequestStageContainer(Long id, List<Stage> stages, RequestFactory factory, ActionManager manager);  RequestStageContainer(Long id, List<Stage> stages, RequestFactory factory, ActionManager manager,
                               ExecuteActionRequest actionRequest); Long getId(); void addStages(List<Stage> stages); List<Stage> getStages(); long getLastStageId(); void setRequestContext(String context); State getProjectedState(String host, String component); void persist(); RequestStatusResponse getRequestStatusResponse(); }
RequestStageContainer { public RequestStatusResponse getRequestStatusResponse() { RequestStatusResponse response = null; if (! stages.isEmpty()) { response = new RequestStatusResponse(id); List<HostRoleCommand> hostRoleCommands = actionManager.getRequestTasks(id); response.setRequestContext(actionManager.getRequestContext(id)); List<ShortTaskStatus> tasks = new ArrayList<ShortTaskStatus>(); for (HostRoleCommand hostRoleCommand : hostRoleCommands) { tasks.add(new ShortTaskStatus(hostRoleCommand)); } response.setTasks(tasks); } return response; } RequestStageContainer(Long id, List<Stage> stages, RequestFactory factory, ActionManager manager);  RequestStageContainer(Long id, List<Stage> stages, RequestFactory factory, ActionManager manager,
                               ExecuteActionRequest actionRequest); Long getId(); void addStages(List<Stage> stages); List<Stage> getStages(); long getLastStageId(); void setRequestContext(String context); State getProjectedState(String host, String component); void persist(); RequestStatusResponse getRequestStatusResponse();  }