PipelineNodeImpl extends BluePipelineNode { protected static WorkflowRun getRun(WorkflowJob job, long itemId) throws InterruptedException { WorkflowRun restartRun = QueueUtil.getRun(job, itemId); if (restartRun == null) { long startTimeMs = System.currentTimeMillis(); while (restartRun == null && System.currentTimeMillis()-startTimeMs < waitJobInqueueTimeout) { Thread.sleep(100); restartRun = QueueUtil.getRun(job, itemId); } } return restartRun; } PipelineNodeImpl(FlowNodeWrapper node, Reachable parent, WorkflowRun run); @Override String getId(); @Override String getDisplayName(); @Override String getDisplayDescription(); @Override BlueRun.BlueRunResult getResult(); @Override BlueRun.BlueRunState getStateObj(); @Override @SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE") @CheckForNull String getFirstParent(); @Override Date getStartTime(); String getStartTimeString(); @Override List<Edge> getEdges(); @Override Long getDurationInMillis(); @Override Object getLog(); @Override String getType(); @Override String getStepType(); @Override String getCauseOfBlockage(); @Override BluePipelineStepContainer getSteps(); @Override Link getLink(); @Override Collection<BlueActionProxy> getActions(); @Override boolean isRestartable(); @Override BlueInputStep getInputStep(); @Override HttpResponse submitInputStep(StaplerRequest request); HttpResponse restart(StaplerRequest request); @Override String toString(); static final int waitJobInqueueTimeout; }
@Test public void getRun_NeverFound() throws Exception { PowerMockito.mockStatic(QueueUtil.class); PowerMockito.when(QueueUtil.getRun(job, 1)).thenReturn(null); WorkflowRun workflowRun = PipelineNodeImpl.getRun(job, 1); assertNull(workflowRun); PowerMockito.verifyStatic(QueueUtil.class, VerificationModeFactory.atLeastOnce()); QueueUtil.getRun(job, 1); }
@Test public void getRun_FirstFound() throws Exception { PowerMockito.mockStatic(QueueUtil.class); PowerMockito.when(QueueUtil.getRun(job, 1)).thenReturn(run); WorkflowRun workflowRun = PipelineNodeImpl.getRun(job, 1); assertEquals(workflowRun, run); PowerMockito.verifyStatic(QueueUtil.class, VerificationModeFactory.times(1)); QueueUtil.getRun(job, 1); }
@Test public void getRun_EventuallyFound() throws Exception { PowerMockito.mockStatic(QueueUtil.class); PowerMockito.when(QueueUtil.getRun(job, 1)).thenReturn(null).thenReturn(null).thenReturn(null).thenReturn(run); WorkflowRun workflowRun = PipelineNodeImpl.getRun(job, 1); assertEquals(workflowRun, run); PowerMockito.verifyStatic(QueueUtil.class, VerificationModeFactory.times(4)); QueueUtil.getRun(job, 1); }