org.springframework.cloud.task.repository.TaskExecution Java Examples

The following examples show how to use org.springframework.cloud.task.repository.TaskExecution. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JobCommandTests.java    From spring-cloud-dataflow with Apache License 2.0 9 votes vote down vote up
private static long createSampleJob(String jobName, int jobExecutionCount) {
	JobInstance instance = jobRepository.createJobInstance(jobName, new JobParameters());
	jobInstances.add(instance);
	TaskExecution taskExecution = dao.createTaskExecution(jobName, new Date(), new ArrayList<>(), null);
	Map<String, JobParameter> jobParameterMap = new HashMap<>();
	jobParameterMap.put("foo", new JobParameter("FOO", true));
	jobParameterMap.put("bar", new JobParameter("BAR", false));
	JobParameters jobParameters = new JobParameters(jobParameterMap);
	JobExecution jobExecution;
	for (int i = 0; i < jobExecutionCount; i++) {
		jobExecution = jobRepository.createJobExecution(instance, jobParameters, null);
		taskBatchDao.saveRelationship(taskExecution, jobExecution);
		StepExecution stepExecution = new StepExecution("foobar", jobExecution);
		jobRepository.add(stepExecution);
	}
	return taskExecution.getExecutionId();
}
 
Example #2
Source File: MapTaskExecutionDao.java    From spring-cloud-task with Apache License 2.0 6 votes vote down vote up
@Override
public TaskExecution getLatestTaskExecutionForTaskName(String taskName) {
	Assert.hasText(taskName, "The task name must not be empty.");
	final List<TaskExecution> taskExecutions = this
			.getLatestTaskExecutionsByTaskNames(taskName);
	if (taskExecutions.isEmpty()) {
		return null;
	}
	else if (taskExecutions.size() == 1) {
		return taskExecutions.get(0);
	}
	else {
		throw new IllegalStateException(
				"Only expected a single TaskExecution but received "
						+ taskExecutions.size());
	}
}
 
Example #3
Source File: JdbcTaskExecutionDaoTests.java    From spring-cloud-task with Apache License 2.0 6 votes vote down vote up
@Test
@DirtiesContext
public void completeTaskExecution() {
	TaskExecution expectedTaskExecution = TestVerifierUtils
			.endSampleTaskExecutionNoArg();
	expectedTaskExecution = this.dao.createTaskExecution(
			expectedTaskExecution.getTaskName(), expectedTaskExecution.getStartTime(),
			expectedTaskExecution.getArguments(),
			expectedTaskExecution.getExternalExecutionId());
	this.dao.completeTaskExecution(expectedTaskExecution.getExecutionId(),
			expectedTaskExecution.getExitCode(), expectedTaskExecution.getEndTime(),
			expectedTaskExecution.getExitMessage());
	TestVerifierUtils.verifyTaskExecution(expectedTaskExecution,
			TestDBUtils.getTaskExecutionFromDB(this.dataSource,
					expectedTaskExecution.getExecutionId()));
}
 
Example #4
Source File: TaskPartitionerTests.java    From spring-cloud-task with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithLocalDeployer() throws Exception {
	SpringApplication app = new SpringApplication(PartitionedBatchJobApplication.class);
	app.setAdditionalProfiles("master");
	Properties properties = new Properties();
	properties.setProperty("spring.datasource.url", DATASOURCE_URL);
	properties.setProperty("spring.datasource.username", DATASOURCE_USER_NAME);
	properties.setProperty("spring.datasource.driverClassName", DATASOURCE_DRIVER_CLASS_NAME);
	properties.setProperty("spring.cloud.deployer.local.use-spring-application-json", "false");
	app.setDefaultProperties(properties);
	app.run();

	Page<TaskExecution> taskExecutions = this.taskExplorer
		.findAll(PageRequest.of(0, 10));
	assertThat(taskExecutions.getTotalElements()).as("Five rows are expected")
		.isEqualTo(5);
	assertThat(this.taskExplorer
		.getTaskExecutionCountByTaskName("PartitionedBatchJobTask"))
		.as("Only One master is expected").isEqualTo(1);
	for (TaskExecution taskExecution : taskExecutions) {
		assertThat(taskExecution.getExitCode()
			.intValue()).as("return code should be 0").isEqualTo(0);
	}
}
 
