Adding a method to pass in taskName for new empty TaskExecution

Resolves #298

Added test and add param to javadoc
This commit is contained in:
Thomas Risberg
2017-03-29 11:33:29 -04:00
committed by Glenn Renfro
parent ad6ce32750
commit fec40fd3f8
3 changed files with 38 additions and 2 deletions

View File

@@ -55,6 +55,7 @@ import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.SocketUtils;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -144,6 +145,23 @@ public class TaskStartTests {
assertEquals("return code should be 0", 0, taskExecutions.iterator().next().getExitCode().intValue());
}
@Test
public void testWithGeneratedTaskExecutionWithName() throws Exception {
final String TASK_EXECUTION_NAME = "PRE-EXECUTION-TEST-NAME";
taskRepository.createTaskExecution(TASK_EXECUTION_NAME);
assertEquals("Only one row is expected", 1, taskExplorer.getTaskExecutionCount());
assertEquals(TASK_EXECUTION_NAME, taskExplorer.getTaskExecution(1).getTaskName());
getTaskApplication(1).run(new String[0]);
assertTrue(waitForDBToBePopulated());
Page<TaskExecution> taskExecutions = taskExplorer.findAll(new PageRequest(0, 10));
TaskExecution te = taskExecutions.iterator().next();
assertEquals("Only one row is expected", 1, taskExecutions.getTotalElements());
assertEquals("return code should be 0", 0, taskExecutions.iterator().next().getExitCode().intValue());
assertEquals("batchEvents", taskExplorer.getTaskExecution(1).getTaskName());
}
@Test(expected = ApplicationContextException.class)
public void testWithNoTaskExecution() throws Exception {
getTaskApplication(55).run(new String[0]);