Java Code Examples for org.springframework.cloud.task.repository.TaskExecution#setStartTime()

The following examples show how to use org.springframework.cloud.task.repository.TaskExecution#setStartTime() . 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: SimpleTaskRepositoryJdbcTests.java    From spring-cloud-task with Apache License 2.0 6 votes vote down vote up
@Test
@DirtiesContext
public void startTaskExecutionWithParent() {
	TaskExecution expectedTaskExecution = TaskExecutionCreator
			.createAndStoreEmptyTaskExecution(this.taskRepository);

	expectedTaskExecution.setStartTime(new Date());
	expectedTaskExecution.setTaskName(UUID.randomUUID().toString());
	expectedTaskExecution.setParentExecutionId(12345L);

	TaskExecution actualTaskExecution = this.taskRepository.startTaskExecution(
			expectedTaskExecution.getExecutionId(),
			expectedTaskExecution.getTaskName(), expectedTaskExecution.getStartTime(),
			expectedTaskExecution.getArguments(),
			expectedTaskExecution.getExternalExecutionId(),
			expectedTaskExecution.getParentExecutionId());

	TestVerifierUtils.verifyTaskExecution(expectedTaskExecution, actualTaskExecution);
}
 
Example 2
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 3
Source File: DefaultTaskExecutionServiceTests.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@Test
@DirtiesContext
public void getCFTaskLogByTaskIdOtherThanLatest() {
	String taskName = "test-task";
	String platformName = "cf-test-platform";
	String taskDeploymentId = "12345";
	TaskDeployment taskDeployment = new TaskDeployment();
	taskDeployment.setPlatformName(platformName);
	taskDeployment.setTaskDeploymentId(taskDeploymentId);
	taskDeployment.setTaskDefinitionName(taskName);
	this.taskDeploymentRepository.save(taskDeployment);
	TaskExecution taskExecution = new TaskExecution();
	taskExecution.setStartTime(new Date());
	taskExecution.setTaskName(taskName);
	taskExecution.setExternalExecutionId("12346");
	this.taskRepository.createTaskExecution(taskExecution);
	this.launcherRepository.save(new Launcher(platformName,
			TaskPlatformFactory.CLOUDFOUNDRY_PLATFORM_TYPE, taskLauncher));
	assertEquals("", this.taskExecutionService.getLog(platformName, taskDeploymentId));
}
 
Example 4
Source File: SimpleTaskRepositoryJdbcTests.java    From spring-cloud-task with Apache License 2.0 6 votes vote down vote up
@Test
@DirtiesContext
public void startTaskExecutionWithNoParam() {
	TaskExecution expectedTaskExecution = TaskExecutionCreator
			.createAndStoreEmptyTaskExecution(this.taskRepository);

	expectedTaskExecution.setStartTime(new Date());
	expectedTaskExecution.setTaskName(UUID.randomUUID().toString());

	TaskExecution actualTaskExecution = this.taskRepository.startTaskExecution(
			expectedTaskExecution.getExecutionId(),
			expectedTaskExecution.getTaskName(), expectedTaskExecution.getStartTime(),
			expectedTaskExecution.getArguments(),
			expectedTaskExecution.getExternalExecutionId());

	TestVerifierUtils.verifyTaskExecution(expectedTaskExecution, actualTaskExecution);
}
 
Example 5
Source File: MapTaskExecutionDaoTests.java    From spring-cloud-task with Apache License 2.0 6 votes vote down vote up
@Test
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());
	Map<Long, TaskExecution> taskExecutionMap = this.mapTaskExecutionDao
			.getTaskExecutions();
	assertThat(taskExecutionMap).as("taskExecutionMap must not be null").isNotNull();
	TestVerifierUtils.verifyTaskExecution(expectedTaskExecution,
			taskExecutionMap.get(expectedTaskExecution.getExecutionId()));
}
 
Example 6
Source File: SimpleTaskRepositoryJdbcTests.java    From spring-cloud-task with Apache License 2.0 6 votes vote down vote up
@Test
@DirtiesContext
public void startTaskExecutionWithParam() {
	TaskExecution expectedTaskExecution = TaskExecutionCreator
			.createAndStoreEmptyTaskExecution(this.taskRepository);

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

	TaskExecution actualTaskExecution = this.taskRepository.startTaskExecution(
			expectedTaskExecution.getExecutionId(),
			expectedTaskExecution.getTaskName(), expectedTaskExecution.getStartTime(),
			expectedTaskExecution.getArguments(),
			expectedTaskExecution.getExternalExecutionId());

	TestVerifierUtils.verifyTaskExecution(expectedTaskExecution, actualTaskExecution);
}
 
Example 7
Source File: SimpleTaskRepositoryMapTests.java    From spring-cloud-task with Apache License 2.0 6 votes vote down vote up
@Test
public void startTaskExecutionWithParent() {
	TaskExecution expectedTaskExecution = TaskExecutionCreator
			.createAndStoreEmptyTaskExecution(this.taskRepository);

	expectedTaskExecution.setStartTime(new Date());
	expectedTaskExecution.setTaskName(UUID.randomUUID().toString());
	expectedTaskExecution.setParentExecutionId(12345L);

	TaskExecution actualTaskExecution = this.taskRepository.startTaskExecution(
			expectedTaskExecution.getExecutionId(),
			expectedTaskExecution.getTaskName(), expectedTaskExecution.getStartTime(),
			expectedTaskExecution.getArguments(),
			expectedTaskExecution.getExternalExecutionId());

	TestVerifierUtils.verifyTaskExecution(expectedTaskExecution, actualTaskExecution);
}
 
