Java Code Examples for org.springframework.cloud.task.configuration.TaskProperties#setExecutionid()

The following examples show how to use org.springframework.cloud.task.configuration.TaskProperties#setExecutionid() . 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: TaskLauncherTaskletTests.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@Test
@DirtiesContext
public void testTaskLauncherTaskletWithTaskExecutionId() throws Exception{
	TaskLauncherTasklet taskLauncherTasklet = prepTaskLauncherTests();

	TaskProperties taskProperties = new TaskProperties();
	taskProperties.setExecutionid(88L);
	mockReturnValForTaskExecution(2L);
	ChunkContext chunkContext = chunkContext();
	createCompleteTaskExecution(0);
	taskLauncherTasklet = getTaskExecutionTasklet(taskProperties);
	taskLauncherTasklet.setArguments(null);
	execute(taskLauncherTasklet, null, chunkContext);
	assertEquals(2L, chunkContext.getStepContext()
			.getStepExecution().getExecutionContext()
			.get("task-execution-id"));
	assertEquals("--spring.cloud.task.parent-execution-id=88", ((List)chunkContext.getStepContext()
			.getStepExecution().getExecutionContext()
			.get("task-arguments")).get(0));
}
 
Example 2
Source File: TaskLauncherTaskletTests.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@Test
@DirtiesContext
public void testTaskLauncherTaskletWithTaskExecutionIdWithPreviousParentID() throws Exception{

	TaskLauncherTasklet taskLauncherTasklet = prepTaskLauncherTests();
	TaskProperties taskProperties = new TaskProperties();
	taskProperties.setExecutionid(88L);
	mockReturnValForTaskExecution(2L);
	ChunkContext chunkContext = chunkContext();
	createCompleteTaskExecution(0);
	chunkContext.getStepContext()
			.getStepExecution().getExecutionContext().put("task-arguments", new ArrayList<String>());
	((List)chunkContext.getStepContext()
			.getStepExecution().getExecutionContext()
			.get("task-arguments")).add("--spring.cloud.task.parent-execution-id=84");
	taskLauncherTasklet = getTaskExecutionTasklet(taskProperties);
	taskLauncherTasklet.setArguments(null);
	execute(taskLauncherTasklet, null, chunkContext);
	assertEquals(2L, chunkContext.getStepContext()
			.getStepExecution().getExecutionContext()
			.get("task-execution-id"));
	assertEquals("--spring.cloud.task.parent-execution-id=88", ((List)chunkContext.getStepContext()
			.getStepExecution().getExecutionContext()
			.get("task-arguments")).get(0));
}
 
Example 3
Source File: TaskLauncherTaskletTests.java    From composed-task-runner with Apache License 2.0 5 votes vote down vote up
@Test
@DirtiesContext
public void testTaskLauncherTaskletWithTaskExecutionId() throws Exception{
	createCompleteTaskExecution(0);
	TaskLauncherTasklet taskLauncherTasklet =
			getTaskExecutionTasklet();
	ChunkContext chunkContext = chunkContext();
	mockReturnValForTaskExecution(1L);
	execute(taskLauncherTasklet, null, chunkContext);
	assertEquals(1L, chunkContext.getStepContext()
			.getStepExecution().getExecutionContext()
			.get("task-execution-id"));
	assertNull(chunkContext.getStepContext()
			.getStepExecution().getExecutionContext()
			.get("task-arguments"));

	TaskProperties taskProperties = new TaskProperties();
	taskProperties.setExecutionid(88l);
	mockReturnValForTaskExecution(2L);
	chunkContext = chunkContext();
	createCompleteTaskExecution(0);
	taskLauncherTasklet = getTaskExecutionTasklet(taskProperties);
	taskLauncherTasklet.setArguments(null);
	execute(taskLauncherTasklet, null, chunkContext);
	assertEquals(2L, chunkContext.getStepContext()
			.getStepExecution().getExecutionContext()
			.get("task-execution-id"));
	assertEquals("--spring.cloud.task.parent-execution-id=88", ((List)chunkContext.getStepContext()
			.getStepExecution().getExecutionContext()
			.get("task-arguments")).get(0));
}