@Test public void testPersist() throws AmbariException { ActionManager actionManager = createStrictMock(ActionManager.class); RequestFactory requestFactory = createStrictMock(RequestFactory.class); Request request = createStrictMock(Request.class); Stage stage1 = createNiceMock(Stage.class); Stage stage2 = createNiceMock(Stage.class); List<Stage> stages = new ArrayList<Stage>(); stages.add(stage1); stages.add(stage2); expect(requestFactory.createNewFromStages(stages)).andReturn(request); expect(request.getStages()).andReturn(stages).anyTimes(); actionManager.sendActions(request, null); replay(actionManager, requestFactory, request, stage1, stage2); RequestStageContainer requestStages = new RequestStageContainer(1L, stages, requestFactory, actionManager); requestStages.persist(); verify(actionManager, requestFactory, request, stage1, stage2); }
public void persist() throws AmbariException { if (!stages.isEmpty()) { Request request = (null == actionRequest) ? requestFactory.createNewFromStages(stages) : requestFactory.createNewFromStages(stages, actionRequest); if (null != requestContext) { request.setRequestContext(requestContext); } if (request != null && request.getStages()!= null && !request.getStages().isEmpty()) { if (LOG.isDebugEnabled()) { LOG.debug(String.format("Triggering Action Manager, request=%s", request)); } actionManager.sendActions(request, actionRequest); } } }
RequestStageContainer { public void persist() throws AmbariException { if (!stages.isEmpty()) { Request request = (null == actionRequest) ? requestFactory.createNewFromStages(stages) : requestFactory.createNewFromStages(stages, actionRequest); if (null != requestContext) { request.setRequestContext(requestContext); } if (request != null && request.getStages()!= null && !request.getStages().isEmpty()) { if (LOG.isDebugEnabled()) { LOG.debug(String.format("Triggering Action Manager, request=%s", request)); } actionManager.sendActions(request, actionRequest); } } } }
RequestStageContainer { public void persist() throws AmbariException { if (!stages.isEmpty()) { Request request = (null == actionRequest) ? requestFactory.createNewFromStages(stages) : requestFactory.createNewFromStages(stages, actionRequest); if (null != requestContext) { request.setRequestContext(requestContext); } if (request != null && request.getStages()!= null && !request.getStages().isEmpty()) { if (LOG.isDebugEnabled()) { LOG.debug(String.format("Triggering Action Manager, request=%s", request)); } actionManager.sendActions(request, actionRequest); } } } RequestStageContainer(Long id, List<Stage> stages, RequestFactory factory, ActionManager manager);  RequestStageContainer(Long id, List<Stage> stages, RequestFactory factory, ActionManager manager,
                               ExecuteActionRequest actionRequest); }
RequestStageContainer { public void persist() throws AmbariException { if (!stages.isEmpty()) { Request request = (null == actionRequest) ? requestFactory.createNewFromStages(stages) : requestFactory.createNewFromStages(stages, actionRequest); if (null != requestContext) { request.setRequestContext(requestContext); } if (request != null && request.getStages()!= null && !request.getStages().isEmpty()) { if (LOG.isDebugEnabled()) { LOG.debug(String.format("Triggering Action Manager, request=%s", request)); } actionManager.sendActions(request, actionRequest); } } } 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 void persist() throws AmbariException { if (!stages.isEmpty()) { Request request = (null == actionRequest) ? requestFactory.createNewFromStages(stages) : requestFactory.createNewFromStages(stages, actionRequest); if (null != requestContext) { request.setRequestContext(requestContext); } if (request != null && request.getStages()!= null && !request.getStages().isEmpty()) { if (LOG.isDebugEnabled()) { LOG.debug(String.format("Triggering Action Manager, request=%s", request)); } actionManager.sendActions(request, actionRequest); } } } 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();  }