Example 8
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 9
Source File: SimpleTaskRepositoryMapTests.java    From spring-cloud-task with Apache License 2.0 6 votes vote down vote up
@Test
public void startTaskExecutionWithParam() {
	TaskExecution expectedTaskExecution = TaskExecutionCreator
			.createAndStoreEmptyTaskExecution(this.taskRepository);

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

	TaskExecution actualTaskExecution = this.taskRepository.startTaskExecution(
			expectedTaskExecution.getExecutionId(),
			expectedTaskExecution.getTaskName(), expectedTaskExecution.getStartTime(),
			expectedTaskExecution.getArguments(),
			expectedTaskExecution.getExternalExecutionId(),
			expectedTaskExecution.getParentExecutionId());

	TestVerifierUtils.verifyTaskExecution(expectedTaskExecution, actualTaskExecution);
}
 
Example 10
Source File: SimpleTaskRepositoryMapTests.java    From spring-cloud-task with Apache License 2.0 6 votes vote down vote up
@Test
public void startTaskExecutionWithNoParam() {
	TaskExecution expectedTaskExecution = TaskExecutionCreator
			.createAndStoreEmptyTaskExecution(this.taskRepository);

	expectedTaskExecution.setStartTime(new Date());
	expectedTaskExecution.setTaskName(UUID.randomUUID().toString());

	TaskExecution actualTaskExecution = this.taskRepository.startTaskExecution(
			expectedTaskExecution.getExecutionId(),
			expectedTaskExecution.getTaskName(), expectedTaskExecution.getStartTime(),
			expectedTaskExecution.getArguments(),
			expectedTaskExecution.getExternalExecutionId());

	TestVerifierUtils.verifyTaskExecution(expectedTaskExecution, actualTaskExecution);
}
 
Example 11
Source File: BaseTaskExecutionDaoTestCases.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
protected TaskExecution getTaskExecution(String taskName,
		String externalExecutionId) {
	TaskExecution taskExecution = new TaskExecution();
	taskExecution.setTaskName(taskName);
	taskExecution.setExternalExecutionId(externalExecutionId);
	taskExecution.setStartTime(new Date());
	return taskExecution;
}
 
Example 12
Source File: SimpleTaskExplorerTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
private TaskExecution getSimpleTaskExecution() {
	TaskExecution taskExecution = new TaskExecution();
	taskExecution.setTaskName(TASK_NAME);
	taskExecution.setStartTime(new Date());
	taskExecution.setExternalExecutionId(EXTERNAL_EXECUTION_ID);
	return taskExecution;
}
 
Example 13
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 testCreateTaskExecutionNoParamMaxTaskName() {
	TaskExecution taskExecution = new TaskExecution();
	taskExecution.setTaskName(
			new String(new char[SimpleTaskRepository.MAX_TASK_NAME_SIZE + 1]));
	taskExecution.setStartTime(new Date());
	this.taskRepository.createTaskExecution(taskExecution);
}
 
Example 14
Source File: TaskExecutionResourceTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Test
public void testTaskExecutionStatusWithRunningTaskExecution()  {
	final TaskExecution taskExecution = new TaskExecution();
	taskExecution.setStartTime(new Date());
	final TaskExecutionResource taskExecutionResource = new TaskExecutionResource(taskExecution);
	assertEquals(TaskExecutionStatus.RUNNING, taskExecutionResource.getTaskExecutionStatus());
	assertNull(taskExecutionResource.getExitCode());
}
 
Example 15
Source File: MapTaskExecutionDao.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Override
public TaskExecution startTaskExecution(long executionId, String taskName,
		Date startTime, List<String> arguments, String externalExecutionid,
		Long parentExecutionId) {
	TaskExecution taskExecution = this.taskExecutions.get(executionId);
	taskExecution.setTaskName(taskName);
	taskExecution.setStartTime(startTime);
	taskExecution.setArguments(arguments);
	taskExecution.setParentExecutionId(parentExecutionId);
	if (externalExecutionid != null) {
		taskExecution.setExternalExecutionId(externalExecutionid);
	}
	return taskExecution;
}
 