Example #5
Source File: SimpleTaskRepositoryJdbcTests.java    From spring-cloud-task with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreateTaskExecutionNoParamMaxErrorMessageSize() {
	SimpleTaskRepository simpleTaskRepository = new SimpleTaskRepository(
			new TaskExecutionDaoFactoryBean(this.dataSource));
	simpleTaskRepository.setMaxErrorMessageSize(5);

	TaskExecution expectedTaskExecution = TaskExecutionCreator
			.createAndStoreTaskExecutionNoParams(simpleTaskRepository);
	expectedTaskExecution.setErrorMessage(
			new String(new char[SimpleTaskRepository.MAX_ERROR_MESSAGE_SIZE + 1]));
	expectedTaskExecution.setEndTime(new Date());
	expectedTaskExecution.setExitCode(0);
	TaskExecution actualTaskExecution = completeTaskExecution(expectedTaskExecution,
			simpleTaskRepository);
	assertThat(actualTaskExecution.getErrorMessage().length()).isEqualTo(5);
}
 
Example #6
Source File: SimpleCommandLineArgsProviderTests.java    From spring-cloud-task with Apache License 2.0 6 votes vote down vote up
@Test
public void testAppending() {
	List<String> appendedValues = new ArrayList<>(3);
	appendedValues.add("one");
	appendedValues.add("two");
	appendedValues.add("three");

	TaskExecution taskExecution = new TaskExecution();
	taskExecution.setArguments(Arrays.asList("foo", "bar", "baz"));

	SimpleCommandLineArgsProvider provider = new SimpleCommandLineArgsProvider(
			taskExecution);
	provider.setAppendedArgs(appendedValues);

	List<String> commandLineArgs = provider.getCommandLineArgs(null);

	assertThat(commandLineArgs.get(0)).isEqualTo("foo");
	assertThat(commandLineArgs.get(1)).isEqualTo("bar");
	assertThat(commandLineArgs.get(2)).isEqualTo("baz");
	assertThat(commandLineArgs.get(3)).isEqualTo("one");
	assertThat(commandLineArgs.get(4)).isEqualTo("two");
	assertThat(commandLineArgs.get(5)).isEqualTo("three");
}
 
Example #7
Source File: JdbcTaskExecutionDaoTests.java    From spring-cloud-task with Apache License 2.0 6 votes vote down vote up
@Test
@DirtiesContext
public void testStartTaskExecution() {
	TaskExecution expectedTaskExecution = this.dao.createTaskExecution(null, null,
			new ArrayList<>(0), null);

	expectedTaskExecution.setArguments(
			Collections.singletonList("foo=" + UUID.randomUUID().toString()));
	expectedTaskExecution.setStartTime(new Date());
	expectedTaskExecution.setTaskName(UUID.randomUUID().toString());

	this.dao.startTaskExecution(expectedTaskExecution.getExecutionId(),
			expectedTaskExecution.getTaskName(), expectedTaskExecution.getStartTime(),
			expectedTaskExecution.getArguments(),
			expectedTaskExecution.getExternalExecutionId());

	TestVerifierUtils.verifyTaskExecution(expectedTaskExecution,
			TestDBUtils.getTaskExecutionFromDB(this.dataSource,
					expectedTaskExecution.getExecutionId()));
}
 
Example #8
Source File: DefaultTaskDeleteService.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@Override
public void cleanupExecution(long id) {
	TaskExecution taskExecution = taskExplorer.getTaskExecution(id);
	Assert.notNull(taskExecution, "There was no task execution with id " + id);
	String launchId = taskExecution.getExternalExecutionId();
	Assert.hasLength(launchId, "The TaskExecution for id " + id + " did not have an externalExecutionId");
	TaskDeployment taskDeployment = this.taskDeploymentRepository.findByTaskDeploymentId(launchId);
	if (taskDeployment == null) {
		logger.warn(String.format("Did not find TaskDeployment for taskName = [%s], taskId = [%s].  Nothing to clean up.",
				taskExecution.getTaskName(), id));
		return;
	}
	Launcher launcher = launcherRepository.findByName(taskDeployment.getPlatformName());
	if (launcher != null) {
		TaskLauncher taskLauncher = launcher.getTaskLauncher();
		taskLauncher.cleanup(launchId);
	}
	else {
		logger.info(
				"Could clean up execution for task id " + id + ". Did not find a task platform named " +
						taskDeployment.getPlatformName());
	}
}
 
