@Test public void runInternal() throws Exception { WikiCreationStep step1 = mock(WikiCreationStep.class); WikiCreationStep step2 = mock(WikiCreationStep.class); WikiCreationStep step3 = mock(WikiCreationStep.class); when(step1.getOrder()).thenReturn(100); when(step2.getOrder()).thenReturn(50); when(step3.getOrder()).thenReturn(75); mocker.registerComponent(WikiCreationStep.class, "step1", step1); mocker.registerComponent(WikiCreationStep.class, "step2", step2); mocker.registerComponent(WikiCreationStep.class, "step3", step3); WikiCreationRequest request = new WikiCreationRequest(); request.setId(Arrays.asList("myrequest")); mocker.getComponentUnderTest().start(request); InOrder inOrder = inOrder(step1, step2, step3, progressManager); inOrder.verify(progressManager).pushLevelProgress(eq(3), any(Object.class)); inOrder.verify(progressManager, calls(1)).startStep(any(Object.class)); inOrder.verify(step2).execute(any(WikiCreationRequest.class)); inOrder.verify(progressManager, calls(1)).startStep(any(Object.class)); inOrder.verify(step3).execute(any(WikiCreationRequest.class)); inOrder.verify(progressManager, calls(1)).startStep(any(Object.class)); inOrder.verify(step1).execute(any(WikiCreationRequest.class)); inOrder.verify(progressManager).popLevelProgress(any(Object.class)); }
@Override protected void runInternal() throws Exception { try { this.xcontextProvider.get().setUserReference( this.defaultDocumentReferenceResolver.resolve(getRequest().getOwnerId())); List<WikiCreationStep> wikiCreationStepList = componentManager.getInstanceList(WikiCreationStep.class); Collections.sort(wikiCreationStepList, new Comparator<WikiCreationStep>() { @Override public int compare(WikiCreationStep o1, WikiCreationStep o2) { return o1.getOrder() - o2.getOrder(); } }); this.progressManager.pushLevelProgress(wikiCreationStepList.size(), this); for (WikiCreationStep step : wikiCreationStepList) { this.progressManager.startStep(this); step.execute(request); this.progressManager.endStep(this); } this.progressManager.popLevelProgress(this); } catch (WikiCreationException | ComponentLookupException e) { throw new WikiCreationException( String.format("Failed to execute creation steps on the wiki [%s].", request.getWikiId()), e); } }
WikiCreationJob extends AbstractJob<WikiCreationRequest, DefaultJobStatus<WikiCreationRequest>> { @Override protected void runInternal() throws Exception { try { this.xcontextProvider.get().setUserReference( this.defaultDocumentReferenceResolver.resolve(getRequest().getOwnerId())); List<WikiCreationStep> wikiCreationStepList = componentManager.getInstanceList(WikiCreationStep.class); Collections.sort(wikiCreationStepList, new Comparator<WikiCreationStep>() { @Override public int compare(WikiCreationStep o1, WikiCreationStep o2) { return o1.getOrder() - o2.getOrder(); } }); this.progressManager.pushLevelProgress(wikiCreationStepList.size(), this); for (WikiCreationStep step : wikiCreationStepList) { this.progressManager.startStep(this); step.execute(request); this.progressManager.endStep(this); } this.progressManager.popLevelProgress(this); } catch (WikiCreationException | ComponentLookupException e) { throw new WikiCreationException( String.format("Failed to execute creation steps on the wiki [%s].", request.getWikiId()), e); } } }
WikiCreationJob extends AbstractJob<WikiCreationRequest, DefaultJobStatus<WikiCreationRequest>> { @Override protected void runInternal() throws Exception { try { this.xcontextProvider.get().setUserReference( this.defaultDocumentReferenceResolver.resolve(getRequest().getOwnerId())); List<WikiCreationStep> wikiCreationStepList = componentManager.getInstanceList(WikiCreationStep.class); Collections.sort(wikiCreationStepList, new Comparator<WikiCreationStep>() { @Override public int compare(WikiCreationStep o1, WikiCreationStep o2) { return o1.getOrder() - o2.getOrder(); } }); this.progressManager.pushLevelProgress(wikiCreationStepList.size(), this); for (WikiCreationStep step : wikiCreationStepList) { this.progressManager.startStep(this); step.execute(request); this.progressManager.endStep(this); } this.progressManager.popLevelProgress(this); } catch (WikiCreationException | ComponentLookupException e) { throw new WikiCreationException( String.format("Failed to execute creation steps on the wiki [%s].", request.getWikiId()), e); } }  }
WikiCreationJob extends AbstractJob<WikiCreationRequest, DefaultJobStatus<WikiCreationRequest>> { @Override protected void runInternal() throws Exception { try { this.xcontextProvider.get().setUserReference( this.defaultDocumentReferenceResolver.resolve(getRequest().getOwnerId())); List<WikiCreationStep> wikiCreationStepList = componentManager.getInstanceList(WikiCreationStep.class); Collections.sort(wikiCreationStepList, new Comparator<WikiCreationStep>() { @Override public int compare(WikiCreationStep o1, WikiCreationStep o2) { return o1.getOrder() - o2.getOrder(); } }); this.progressManager.pushLevelProgress(wikiCreationStepList.size(), this); for (WikiCreationStep step : wikiCreationStepList) { this.progressManager.startStep(this); step.execute(request); this.progressManager.endStep(this); } this.progressManager.popLevelProgress(this); } catch (WikiCreationException | ComponentLookupException e) { throw new WikiCreationException( String.format("Failed to execute creation steps on the wiki [%s].", request.getWikiId()), e); } }  @Override String getType(); }
WikiCreationJob extends AbstractJob<WikiCreationRequest, DefaultJobStatus<WikiCreationRequest>> { @Override protected void runInternal() throws Exception { try { this.xcontextProvider.get().setUserReference( this.defaultDocumentReferenceResolver.resolve(getRequest().getOwnerId())); List<WikiCreationStep> wikiCreationStepList = componentManager.getInstanceList(WikiCreationStep.class); Collections.sort(wikiCreationStepList, new Comparator<WikiCreationStep>() { @Override public int compare(WikiCreationStep o1, WikiCreationStep o2) { return o1.getOrder() - o2.getOrder(); } }); this.progressManager.pushLevelProgress(wikiCreationStepList.size(), this); for (WikiCreationStep step : wikiCreationStepList) { this.progressManager.startStep(this); step.execute(request); this.progressManager.endStep(this); } this.progressManager.popLevelProgress(this); } catch (WikiCreationException | ComponentLookupException e) { throw new WikiCreationException( String.format("Failed to execute creation steps on the wiki [%s].", request.getWikiId()), e); } }  @Override String getType(); static final String JOB_ID_PREFIX; static final String JOB_TYPE; }