Example 16
Source File: TaskControllerTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Before
public void setupMockMVC() {
	this.mockMvc = MockMvcBuilders.webAppContextSetup(wac)
			.defaultRequest(get("/").accept(MediaType.APPLICATION_JSON)).build();

	launcherRepository.save(new Launcher("default", "local", taskLauncher));
	when(taskLauncher.launch(any(AppDeploymentRequest.class))).thenReturn("testID");


	Map<String, String> deploymentProperties = new HashMap<>();
	deploymentProperties.put("app.test.key1", "value1");
	TaskManifest taskManifest = new TaskManifest();
	AppDeploymentRequest request = new AppDeploymentRequest(new AppDefinition("test", Collections.emptyMap()), new FileSystemResource(""), deploymentProperties, null);
	taskManifest.setTaskDeploymentRequest(request);
	taskManifest.setPlatformName("test");

	final TaskExecution taskExecutionRunning = this.taskExecutionCreationService.createTaskExecution("myTask");
	taskExecutionRunning.setStartTime(new Date());
	when(taskExplorer.getLatestTaskExecutionForTaskName("myTask")).thenReturn(taskExecutionRunning);
	when(taskExplorer.getTaskExecution(taskExecutionRunning.getExecutionId())).thenReturn(taskExecutionRunning);
	this.dataflowTaskExecutionMetadataDao.save(taskExecutionRunning, taskManifest);

	final TaskExecution taskExecutionComplete = this.taskExecutionCreationService.createTaskExecution("myTask2");
	taskExecutionComplete.setTaskName("myTask2");
	taskExecutionComplete.setStartTime(new Date());
	taskExecutionComplete.setEndTime(new Date());
	taskExecutionComplete.setExitCode(0);
	when(taskExplorer.getLatestTaskExecutionForTaskName("myTask2")).thenReturn(taskExecutionComplete);
	when(taskExplorer.getTaskExecution(taskExecutionComplete.getExecutionId())).thenReturn(taskExecutionComplete);
	when(taskExplorer.getLatestTaskExecutionsByTaskNames(any()))
			.thenReturn(Arrays.asList(taskExecutionRunning, taskExecutionComplete));
	this.dataflowTaskExecutionMetadataDao.save(taskExecutionComplete, taskManifest);
}
 
Example 17
Source File: TaskExecutionResourceTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Test
public void testTaskExecutionStatusWithFailedTaskExecution()  {
	final TaskExecution taskExecution = new TaskExecution();
	taskExecution.setStartTime(new Date());
	taskExecution.setEndTime(new Date());
	taskExecution.setExitCode(123);
	final TaskExecutionResource taskExecutionResource = new TaskExecutionResource(taskExecution);
	assertEquals(TaskExecutionStatus.ERROR, taskExecutionResource.getTaskExecutionStatus());
}
 
Example 18
Source File: TaskExecutionResourceTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Test
public void testTaskExecutionStatusWithSuccessfulTaskExecution()  {
	final TaskExecution taskExecution = new TaskExecution();
	taskExecution.setStartTime(new Date());
	taskExecution.setEndTime(new Date());
	taskExecution.setExitCode(0);
	final TaskExecutionResource taskExecutionResource = new TaskExecutionResource(taskExecution);
	assertEquals(TaskExecutionStatus.COMPLETE, taskExecutionResource.getTaskExecutionStatus());
}
 
Example 19
Source File: BaseTaskExecutionDaoTestCases.java    From spring-cloud-task with Apache License 2.0 4 votes vote down vote up
protected long initializeRepositoryNotInOrderWithMultipleTaskExecutions() {

		final TaskExecution foo1_0 = getTaskExecution("FOO1", "externalC");
		foo1_0.setStartTime(getDate(2015, 2, 22, 23, 59));

		final TaskExecution foo1_1 = getTaskExecution("FOO1", "externalC");
		foo1_1.setStartTime(getDate(2015, 2, 20, 14, 45));

		final TaskExecution foo1_2 = getTaskExecution("FOO1", "externalC");
		foo1_2.setStartTime(getDate(2015, 1, 19, 14, 30));

		final TaskExecution foo1_3 = getTaskExecution("FOO1", "externalC");
		foo1_3.setStartTime(getDate(2015, 1, 20, 14, 45));

		TaskExecution foo2 = getTaskExecution("FOO2", "externalA");
		foo2.setStartTime(getDate(2015, 4, 20, 14, 45));

		TaskExecution foo3 = getTaskExecution("FOO3", "externalB");
		foo3.setStartTime(getDate(2016, 8, 20, 14, 45));

		TaskExecution foo4 = getTaskExecution("FOO4", "externalB");
		foo4.setStartTime(getDate(2015, 2, 20, 14, 45));

		final TaskExecution foo5_0 = getTaskExecution("FOO5", "externalC");
		foo5_0.setStartTime(getDate(2015, 2, 22, 23, 59));

		final TaskExecution foo5_1 = getTaskExecution("FOO5", "externalC");
		foo5_1.setStartTime(getDate(2015, 2, 22, 23, 59));

		final TaskExecution foo5_2 = getTaskExecution("FOO5", "externalC");
		foo5_2.setStartTime(getDate(2015, 2, 22, 23, 59));

		long executionIdOffset = this.createTaskExecution(foo1_0);
		this.createTaskExecution(foo1_1);
		this.createTaskExecution(foo1_2);
		this.createTaskExecution(foo1_3);

		this.createTaskExecution(foo2);
		this.createTaskExecution(foo3);
		this.createTaskExecution(foo4);

		this.createTaskExecution(foo5_0);
		this.createTaskExecution(foo5_1);
		this.createTaskExecution(foo5_2);

		return executionIdOffset;
	}