Example #9
Source File: SimpleTaskRepositoryJdbcTests.java    From spring-cloud-task with Apache License 2.0 6 votes vote down vote up
private void verifyTaskRepositoryConstructor(Integer maxExitMessage,
		Integer maxErrorMessage, TaskRepository taskRepository) {
	TaskExecution expectedTaskExecution = TaskExecutionCreator
			.createAndStoreTaskExecutionNoParams(taskRepository);
	expectedTaskExecution.setErrorMessage(new String(new char[maxErrorMessage + 1]));
	expectedTaskExecution.setExitMessage(new String(new char[maxExitMessage + 1]));
	expectedTaskExecution.setEndTime(new Date());
	expectedTaskExecution.setExitCode(0);

	TaskExecution actualTaskExecution = completeTaskExecution(expectedTaskExecution,
			taskRepository);
	assertThat(actualTaskExecution.getErrorMessage().length())
			.isEqualTo(maxErrorMessage.intValue());
	assertThat(actualTaskExecution.getExitMessage().length())
			.isEqualTo(maxExitMessage.intValue());
}
 
Example #10
Source File: TaskControllerTests.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@Test
public void testTaskLaunchNoManifest() throws Exception{
	final TaskExecution taskExecutionComplete = this.taskExecutionCreationService.createTaskExecution("myTask3");
	taskExecutionComplete.setTaskName("myTask3");
	taskExecutionComplete.setStartTime(new Date());
	taskExecutionComplete.setEndTime(new Date());
	taskExecutionComplete.setExitCode(0);
	when(taskExplorer.getLatestTaskExecutionForTaskName("myTask3")).thenReturn(taskExecutionComplete);
	when(taskExplorer.getTaskExecution(taskExecutionComplete.getExecutionId())).thenReturn(taskExecutionComplete);
	when(taskExplorer.getLatestTaskExecutionsByTaskNames(any()))
			.thenReturn(Arrays.asList(taskExecutionComplete, taskExecutionComplete));
	repository.save(new TaskDefinition("myTask3", "foo"));
	this.registry.save("foo", ApplicationType.task,
			"1.0.0", new URI("file:src/test/resources/apps/foo-task"), null);
	this.dataflowTaskExecutionMetadataDao.save(taskExecutionComplete, null);
	mockMvc.perform(get("/tasks/definitions/myTask3").param("manifest", "true").accept(MediaType.APPLICATION_JSON))
			.andDo(print()).andExpect(status().isOk());

}
 
Example #11
Source File: SimpleCommandLineArgsProviderTests.java    From spring-cloud-task with Apache License 2.0 6 votes vote down vote up
@Test
public void testAppendingNull() {

	TaskExecution taskExecution = new TaskExecution();
	taskExecution.setArguments(Arrays.asList("foo", "bar", "baz"));

	SimpleCommandLineArgsProvider provider = new SimpleCommandLineArgsProvider(
			taskExecution);
	provider.setAppendedArgs(null);

	List<String> commandLineArgs = provider.getCommandLineArgs(null);

	assertThat(commandLineArgs.size()).isEqualTo(3);
	assertThat(commandLineArgs.get(0)).isEqualTo("foo");
	assertThat(commandLineArgs.get(1)).isEqualTo("bar");
	assertThat(commandLineArgs.get(2)).isEqualTo("baz");
}
 
Example #12
Source File: TaskBatchExecutionListenerTests.java    From spring-cloud-task with Apache License 2.0 6 votes vote down vote up
@Test
public void testMapBased() {
	this.applicationContext = SpringApplication.run(JobConfiguration.class, ARGS);

	TaskExplorer taskExplorer = this.applicationContext.getBean(TaskExplorer.class);

	Page<TaskExecution> page = taskExplorer.findTaskExecutionsByName("application",
			PageRequest.of(0, 1));

	Set<Long> jobExecutionIds = taskExplorer.getJobExecutionIdsByTaskExecutionId(
			page.iterator().next().getExecutionId());

	assertThat(jobExecutionIds.size()).isEqualTo(1);
	assertThat((long) taskExplorer
			.getTaskExecutionIdByJobExecutionId(jobExecutionIds.iterator().next()))
					.isEqualTo(1);
}
 
