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

The following examples show how to use org.springframework.cloud.task.repository.TaskExecution. These examples are extracted from open source projects. 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 Project: spring-cloud-dataflow   Source File: JobCommandTests.java    License: Apache License 2.0 6 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
@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 3
@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 4
Source Project: spring-cloud-task   Source File: JdbcTaskExecutionDao.java    License: 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 5
@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 6
Source Project: spring-cloud-task   Source File: TaskPartitionerTests.java    License: 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 7
@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 8
@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
@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 10
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 11
Source Project: spring-cloud-dataflow   Source File: TaskControllerTests.java    License: 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 12
@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
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 14
Source Project: spring-cloud-task   Source File: MapTaskExecutionDao.java    License: 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 15
@Test
@DirtiesContext
public void testFindAllPageableSort() {
	initializeRepositoryNotInOrder();
	Sort sort = Sort.by(new Sort.Order(Sort.Direction.ASC, "EXTERNAL_EXECUTION_ID"));
	Iterator<TaskExecution> iter = getPageIterator(0, 2, sort);
	TaskExecution taskExecution = iter.next();
	assertThat(taskExecution.getTaskName()).isEqualTo("FOO2");
	taskExecution = iter.next();
	assertThat(taskExecution.getTaskName()).isEqualTo("FOO3");

	iter = getPageIterator(1, 2, sort);
	taskExecution = iter.next();
	assertThat(taskExecution.getTaskName()).isEqualTo("FOO1");
}
 
Example 16
Source Project: spring-cloud-task   Source File: MapTaskExecutionDao.java    License: 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 17
Source Project: spring-cloud-task   Source File: SimpleTaskExplorerTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void getTaskExecution() {
	Map<Long, TaskExecution> expectedResults = createSampleDataSet(5);
	for (Long taskExecutionId : expectedResults.keySet()) {
		TaskExecution actualTaskExecution = this.taskExplorer
				.getTaskExecution(taskExecutionId);
		assertThat(actualTaskExecution).as(String.format(
				"expected a taskExecution but got null for test type %s",
				this.testType)).isNotNull();
		TestVerifierUtils.verifyTaskExecution(expectedResults.get(taskExecutionId),
				actualTaskExecution);
	}
}
 
Example 18
Source Project: spring-cloud-task   Source File: TaskLifecycleListener.java    License: Apache License 2.0 5 votes vote down vote up
private TaskExecution getTaskExecutionCopy(TaskExecution taskExecution) {
	Date startTime = new Date(taskExecution.getStartTime().getTime());
	Date endTime = (taskExecution.getEndTime() == null) ? null
			: new Date(taskExecution.getEndTime().getTime());

	return new TaskExecution(taskExecution.getExecutionId(),
			taskExecution.getExitCode(), taskExecution.getTaskName(), startTime,
			endTime, taskExecution.getExitMessage(),
			Collections.unmodifiableList(taskExecution.getArguments()),
			taskExecution.getErrorMessage(), taskExecution.getExternalExecutionId());
}
 
Example 19
@Test
@DirtiesContext
public void testCreateTaskExecutionNoParamMaxErrorDefaultMessageSize() {
	TaskExecution expectedTaskExecution = TaskExecutionCreator
			.createAndStoreTaskExecutionNoParams(this.taskRepository);
	expectedTaskExecution.setErrorMessage(
			new String(new char[SimpleTaskRepository.MAX_ERROR_MESSAGE_SIZE + 1]));
	expectedTaskExecution.setEndTime(new Date());
	expectedTaskExecution.setExitCode(0);
	TaskExecution actualTaskExecution = completeTaskExecution(expectedTaskExecution,
			this.taskRepository);
	assertThat(actualTaskExecution.getErrorMessage().length())
			.isEqualTo(SimpleTaskRepository.MAX_ERROR_MESSAGE_SIZE);
}
 
Example 20
@Test
public void testUpdateNullExternalExecutionId() {
	TaskExecution expectedTaskExecution = TaskExecutionCreator
			.createAndStoreTaskExecutionNoParams(this.taskRepository);
	expectedTaskExecution.setExternalExecutionId(null);
	this.taskRepository.updateExternalExecutionId(
			expectedTaskExecution.getExecutionId(),
			expectedTaskExecution.getExternalExecutionId());
	TestVerifierUtils.verifyTaskExecution(expectedTaskExecution,
			getSingleTaskExecutionFromMapRepository(
					expectedTaskExecution.getExecutionId()));
}
 
Example 21
private void createJobExecution(String name, BatchStatus status) {
	TaskExecution taskExecution = this.dao.createTaskExecution(name, new Date(), new ArrayList<>(), null);
	JobExecution jobExecution = this.jobRepository.createJobExecution(this.jobRepository.createJobInstance(name, new JobParameters()), new JobParameters(), null);
	StepExecution stepExecution = new StepExecution(name + "_STEP", jobExecution, jobExecution.getId());
	stepExecution.setId(null);
	jobRepository.add(stepExecution);
	this.taskBatchDao.saveRelationship(taskExecution, jobExecution);
	jobExecution.setStatus(status);
	jobExecution.setStartTime(new Date());
	this.jobRepository.update(jobExecution);
}
 
