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:
committed by
Glenn Renfro
parent
ad6ce32750
commit
fec40fd3f8
@@ -70,6 +70,19 @@ public interface TaskRepository {
|
||||
@Transactional
|
||||
TaskExecution createTaskExecution(TaskExecution taskExecution);
|
||||
|
||||
/**
|
||||
* Creates an empty TaskExecution with just an id and name provided. This is intended to be
|
||||
* utilized in systems where the request of launching a task is separate from the
|
||||
* actual start of a task (the underlying system may need to deploy the task prior to
|
||||
* launching, etc).
|
||||
*
|
||||
* @param name task name to be associated with the task execution.
|
||||
*
|
||||
* @return the initial {@link TaskExecution}
|
||||
*/
|
||||
@Transactional
|
||||
TaskExecution createTaskExecution(String name);
|
||||
|
||||
/**
|
||||
* Creates an empty TaskExecution with just an id provided. This is intended to be
|
||||
* utilized in systems where the request of launching a task is separate from the
|
||||
|
||||
@@ -115,15 +115,20 @@ public class SimpleTaskRepository implements TaskRepository {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskExecution createTaskExecution() {
|
||||
public TaskExecution createTaskExecution(String name) {
|
||||
initialize();
|
||||
TaskExecution taskExecution =
|
||||
taskExecutionDao.createTaskExecution(null, null,
|
||||
taskExecutionDao.createTaskExecution(name, null,
|
||||
Collections.<String>emptyList(), null);
|
||||
logger.debug("Creating: " + taskExecution.toString());
|
||||
return taskExecution;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskExecution createTaskExecution() {
|
||||
return createTaskExecution((String)null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskExecution startTaskExecution(long executionid, String taskName, Date startTime, List<String> arguments,
|
||||
String externalExecutionId) {
|
||||
|
||||
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user