Example #13
Source File: JdbcTaskExecutionDao.java    From spring-cloud-task with Apache License 2.0 6 votes vote down vote up
@Override
public TaskExecution createTaskExecution(String taskName, Date startTime,
		List<String> arguments, String externalExecutionId, Long parentExecutionId) {
	long nextExecutionId = getNextExecutionId();

	TaskExecution taskExecution = new TaskExecution(nextExecutionId, null, taskName,
			startTime, null, null, arguments, null, externalExecutionId);

	final MapSqlParameterSource queryParameters = new MapSqlParameterSource()
			.addValue("taskExecutionId", nextExecutionId, Types.BIGINT)
			.addValue("exitCode", null, Types.INTEGER)
			.addValue("startTime", startTime, Types.TIMESTAMP)
			.addValue("taskName", taskName, Types.VARCHAR)
			.addValue("lastUpdated", new Date(), Types.TIMESTAMP)
			.addValue("externalExecutionId", externalExecutionId, Types.VARCHAR)
			.addValue("parentExecutionId", parentExecutionId, Types.BIGINT);

	this.jdbcTemplate.update(getQuery(SAVE_TASK_EXECUTION), queryParameters);
	insertTaskArguments(nextExecutionId, arguments);
	return taskExecution;
}
 
Example #14
Source File: DefaultTaskJobServiceTests.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
private void createSampleJob(JobRepository jobRepository, TaskBatchDao taskBatchDao,
		TaskExecutionDao taskExecutionDao, String jobName,
		int jobExecutionCount, BatchStatus status) {
	JobInstance instance = jobRepository.createJobInstance(jobName, new JobParameters());
	TaskExecution taskExecution = taskExecutionDao.createTaskExecution(jobName, new Date(), new ArrayList<>(), null);
	JobExecution jobExecution;

	for (int i = 0; i < jobExecutionCount; i++) {
		jobExecution = jobRepository.createJobExecution(instance,
				this.jobParameters, null);
		StepExecution stepExecution = new StepExecution("foo", jobExecution, 1L);
		stepExecution.setId(null);
		jobRepository.add(stepExecution);
		taskBatchDao.saveRelationship(taskExecution, jobExecution);
		jobExecution.setStatus(status);
		jobExecution.setStartTime(new Date());
		jobRepository.update(jobExecution);
	}
}
 
Example #15
Source File: TaskAppDeploymentRequestCreator.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
private List<String> updateCommandLineArgs(List<String> commandLineArgs, TaskExecution taskExecution, String platformName) {
	List<String> results = new ArrayList();
	commandLineArgs.stream()
			.filter(arg -> !arg.startsWith(TASK_EXECUTION_KEY)
					&& !arg.startsWith(PLATFORM_NAME_KEY))
			.forEach(results::add);

	results.add(PLATFORM_NAME_KEY + platformName);
	results.add(TASK_EXECUTION_KEY + taskExecution.getExecutionId());
	return results;
}
 
Example #16
Source File: MapTaskExecutionDao.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Override
public Page<TaskExecution> findRunningTaskExecutions(String taskName,
		Pageable pageable) {
	Set<TaskExecution> result = getTaskExecutionTreeSet();
	for (Map.Entry<Long, TaskExecution> entry : this.taskExecutions.entrySet()) {
		if (entry.getValue().getTaskName().equals(taskName)
				&& entry.getValue().getEndTime() == null) {
			result.add(entry.getValue());
		}
	}
	return getPageFromList(new ArrayList<>(result), pageable,
			getRunningTaskExecutionCountByTaskName(taskName));
}
 
Example #17
Source File: DeployerPartitionHandlerTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
	MockitoAnnotations.initMocks(this);
	this.environment = new MockEnvironment();
	TaskExecution taskExecution = new TaskExecution(2, 0, "name", new Date(),
			new Date(), "", Collections.emptyList(), null, null, null);
	when(taskRepository.createTaskExecution()).thenReturn(taskExecution);
}
 