Example 22
Source Project: spring-cloud-task   Source File: SimpleTaskExplorerTests.java    License: Apache License 2.0 5 votes vote down vote up
private TreeSet<TaskExecution> getTreeSet() {
	return new TreeSet<>(new Comparator<TaskExecution>() {
		@Override
		public int compare(TaskExecution e1, TaskExecution e2) {
			int result = e1.getStartTime().compareTo(e2.getStartTime());
			if (result == 0) {
				result = Long.valueOf(e1.getExecutionId())
						.compareTo(e2.getExecutionId());
			}
			return result;
		}
	});
}
 
Example 23
Source Project: spring-cloud-task   Source File: TaskExecutionCreator.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates a sample TaskExecution and stores it in the taskRepository with params.
 * @param taskRepository the taskRepository where the taskExecution should be stored.
 * @return the taskExecution created.
 */
public static TaskExecution createAndStoreTaskExecutionWithParams(
		TaskRepository taskRepository) {
	TaskExecution expectedTaskExecution = TestVerifierUtils
			.createSampleTaskExecutionNoArg();
	List<String> params = new ArrayList<>();
	params.add(UUID.randomUUID().toString());
	params.add(UUID.randomUUID().toString());
	expectedTaskExecution.setArguments(params);
	expectedTaskExecution = taskRepository.createTaskExecution(expectedTaskExecution);
	return expectedTaskExecution;
}
 
Example 24
@Test
public void testExitMessageRunFail() {
	ExitStatus expectedTaskStatus = new ExitStatus("TEST_EXIT_MESSAGE");
	TaskExecution taskExecution = getDefaultTaskExecution(1,
			expectedTaskStatus.getExitCode());
	when(this.taskExplorer.getTaskExecution(anyLong())).thenReturn(taskExecution);
	populateExecutionContext(111L);

	assertEquals(expectedTaskStatus, this.taskListener.afterStep(this.stepExecution));
}
 
Example 25
@Test
public void testFailedRun() {
	TaskExecution taskExecution = getDefaultTaskExecution(1, null);
	when(this.taskExplorer.getTaskExecution(anyLong())).thenReturn(taskExecution);
	populateExecutionContext(111L);

	assertEquals(ExitStatus.FAILED, this.taskListener.afterStep(this.stepExecution));
}
 
Example 26
Source Project: spring-cloud-task   Source File: MapTaskExecutionDao.java    License: 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 27
/**
 * Return a page-able list of {@link TaskDefinitionResource} defined tasks.
 *
 * @param pageable page-able collection of {@code TaskDefinitionResource}
 * @param search optional findByTaskNameContains parameter
 * @param manifest optional manifest flag to indicate whether the latest task execution requires task manifest update
 * @param assembler assembler for the {@link TaskDefinition}
 * @return a list of task definitions
 */
@RequestMapping(value = "", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
public PagedModel<TaskDefinitionResource> list(Pageable pageable, @RequestParam(required = false) String search,
		@RequestParam(required = false) boolean manifest,
		PagedResourcesAssembler<TaskExecutionAwareTaskDefinition> assembler) {

	final Page<TaskDefinition> taskDefinitions;
	if (search != null) {
		taskDefinitions = repository.findByTaskNameContains(search, pageable);
	}
	else {
		taskDefinitions = repository.findAll(pageable);
	}

	final java.util.HashMap<String, TaskDefinition> taskDefinitionMap = new java.util.HashMap<>();

	for (TaskDefinition taskDefinition : taskDefinitions) {
		taskDefinitionMap.put(taskDefinition.getName(), taskDefinition);
	}

	final List<TaskExecution> taskExecutions;

	if (!taskDefinitionMap.isEmpty()) {
		taskExecutions = this.explorer.getLatestTaskExecutionsByTaskNames(
				taskDefinitionMap.keySet().toArray(new String[taskDefinitionMap.size()]));
	}
	else {
		taskExecutions = null;
	}

	final Page<TaskExecutionAwareTaskDefinition> taskExecutionAwareTaskDefinitions = taskDefinitions
			.map(new TaskDefinitionConverter(taskExecutions));

	PagedModel<TaskDefinitionResource> taskDefinitionResources = assembler.toModel(taskExecutionAwareTaskDefinitions, new Assembler(manifest));
	// Classify the composed task elements by iterating through the task definitions that are part of this page.
	updateComposedTaskElement(taskDefinitionResources.getContent());
	return taskDefinitionResources;
}
 
Example 28
Source Project: spring-cloud-task   Source File: SimpleTaskExplorerTests.java    License: 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 29
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 30
@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);
}