Updates the TaskRepository createTaskExecution to support TaskExecution param
resolves #223 Updated to use TaskExecution when creating new executions for test.
This commit is contained in:
@@ -177,20 +177,23 @@ public class JdbcTaskExecutionDaoTests {
|
||||
}
|
||||
|
||||
private void initializeRepository() {
|
||||
repository.createTaskExecution("FOO3",
|
||||
new Date(),new ArrayList<String>(0), "externalA");
|
||||
repository.createTaskExecution("FOO2",
|
||||
new Date(),new ArrayList<String>(0), "externalB");
|
||||
repository.createTaskExecution("FOO1",
|
||||
new Date(),new ArrayList<String>(0), "externalC");
|
||||
repository.createTaskExecution(getTaskExecution("FOO3", "externalA"));
|
||||
repository.createTaskExecution(getTaskExecution("FOO2", "externalB"));
|
||||
repository.createTaskExecution(getTaskExecution("FOO1", "externalC"));
|
||||
}
|
||||
|
||||
private void initializeRepositoryNotInOrder() {
|
||||
repository.createTaskExecution("FOO1",
|
||||
new Date(), new ArrayList<String>(0), "externalC");
|
||||
repository.createTaskExecution("FOO2",
|
||||
new Date(), new ArrayList<String>(0), "externalA");
|
||||
repository.createTaskExecution("FOO3",
|
||||
new Date(), new ArrayList<String>(0), "externalB");
|
||||
repository.createTaskExecution(getTaskExecution("FOO1", "externalC"));
|
||||
repository.createTaskExecution(getTaskExecution("FOO2", "externalA"));
|
||||
repository.createTaskExecution(getTaskExecution("FOO3", "externalB"));
|
||||
}
|
||||
|
||||
private TaskExecution getTaskExecution(String taskName,
|
||||
String externalExecutionId) {
|
||||
TaskExecution taskExecution = new TaskExecution();
|
||||
taskExecution.setTaskName(taskName);
|
||||
taskExecution.setExternalExecutionId(externalExecutionId);
|
||||
taskExecution.setStartTime(new Date());
|
||||
return taskExecution;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,10 @@ import org.springframework.data.domain.Pageable;
|
||||
@RunWith(Parameterized.class)
|
||||
public class SimpleTaskExplorerTests {
|
||||
|
||||
private final static String TASK_NAME = "FOOBAR";
|
||||
|
||||
private final static String EXTERNAL_EXECUTION_ID = "123ABC";
|
||||
|
||||
private AnnotationConfigApplicationContext context;
|
||||
|
||||
@Autowired
|
||||
@@ -154,8 +158,6 @@ public class SimpleTaskExplorerTests {
|
||||
public void findRunningTasks() {
|
||||
final int TEST_COUNT = 2;
|
||||
final int COMPLETE_COUNT = 5;
|
||||
final String TASK_NAME = "FOOBAR";
|
||||
final String EXTERNAL_EXECUTION_ID = "123ABC";
|
||||
|
||||
Map<Long, TaskExecution> expectedResults = new HashMap<>();
|
||||
//Store completed jobs
|
||||
@@ -165,8 +167,8 @@ public class SimpleTaskExplorerTests {
|
||||
}
|
||||
|
||||
for (; i < (COMPLETE_COUNT + TEST_COUNT); i++) {
|
||||
TaskExecution expectedTaskExecution = this.taskRepository.createTaskExecution(
|
||||
TASK_NAME, new Date(), new ArrayList<String>(), EXTERNAL_EXECUTION_ID);
|
||||
TaskExecution expectedTaskExecution = this.taskRepository.
|
||||
createTaskExecution(getSimpleTaskExecution());
|
||||
expectedResults.put(expectedTaskExecution.getExecutionId(), expectedTaskExecution);
|
||||
}
|
||||
Pageable pageable = new PageRequest(0, 10);
|
||||
@@ -190,8 +192,6 @@ public class SimpleTaskExplorerTests {
|
||||
public void findTasksByName() {
|
||||
final int TEST_COUNT = 5;
|
||||
final int COMPLETE_COUNT = 7;
|
||||
final String TASK_NAME = "FOOBAR";
|
||||
final String EXTERNAL_EXECUTION_ID = "123ABC";
|
||||
Random randomGenerator = new Random();
|
||||
|
||||
Map<Long, TaskExecution> expectedResults = new HashMap<>();
|
||||
@@ -201,8 +201,8 @@ public class SimpleTaskExplorerTests {
|
||||
}
|
||||
|
||||
for (int i = 0; i < TEST_COUNT; i++) {
|
||||
TaskExecution expectedTaskExecution = this.taskRepository.createTaskExecution(
|
||||
TASK_NAME, new Date(), new ArrayList<String>(), EXTERNAL_EXECUTION_ID);
|
||||
TaskExecution expectedTaskExecution = this.taskRepository.
|
||||
createTaskExecution(getSimpleTaskExecution());
|
||||
expectedResults.put(expectedTaskExecution.getExecutionId(), expectedTaskExecution);
|
||||
}
|
||||
|
||||
@@ -319,8 +319,7 @@ public class SimpleTaskExplorerTests {
|
||||
|
||||
private TaskExecution createAndSaveTaskExecution(int i) {
|
||||
TaskExecution taskExecution = TestVerifierUtils.createSampleTaskExecution(i);
|
||||
taskExecution = this.taskRepository.createTaskExecution(taskExecution.getTaskName(),
|
||||
taskExecution.getStartTime(), taskExecution.getArguments(), taskExecution.getExternalExecutionId());
|
||||
taskExecution = this.taskRepository.createTaskExecution(taskExecution);
|
||||
return taskExecution;
|
||||
}
|
||||
|
||||
@@ -379,6 +378,14 @@ public class SimpleTaskExplorerTests {
|
||||
});
|
||||
}
|
||||
|
||||
private TaskExecution getSimpleTaskExecution() {
|
||||
TaskExecution taskExecution = new TaskExecution();
|
||||
taskExecution.setTaskName(TASK_NAME);
|
||||
taskExecution.setStartTime(new Date());
|
||||
taskExecution.setExternalExecutionId(EXTERNAL_EXECUTION_ID);
|
||||
return taskExecution;
|
||||
}
|
||||
|
||||
private enum DaoType{jdbc, map}
|
||||
|
||||
@Configuration
|
||||
|
||||
@@ -193,9 +193,7 @@ public class SimpleTaskRepositoryJdbcTests {
|
||||
MAX_ERROR_MESSAGE_SIZE);
|
||||
TaskExecution expectedTaskExecution = TestVerifierUtils.createSampleTaskExecutionNoArg();
|
||||
expectedTaskExecution.setTaskName(new String(new char[MAX_TASK_NAME_SIZE + 1]));
|
||||
simpleTaskRepository.createTaskExecution(expectedTaskExecution.getTaskName(),
|
||||
expectedTaskExecution.getStartTime(), expectedTaskExecution.getArguments(),
|
||||
expectedTaskExecution.getExternalExecutionId());
|
||||
simpleTaskRepository.createTaskExecution(expectedTaskExecution);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@@ -204,9 +202,7 @@ public class SimpleTaskRepositoryJdbcTests {
|
||||
new TaskExecutionDaoFactoryBean(this.dataSource), null, null, null);
|
||||
TaskExecution expectedTaskExecution = TestVerifierUtils.createSampleTaskExecutionNoArg();
|
||||
expectedTaskExecution.setTaskName(new String(new char[SimpleTaskRepository.MAX_TASK_NAME_SIZE + 1]));
|
||||
simpleTaskRepository.createTaskExecution(expectedTaskExecution.getTaskName(),
|
||||
expectedTaskExecution.getStartTime(), expectedTaskExecution.getArguments(),
|
||||
expectedTaskExecution.getExternalExecutionId());
|
||||
simpleTaskRepository.createTaskExecution(expectedTaskExecution);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -230,9 +226,11 @@ public class SimpleTaskRepositoryJdbcTests {
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@DirtiesContext
|
||||
public void testCreateTaskExecutionNoParamMaxTaskName(){
|
||||
taskRepository.createTaskExecution(
|
||||
new String(new char[SimpleTaskRepository.MAX_TASK_NAME_SIZE+1]),
|
||||
new Date(), null, null);
|
||||
TaskExecution taskExecution = new TaskExecution();
|
||||
taskExecution.setTaskName(
|
||||
new String(new char[SimpleTaskRepository.MAX_TASK_NAME_SIZE+1]));
|
||||
taskExecution.setStartTime(new Date());
|
||||
taskRepository.createTaskExecution(taskExecution);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
|
||||
@@ -48,9 +48,7 @@ public class TaskExecutionCreator {
|
||||
*/
|
||||
public static TaskExecution createAndStoreTaskExecutionNoParams(TaskRepository taskRepository) {
|
||||
TaskExecution expectedTaskExecution = TestVerifierUtils.createSampleTaskExecutionNoArg();
|
||||
expectedTaskExecution = taskRepository.createTaskExecution(expectedTaskExecution.getTaskName(),
|
||||
expectedTaskExecution.getStartTime(), expectedTaskExecution.getArguments(),
|
||||
expectedTaskExecution.getExternalExecutionId());
|
||||
expectedTaskExecution = taskRepository.createTaskExecution();
|
||||
return expectedTaskExecution;
|
||||
}
|
||||
|
||||
@@ -66,9 +64,7 @@ public class TaskExecutionCreator {
|
||||
params.add(UUID.randomUUID().toString());
|
||||
params.add(UUID.randomUUID().toString());
|
||||
expectedTaskExecution.setArguments(params);
|
||||
expectedTaskExecution = taskRepository.createTaskExecution(expectedTaskExecution.getTaskName(),
|
||||
expectedTaskExecution.getStartTime(), expectedTaskExecution.getArguments(),
|
||||
expectedTaskExecution.getExternalExecutionId());
|
||||
expectedTaskExecution = taskRepository.createTaskExecution(expectedTaskExecution);
|
||||
return expectedTaskExecution;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user