Example #18
Source File: SimpleTaskExplorerTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
private List<Long> getSortedOfTaskExecIds(Map<Long, TaskExecution> taskExecutionMap) {
	List<Long> sortedExecIds = new ArrayList<>(taskExecutionMap.size());
	TreeSet<TaskExecution> sortedSet = getTreeSet();
	sortedSet.addAll(taskExecutionMap.values());
	Iterator<TaskExecution> iterator = sortedSet.descendingIterator();
	while (iterator.hasNext()) {
		sortedExecIds.add(iterator.next().getExecutionId());
	}
	return sortedExecIds;
}
 
Example #19
Source File: TaskSanitizerTest.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Test
public void testTaskExecutionArguments() {
	TaskExecution taskExecution = new TaskExecution();
	taskExecution.setTaskName("a1");
	taskExecution.setArguments(Arrays.asList("--username=test", "--password=testing"));
	TaskExecution sanitizedTaskExecution = this.taskSanitizer.sanitizeTaskExecutionArguments(taskExecution);
	Assert.assertEquals("--username=******", sanitizedTaskExecution.getArguments().get(0));
	Assert.assertEquals("--password=******", sanitizedTaskExecution.getArguments().get(1));
}
 
Example #20
Source File: SimpleCommandLineArgsProviderTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Test
public void test() {
	TaskExecution taskExecution = new TaskExecution();
	taskExecution.setArguments(Arrays.asList("foo", "bar", "baz"));

	SimpleCommandLineArgsProvider provider = new SimpleCommandLineArgsProvider(
			taskExecution);

	List<String> commandLineArgs = provider.getCommandLineArgs(null);

	assertThat(commandLineArgs.get(0)).isEqualTo("foo");
	assertThat(commandLineArgs.get(1)).isEqualTo("bar");
	assertThat(commandLineArgs.get(2)).isEqualTo("baz");
}
 
Example #21
Source File: SimpleTaskExplorerTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
private Map<Long, TaskExecution> createSampleDataSet(int count) {
	Map<Long, TaskExecution> expectedResults = new HashMap<>();
	for (int i = 0; i < count; i++) {
		TaskExecution expectedTaskExecution = createAndSaveTaskExecution(i);
		expectedResults.put(expectedTaskExecution.getExecutionId(),
				expectedTaskExecution);
	}
	return expectedResults;
}
 
Example #22
Source File: SimpleTaskExplorerTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Test
public void findTasksByName() {
	final int TEST_COUNT = 5;
	final int COMPLETE_COUNT = 7;

	Map<Long, TaskExecution> expectedResults = new HashMap<>();
	// Store completed jobs
	for (int i = 0; i < COMPLETE_COUNT; i++) {
		createAndSaveTaskExecution(i);
	}

	for (int i = 0; i < TEST_COUNT; i++) {
		TaskExecution expectedTaskExecution = this.taskRepository
				.createTaskExecution(getSimpleTaskExecution());
		expectedResults.put(expectedTaskExecution.getExecutionId(),
				expectedTaskExecution);
	}

	Pageable pageable = PageRequest.of(0, 10);
	Page<TaskExecution> resultSet = this.taskExplorer
			.findTaskExecutionsByName(TASK_NAME, pageable);
	assertThat(resultSet.getNumberOfElements()).as(String.format(
			"Running task count for task name did not match expected result for testType %s",
			this.testType)).isEqualTo(TEST_COUNT);

	for (TaskExecution result : resultSet) {
		assertThat(expectedResults.containsKey(result.getExecutionId()))
				.as(String.format("result returned from %s repo %s not expected",
						this.testType, result.getExecutionId()))
				.isTrue();
		assertThat(result.getTaskName()).as(String.format(
				"taskName for taskExecution is incorrect for testType %s",
				this.testType)).isEqualTo(TASK_NAME);
	}
}
 
Example #23
Source File: MapTaskExecutionDao.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Override
public void updateExternalExecutionId(long taskExecutionId,
		String externalExecutionId) {
	TaskExecution taskExecution = this.taskExecutions.get(taskExecutionId);
	Assert.notNull(taskExecution,
			"Invalid TaskExecution, ID " + taskExecutionId + " not found.");
	taskExecution.setExternalExecutionId(externalExecutionId);
}
 
