@Test(expected=NoSuchJobException.class) public void testGetStepExecutionsNoExecutionReturned() { jsrJobOperator.getStepExecutions(5L); }
@Test public void testGetStepExecutionsNoStepExecutions() { JobExecution jobExecution = new JobExecution(5L); when(jobExplorer.getJobExecution(5L)).thenReturn(jobExecution); List<javax.batch.runtime.StepExecution> results = jsrJobOperator.getStepExecutions(5L); assertEquals(0, results.size()); }
@Test public void testGetStepExecutionsRoseyScenario() { JobExecution jobExecution = new JobExecution(5L); List<StepExecution> stepExecutions = new ArrayList<>(); stepExecutions.add(new StepExecution("step1", jobExecution, 1L)); stepExecutions.add(new StepExecution("step2", jobExecution, 2L)); jobExecution.addStepExecutions(stepExecutions); when(jobExplorer.getJobExecution(5L)).thenReturn(jobExecution); when(jobExplorer.getStepExecution(5L, 1L)).thenReturn(new StepExecution("step1", jobExecution, 1L)); when(jobExplorer.getStepExecution(5L, 2L)).thenReturn(new StepExecution("step2", jobExecution, 2L)); List<javax.batch.runtime.StepExecution> results = jsrJobOperator.getStepExecutions(5L); assertEquals("step1", results.get(0).getStepName()); assertEquals("step2", results.get(1).getStepName()); }
@Test public void testGetStepExecutionsPartitionedStepScenario() { JobExecution jobExecution = new JobExecution(5L); List<StepExecution> stepExecutions = new ArrayList<>(); stepExecutions.add(new StepExecution("step1", jobExecution, 1L)); stepExecutions.add(new StepExecution("step2", jobExecution, 2L)); stepExecutions.add(new StepExecution("step2:partition0", jobExecution, 2L)); stepExecutions.add(new StepExecution("step2:partition1", jobExecution, 2L)); stepExecutions.add(new StepExecution("step2:partition2", jobExecution, 2L)); jobExecution.addStepExecutions(stepExecutions); when(jobExplorer.getJobExecution(5L)).thenReturn(jobExecution); when(jobExplorer.getStepExecution(5L, 1L)).thenReturn(new StepExecution("step1", jobExecution, 1L)); when(jobExplorer.getStepExecution(5L, 2L)).thenReturn(new StepExecution("step2", jobExecution, 2L)); List<javax.batch.runtime.StepExecution> results = jsrJobOperator.getStepExecutions(5L); assertEquals("step1", results.get(0).getStepName()); assertEquals("step2", results.get(1).getStepName()); }
@Test public void testDecisionThrowsException() throws Exception { JobExecution execution = runJob("DecisionStepTests-decisionThrowsException-context", new Properties(), 10000L); assertEquals(BatchStatus.FAILED, execution.getBatchStatus()); assertEquals(2, BatchRuntime.getJobOperator().getStepExecutions(execution.getExecutionId()).size()); }
@Test public void testDecisionValidExitStatus() throws Exception { JobExecution execution = runJob("DecisionStepTests-decisionValidExitStatus-context", new Properties(), 10000L); assertEquals(BatchStatus.COMPLETED, execution.getBatchStatus()); assertEquals(3, BatchRuntime.getJobOperator().getStepExecutions(execution.getExecutionId()).size()); }
@Test public void testStepGetsFailedTransitionWhenNextAttributePresent() throws Exception { JobExecution jobExecution = runJob("FlowParserTestsStepGetsFailedTransitionWhenNextAttributePresent", new Properties(), 10000L); assertEquals(ExitStatus.FAILED.getExitCode(), jobExecution.getExitStatus()); JobOperator jobOperator = BatchRuntime.getJobOperator(); List<StepExecution> stepExecutions = jobOperator.getStepExecutions(jobExecution.getExecutionId()); assertEquals(1, stepExecutions.size()); StepExecution failedStep = stepExecutions.get(0); assertTrue("failedExitStatusStep".equals(failedStep.getStepName())); assertTrue("FAILED".equals(failedStep.getExitStatus())); }
@Test public void testDecisionAsFirstStepOfJob() throws Exception { JobExecution execution = runJob("DecisionStepTests-decisionAsFirstStep-context", new Properties(), 10000L); assertEquals(BatchStatus.FAILED, execution.getBatchStatus()); assertEquals(0, BatchRuntime.getJobOperator().getStepExecutions(execution.getExecutionId()).size()); }
@Test public void testDecisionAfterFlow() throws Exception { JobExecution execution = runJob("DecisionStepTests-decisionAfterFlow-context", new Properties(), 10000L); assertEquals(BatchStatus.COMPLETED, execution.getBatchStatus()); assertEquals(3, BatchRuntime.getJobOperator().getStepExecutions(execution.getExecutionId()).size()); }
@Test public void testWildcardAddedLastWhenUsedWithNextAttrAndNoTransitionElements() throws Exception { JobExecution jobExecution = runJob("FlowParserTestsWildcardAndNextAttrJob", new Properties(), 1000L); assertEquals(ExitStatus.FAILED.getExitCode(), jobExecution.getExitStatus()); JobOperator jobOperator = BatchRuntime.getJobOperator(); List<StepExecution> stepExecutions = jobOperator.getStepExecutions(jobExecution.getExecutionId()); assertEquals(1, stepExecutions.size()); StepExecution failedStep = stepExecutions.get(0); assertTrue("step1".equals(failedStep.getStepName())); }
@Test public void testStepNoOverrideWhenNextAndFailedTransitionElementExists() throws Exception { JobExecution jobExecution = runJob("FlowParserTestsStepNoOverrideWhenNextAndFailedTransitionElementExists", new Properties(), 10000L); assertEquals(ExitStatus.FAILED.getExitCode(), jobExecution.getExitStatus()); JobOperator jobOperator = BatchRuntime.getJobOperator(); List<StepExecution> stepExecutions = jobOperator.getStepExecutions(jobExecution.getExecutionId()); assertEquals(1, stepExecutions.size()); StepExecution failedStep = stepExecutions.get(0); assertTrue("failedExitStatusStepDontOverride".equals(failedStep.getStepName())); assertTrue("CUSTOM_FAIL".equals(failedStep.getExitStatus())); }
@Test public void testDecisionAfterSplit() throws Exception { JobExecution execution = runJob("DecisionStepTests-decisionAfterSplit-context", new Properties(), 10000L); assertEquals(BatchStatus.COMPLETED, execution.getBatchStatus()); assertEquals(4, BatchRuntime.getJobOperator().getStepExecutions(execution.getExecutionId()).size()); assertEquals(2, StepExecutionCountingDecider.previousStepCount); }
@Test public void testDecisionUnmappedExitStatus() throws Exception { JobExecution execution = runJob("DecisionStepTests-decisionInvalidExitStatus-context", new Properties(), 10000L); assertEquals(BatchStatus.COMPLETED, execution.getBatchStatus()); List<StepExecution> stepExecutions = BatchRuntime.getJobOperator().getStepExecutions(execution.getExecutionId()); assertEquals(2, stepExecutions.size()); for (StepExecution curExecution : stepExecutions) { assertEquals(BatchStatus.COMPLETED, curExecution.getBatchStatus()); } }
@Test public void testDecisionCustomExitStatus() throws Exception { JobExecution execution = runJob("DecisionStepTests-decisionCustomExitStatus-context", new Properties(), 10000L); assertEquals(BatchStatus.FAILED, execution.getBatchStatus()); assertEquals(2, BatchRuntime.getJobOperator().getStepExecutions(execution.getExecutionId()).size()); assertEquals("CustomFail", execution.getExitStatus()); }
@Test public void testDecisionRestart() throws Exception { JobExecution execution = runJob("DecisionStepTests-restart-context", new Properties(), 10000L); assertEquals(BatchStatus.STOPPED, execution.getBatchStatus()); List<StepExecution> stepExecutions = BatchRuntime.getJobOperator().getStepExecutions(execution.getExecutionId()); assertEquals(2, stepExecutions.size()); assertEquals("step1", stepExecutions.get(0).getStepName()); assertEquals("decision1", stepExecutions.get(1).getStepName()); JobExecution execution2 = restartJob(execution.getExecutionId(), new Properties(), 10000L); assertEquals(BatchStatus.COMPLETED, execution2.getBatchStatus()); List<StepExecution> stepExecutions2 = BatchRuntime.getJobOperator().getStepExecutions(execution2.getExecutionId()); assertEquals(2, stepExecutions2.size()); assertEquals("decision1", stepExecutions2.get(0).getStepName()); assertEquals("step2", stepExecutions2.get(1).getStepName()); }
@Test public void testSkippable() throws Exception { JobOperator jobOperator = BatchRuntime.getJobOperator(); Properties jobParameters = new Properties(); jobParameters.setProperty("run", "1"); JobExecution execution1 = runJob("ExceptionHandlingParsingTests-context", jobParameters, 10000l); List<StepExecution> stepExecutions = jobOperator.getStepExecutions(execution1.getExecutionId()); assertEquals(BatchStatus.FAILED, execution1.getBatchStatus()); assertEquals(1, stepExecutions.size()); assertEquals(1, getMetric(stepExecutions.get(0), Metric.MetricType.PROCESS_SKIP_COUNT).getValue()); jobParameters = new Properties(); jobParameters.setProperty("run", "2"); JobExecution execution2 = restartJob(execution1.getExecutionId(), jobParameters, 10000l); stepExecutions = jobOperator.getStepExecutions(execution2.getExecutionId()); assertEquals(BatchStatus.FAILED, execution2.getBatchStatus()); assertEquals(2, stepExecutions.size()); jobParameters = new Properties(); jobParameters.setProperty("run", "3"); JobExecution execution3 = restartJob(execution2.getExecutionId(), jobParameters, 10000l); stepExecutions = jobOperator.getStepExecutions(execution3.getExecutionId()); assertEquals(BatchStatus.COMPLETED, execution3.getBatchStatus()); assertEquals(2, stepExecutions.size()); assertEquals(0, getMetric(stepExecutions.get(1), Metric.MetricType.ROLLBACK_COUNT).getValue()); jobParameters = new Properties(); jobParameters.setProperty("run", "4"); JobExecution execution4 = runJob("ExceptionHandlingParsingTests-context", jobParameters, 10000l); stepExecutions = jobOperator.getStepExecutions(execution4.getExecutionId()); assertEquals(BatchStatus.COMPLETED, execution4.getBatchStatus()); assertEquals(3, stepExecutions.size()); }
@Test public void test() throws Exception { JobExecution jobExecution = runJob("jobWithEndTransition", null, 10000L); assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus()); assertEquals("SUCCESS", jobExecution.getExitStatus()); assertEquals(1, operator.getStepExecutions(jobExecution.getExecutionId()).size()); }
@Test public void test() throws Exception { javax.batch.runtime.JobExecution execution = runJob("JsrSplitParsingTests-context", null, 10000L); assertEquals(javax.batch.runtime.BatchStatus.COMPLETED, execution.getBatchStatus()); assertEquals("COMPLETED", execution.getExitStatus()); List<StepExecution> stepExecutions = BatchRuntime.getJobOperator().getStepExecutions(execution.getExecutionId()); assertEquals(5, stepExecutions.size()); }
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(execution.getExecutionId()); assertEquals(1, getMetric(stepExecutions.get(0), Metric.MetricType.READ_SKIP_COUNT).getValue()); assertEquals(1, TestSkipListener.readSkips); stepExecutions = jobOperator.getStepExecutions(execution.getExecutionId()); assertEquals(1, getMetric(stepExecutions.get(0), Metric.MetricType.PROCESS_SKIP_COUNT).getValue()); assertEquals(0, TestSkipListener.readSkips); stepExecutions = jobOperator.getStepExecutions(execution.getExecutionId()); assertEquals(1, getMetric(stepExecutions.get(0), Metric.MetricType.WRITE_SKIP_COUNT).getValue()); assertEquals(0, TestSkipListener.readSkips); stepExecutions = jobOperator.getStepExecutions(execution.getExecutionId()); assertEquals(0, getMetric(stepExecutions.get(0), Metric.MetricType.WRITE_SKIP_COUNT).getValue()); assertEquals(0, TestSkipListener.readSkips);
private void assertCompletion(long executionId) { List<StepExecution> stepExecutions = jobOperator.getStepExecutions( executionId ); for ( StepExecution stepExecution : stepExecutions ) { BatchStatus batchStatus = stepExecution.getBatchStatus(); log.infof( "step %s executed.", stepExecution.getStepName() ); assertEquals( BatchStatus.COMPLETED, batchStatus ); } }