Example #24
Source File: TaskLauncherSinkTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithLocalDeployer() throws Exception {
	launchTask(URL);
	assertThat(waitForDBToBePopulated()).isTrue();

	Page<TaskExecution> taskExecutions = this.taskExplorer
			.findAll(PageRequest.of(0, 10));
	assertThat(taskExecutions.getTotalElements()).as("Only one row is expected")
			.isEqualTo(1);
	assertThat(waitForTaskToComplete()).isTrue();
	assertThat(taskExecutions.iterator().next().getExitCode().intValue())
			.as("return code should be 0").isEqualTo(0);
}
 
Example #25
Source File: DefaultTaskExecutionServiceTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalStateException.class)
@DirtiesContext
public void testUpgradeFailureTaskCurrentlyRunning() throws MalformedURLException {
	TaskExecution myTask = this.taskRepository.createTaskExecution(TASK_NAME_ORIG);
	TaskManifest manifest = new TaskManifest();
	manifest.setPlatformName("default");
	AppDeploymentRequest request = new AppDeploymentRequest(new AppDefinition("some-name", null),
			new FileUrlResource("src/test/resources/apps/foo-task"));
	manifest.setTaskDeploymentRequest(request);

	this.dataflowTaskExecutionMetadataDao.save(myTask, manifest);

	initializeSuccessfulRegistry(appRegistry);
	this.taskExecutionService.executeTask(TASK_NAME_ORIG, new HashMap<>(), new LinkedList<>());
}
 
Example #26
Source File: TaskMetrics.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
private Tags commonTags(TaskExecution taskExecution) {
	return Tags.of(TASK_NAME_TAG, taskExecution.getTaskName())
			.and(TASK_EXECUTION_ID_TAG, "" + taskExecution.getExecutionId())
			.and(TASK_PARENT_EXECUTION_ID_TAG,
					"" + taskExecution.getParentExecutionId())
			.and(TASK_EXTERNAL_EXECUTION_ID_TAG,
					(taskExecution.getExternalExecutionId() == null) ? "unknown"
							: "" + taskExecution.getExternalExecutionId());
}
 
Example #27
Source File: TaskDefinitionController.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
TaskDefinitionResource updateTaskExecutionResource(TaskExecutionAwareTaskDefinition taskExecutionAwareTaskDefinition, TaskDefinitionResource taskDefinitionResource, boolean manifest) {
	TaskExecution taskExecution = taskExecutionAwareTaskDefinition.getLatestTaskExecution();
	TaskManifest taskManifest = taskExecutionService.findTaskManifestById(taskExecution.getExecutionId());
	taskManifest = taskSanitizer.sanitizeTaskManifest(taskManifest);
	TaskExecutionResource taskExecutionResource = (manifest && taskManifest != null) ? new TaskExecutionResource(taskExecution, taskManifest) : new TaskExecutionResource(taskExecution);
	taskDefinitionResource.setLastTaskExecution(taskExecutionResource);
	return taskDefinitionResource;
}
 
Example #28
Source File: SimpleTaskRepositoryMapTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Test
public void testCompleteTaskExecution() {
	TaskExecution expectedTaskExecution = TaskExecutionCreator
			.createAndStoreTaskExecutionNoParams(this.taskRepository);
	expectedTaskExecution.setEndTime(new Date());
	expectedTaskExecution.setExitCode(0);
	TaskExecution actualTaskExecution = TaskExecutionCreator
			.completeExecution(this.taskRepository, expectedTaskExecution);
	TestVerifierUtils.verifyTaskExecution(expectedTaskExecution, actualTaskExecution);
}
 
Example #29
Source File: SimpleTaskRepositoryJdbcTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
@DirtiesContext
public void testCreateTaskExecutionNullEndTime() {
	TaskExecution expectedTaskExecution = TaskExecutionCreator
			.createAndStoreTaskExecutionNoParams(this.taskRepository);
	expectedTaskExecution.setExitCode(-1);
	TaskExecutionCreator.completeExecution(this.taskRepository,
			expectedTaskExecution);
}
 
Example #30
Source File: TaskDefinitionController.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Override
public TaskExecutionAwareTaskDefinition apply(TaskDefinition source) {
	TaskExecution lastTaskExecution = null;

	if (taskExecutions != null) {
		lastTaskExecution = taskExecutions.get(source.getName());
	}

	if (lastTaskExecution != null) {
		return new TaskExecutionAwareTaskDefinition(source, lastTaskExecution);
	}
	else {
		return new TaskExecutionAwareTaskDefinition(source);
	}
}