Update versions and update code format
This commit is contained in:
@@ -175,7 +175,8 @@ public class SimpleTaskAutoConfiguration {
|
||||
// retrieve the count of dataSources (without instantiating them) excluding
|
||||
// DataSource proxy beans
|
||||
long dataSources = Arrays.stream(this.context.getBeanNamesForType(DataSource.class))
|
||||
.filter((name -> !ScopedProxyUtils.isScopedTarget(name))).count();
|
||||
.filter((name -> !ScopedProxyUtils.isScopedTarget(name)))
|
||||
.count();
|
||||
|
||||
if (configurers == 0 && dataSources > 1) {
|
||||
throw new IllegalStateException("To use the default TaskConfigurer the context must contain no more than"
|
||||
|
||||
@@ -46,22 +46,22 @@ public class TaskRuntimeHints implements RuntimeHintsRegistrar {
|
||||
hints.resources().registerPattern("org/springframework/cloud/task/schema-hsqldb.sql");
|
||||
hints.resources().registerPattern("org/springframework/cloud/task/schema-sqlserver.sql");
|
||||
|
||||
hints.reflection().registerType(
|
||||
TypeReference.of("org.springframework.boot.jdbc.init.DataSourceScriptDatabaseInitializer"),
|
||||
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
|
||||
MemberCategory.INVOKE_DECLARED_METHODS));
|
||||
hints.reflection().registerType(TypeReference.of("org.springframework.cloud.task.repository.TaskExecution"),
|
||||
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
|
||||
MemberCategory.INVOKE_DECLARED_METHODS));
|
||||
hints.reflection()
|
||||
.registerType(TypeReference.of("org.springframework.boot.jdbc.init.DataSourceScriptDatabaseInitializer"),
|
||||
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
|
||||
MemberCategory.INVOKE_DECLARED_METHODS));
|
||||
hints.reflection()
|
||||
.registerType(TypeReference.of("org.springframework.cloud.task.repository.TaskExecution"), hint -> hint
|
||||
.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_METHODS));
|
||||
|
||||
if (!ClassUtils.isPresent("com.zaxxer.hikari.HikariDataSource", classLoader)) {
|
||||
return;
|
||||
}
|
||||
hints.reflection().registerType(Statement[].class, hint -> {
|
||||
});
|
||||
hints.reflection().registerType(TypeReference.of("com.zaxxer.hikari.util.ConcurrentBag$IConcurrentBagEntry[]"),
|
||||
hint -> {
|
||||
});
|
||||
hints.reflection()
|
||||
.registerType(TypeReference.of("com.zaxxer.hikari.util.ConcurrentBag$IConcurrentBagEntry[]"), hint -> {
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,8 +52,8 @@ class ObservationApplicationRunner implements ApplicationRunner {
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
TaskObservationContext context = new TaskObservationContext(this.beanName);
|
||||
Observation observation = TaskDocumentedObservation.TASK_RUNNER_OBSERVATION
|
||||
.observation(this.taskObservationConvention, INSTANCE, context, registry())
|
||||
.contextualName(this.beanName);
|
||||
.observation(this.taskObservationConvention, INSTANCE, context, registry())
|
||||
.contextualName(this.beanName);
|
||||
|
||||
try (Observation.Scope scope = observation.start().openScope()) {
|
||||
this.delegate.run(args);
|
||||
|
||||
@@ -51,8 +51,8 @@ class ObservationCommandLineRunner implements CommandLineRunner {
|
||||
public void run(String... args) throws Exception {
|
||||
TaskObservationContext context = new TaskObservationContext(this.beanName);
|
||||
Observation observation = TaskDocumentedObservation.TASK_RUNNER_OBSERVATION
|
||||
.observation(this.taskObservationConvention, INSTANCE, context, registry())
|
||||
.contextualName(this.beanName);
|
||||
.observation(this.taskObservationConvention, INSTANCE, context, registry())
|
||||
.contextualName(this.beanName);
|
||||
try (Observation.Scope scope = observation.start().openScope()) {
|
||||
this.delegate.run(args);
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ public class TaskLifecycleListener
|
||||
TaskExecutionException taskExecutionException = (TaskExecutionException) exception;
|
||||
if (taskExecutionException.getCause() instanceof InvocationTargetException) {
|
||||
InvocationTargetException invocationTargetException = (InvocationTargetException) taskExecutionException
|
||||
.getCause();
|
||||
.getCause();
|
||||
if (invocationTargetException != null && invocationTargetException.getTargetException() != null) {
|
||||
exception = invocationTargetException.getTargetException();
|
||||
}
|
||||
@@ -271,7 +271,7 @@ public class TaskLifecycleListener
|
||||
}
|
||||
if (this.taskProperties.getExecutionid() != null) {
|
||||
TaskExecution taskExecution = this.taskExplorer
|
||||
.getTaskExecution(this.taskProperties.getExecutionid());
|
||||
.getTaskExecution(this.taskProperties.getExecutionid());
|
||||
Assert.notNull(taskExecution, String.format("Invalid TaskExecution, ID %s not found",
|
||||
this.taskProperties.getExecutionid()));
|
||||
Assert.isNull(taskExecution.getEndTime(),
|
||||
|
||||
@@ -134,19 +134,19 @@ public class TaskListenerExecutorObjectFactory implements ObjectFactory<TaskExec
|
||||
if (!beforeTaskMethods.isEmpty()) {
|
||||
for (Method beforeTaskMethod : beforeTaskMethods.keySet()) {
|
||||
this.beforeTaskInstances.computeIfAbsent(beforeTaskMethod, k -> new LinkedHashSet<>())
|
||||
.add(this.context.getBean(beanName));
|
||||
.add(this.context.getBean(beanName));
|
||||
}
|
||||
}
|
||||
if (!afterTaskMethods.isEmpty()) {
|
||||
for (Method afterTaskMethod : afterTaskMethods.keySet()) {
|
||||
this.afterTaskInstances.computeIfAbsent(afterTaskMethod, k -> new LinkedHashSet<>())
|
||||
.add(this.context.getBean(beanName));
|
||||
.add(this.context.getBean(beanName));
|
||||
}
|
||||
}
|
||||
if (!failedTaskMethods.isEmpty()) {
|
||||
for (Method failedTaskMethod : failedTaskMethods.keySet()) {
|
||||
this.failedTaskInstances.computeIfAbsent(failedTaskMethod, k -> new LinkedHashSet<>())
|
||||
.add(this.context.getBean(beanName));
|
||||
.add(this.context.getBean(beanName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,18 +73,18 @@ public class TaskObservations {
|
||||
this.taskObservationContext = new TaskExecutionObservationContext(taskExecution);
|
||||
|
||||
Observation observation = TaskExecutionObservation.TASK_ACTIVE
|
||||
.observation(this.customObservationConvention, new DefaultTaskExecutionObservationConvention(),
|
||||
this.taskObservationContext, this.observationRegistry)
|
||||
.contextualName(String.valueOf(taskExecution.getExecutionId()))
|
||||
.observationConvention(this.observationsProvider)
|
||||
.lowCardinalityKeyValue(TaskExecutionObservation.TaskKeyValues.TASK_NAME.asString(),
|
||||
getValueOrDefault(taskExecution.getTaskName()))
|
||||
.lowCardinalityKeyValue(TaskExecutionObservation.TaskKeyValues.TASK_EXECUTION_ID.asString(),
|
||||
"" + taskExecution.getExecutionId())
|
||||
.lowCardinalityKeyValue(TaskExecutionObservation.TaskKeyValues.TASK_PARENT_EXECUTION_ID.asString(),
|
||||
(getValueOrDefault(taskExecution.getParentExecutionId())))
|
||||
.lowCardinalityKeyValue(TaskExecutionObservation.TaskKeyValues.TASK_EXTERNAL_EXECUTION_ID.asString(),
|
||||
(getValueOrDefault(taskExecution.getExternalExecutionId())));
|
||||
.observation(this.customObservationConvention, new DefaultTaskExecutionObservationConvention(),
|
||||
this.taskObservationContext, this.observationRegistry)
|
||||
.contextualName(String.valueOf(taskExecution.getExecutionId()))
|
||||
.observationConvention(this.observationsProvider)
|
||||
.lowCardinalityKeyValue(TaskExecutionObservation.TaskKeyValues.TASK_NAME.asString(),
|
||||
getValueOrDefault(taskExecution.getTaskName()))
|
||||
.lowCardinalityKeyValue(TaskExecutionObservation.TaskKeyValues.TASK_EXECUTION_ID.asString(),
|
||||
"" + taskExecution.getExecutionId())
|
||||
.lowCardinalityKeyValue(TaskExecutionObservation.TaskKeyValues.TASK_PARENT_EXECUTION_ID.asString(),
|
||||
(getValueOrDefault(taskExecution.getParentExecutionId())))
|
||||
.lowCardinalityKeyValue(TaskExecutionObservation.TaskKeyValues.TASK_EXTERNAL_EXECUTION_ID.asString(),
|
||||
(getValueOrDefault(taskExecution.getExternalExecutionId())));
|
||||
|
||||
if (taskObservationCloudKeyValues != null) {
|
||||
observation.lowCardinalityKeyValue(TaskExecutionObservation.TaskKeyValues.TASK_CF_ORG_NAME.asString(),
|
||||
|
||||
@@ -222,12 +222,13 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao {
|
||||
arguments, null, externalExecutionId);
|
||||
|
||||
final MapSqlParameterSource queryParameters = new MapSqlParameterSource()
|
||||
.addValue("taskExecutionId", nextExecutionId, Types.BIGINT).addValue("exitCode", null, Types.INTEGER)
|
||||
.addValue("startTime", startTime == null ? null : Timestamp.valueOf(startTime), Types.TIMESTAMP)
|
||||
.addValue("taskName", taskName, Types.VARCHAR)
|
||||
.addValue("lastUpdated", Timestamp.valueOf(LocalDateTime.now()), Types.TIMESTAMP)
|
||||
.addValue("externalExecutionId", externalExecutionId, Types.VARCHAR)
|
||||
.addValue("parentExecutionId", parentExecutionId, Types.BIGINT);
|
||||
.addValue("taskExecutionId", nextExecutionId, Types.BIGINT)
|
||||
.addValue("exitCode", null, Types.INTEGER)
|
||||
.addValue("startTime", startTime == null ? null : Timestamp.valueOf(startTime), Types.TIMESTAMP)
|
||||
.addValue("taskName", taskName, Types.VARCHAR)
|
||||
.addValue("lastUpdated", Timestamp.valueOf(LocalDateTime.now()), Types.TIMESTAMP)
|
||||
.addValue("externalExecutionId", externalExecutionId, Types.VARCHAR)
|
||||
.addValue("parentExecutionId", parentExecutionId, Types.BIGINT);
|
||||
|
||||
this.jdbcTemplate.update(getQuery(SAVE_TASK_EXECUTION), queryParameters);
|
||||
insertTaskArguments(nextExecutionId, arguments);
|
||||
@@ -247,11 +248,12 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao {
|
||||
null, externalExecutionId, parentExecutionId);
|
||||
|
||||
final MapSqlParameterSource queryParameters = new MapSqlParameterSource()
|
||||
.addValue("startTime", startTime == null ? null : Timestamp.valueOf(startTime), Types.TIMESTAMP)
|
||||
.addValue("exitCode", null, Types.INTEGER).addValue("taskName", taskName, Types.VARCHAR)
|
||||
.addValue("lastUpdated", Timestamp.valueOf(LocalDateTime.now()), Types.TIMESTAMP)
|
||||
.addValue("parentExecutionId", parentExecutionId, Types.BIGINT)
|
||||
.addValue("taskExecutionId", executionId, Types.BIGINT);
|
||||
.addValue("startTime", startTime == null ? null : Timestamp.valueOf(startTime), Types.TIMESTAMP)
|
||||
.addValue("exitCode", null, Types.INTEGER)
|
||||
.addValue("taskName", taskName, Types.VARCHAR)
|
||||
.addValue("lastUpdated", Timestamp.valueOf(LocalDateTime.now()), Types.TIMESTAMP)
|
||||
.addValue("parentExecutionId", parentExecutionId, Types.BIGINT)
|
||||
.addValue("taskExecutionId", executionId, Types.BIGINT);
|
||||
|
||||
String updateString = START_TASK_EXECUTION_PREFIX;
|
||||
|
||||
@@ -282,11 +284,12 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao {
|
||||
}
|
||||
|
||||
final MapSqlParameterSource parameters = new MapSqlParameterSource()
|
||||
.addValue("endTime", endTime == null ? null : Timestamp.valueOf(endTime), Types.TIMESTAMP)
|
||||
.addValue("exitCode", exitCode, Types.INTEGER).addValue("exitMessage", exitMessage, Types.VARCHAR)
|
||||
.addValue("errorMessage", errorMessage, Types.VARCHAR)
|
||||
.addValue("lastUpdated", Timestamp.valueOf(LocalDateTime.now()), Types.TIMESTAMP)
|
||||
.addValue("taskExecutionId", taskExecutionId, Types.BIGINT);
|
||||
.addValue("endTime", endTime == null ? null : Timestamp.valueOf(endTime), Types.TIMESTAMP)
|
||||
.addValue("exitCode", exitCode, Types.INTEGER)
|
||||
.addValue("exitMessage", exitMessage, Types.VARCHAR)
|
||||
.addValue("errorMessage", errorMessage, Types.VARCHAR)
|
||||
.addValue("lastUpdated", Timestamp.valueOf(LocalDateTime.now()), Types.TIMESTAMP)
|
||||
.addValue("taskExecutionId", taskExecutionId, Types.BIGINT);
|
||||
|
||||
this.jdbcTemplate.update(getQuery(UPDATE_TASK_EXECUTION), parameters);
|
||||
}
|
||||
@@ -503,8 +506,8 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao {
|
||||
@Override
|
||||
public void updateExternalExecutionId(long taskExecutionId, String externalExecutionId) {
|
||||
final MapSqlParameterSource queryParameters = new MapSqlParameterSource()
|
||||
.addValue("externalExecutionId", externalExecutionId, Types.VARCHAR)
|
||||
.addValue("taskExecutionId", taskExecutionId, Types.BIGINT);
|
||||
.addValue("externalExecutionId", externalExecutionId, Types.VARCHAR)
|
||||
.addValue("taskExecutionId", taskExecutionId, Types.BIGINT);
|
||||
|
||||
if (this.jdbcTemplate.update(getQuery(UPDATE_TASK_EXECUTION_EXTERNAL_EXECUTION_ID), queryParameters) != 1) {
|
||||
throw new IllegalStateException("Invalid TaskExecution, ID " + taskExecutionId + " not found.");
|
||||
@@ -580,8 +583,8 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao {
|
||||
*/
|
||||
private void insertArgument(long taskExecutionId, String taskParam) {
|
||||
final MapSqlParameterSource queryParameters = new MapSqlParameterSource()
|
||||
.addValue("taskExecutionId", taskExecutionId, Types.BIGINT)
|
||||
.addValue("taskParam", taskParam, Types.VARCHAR);
|
||||
.addValue("taskExecutionId", taskExecutionId, Types.BIGINT)
|
||||
.addValue("taskParam", taskParam, Types.VARCHAR);
|
||||
this.jdbcTemplate.update(getQuery(CREATE_TASK_ARGUMENT), queryParameters);
|
||||
}
|
||||
|
||||
|
||||
@@ -308,12 +308,12 @@ public class MapTaskExecutionDao implements TaskExecutionDao {
|
||||
}
|
||||
|
||||
final TaskExecution tempTaskExecution = tempTaskExecutions
|
||||
.get(taskExecutionMapEntry.getValue().getTaskName());
|
||||
.get(taskExecutionMapEntry.getValue().getTaskName());
|
||||
if (tempTaskExecution == null
|
||||
|| tempTaskExecution.getStartTime().isBefore(taskExecutionMapEntry.getValue().getStartTime())
|
||||
|| (tempTaskExecution.getStartTime().equals(taskExecutionMapEntry.getValue().getStartTime())
|
||||
&& tempTaskExecution.getExecutionId() < taskExecutionMapEntry.getValue()
|
||||
.getExecutionId())) {
|
||||
.getExecutionId())) {
|
||||
tempTaskExecutions.put(taskExecutionMapEntry.getValue().getTaskName(),
|
||||
taskExecutionMapEntry.getValue());
|
||||
}
|
||||
|
||||
@@ -38,8 +38,12 @@ public class Db2PagingQueryProvider extends AbstractSqlPagingQueryProvider {
|
||||
private String generateRowNumSqlQueryWithNesting(String selectClause, boolean remainingPageQuery,
|
||||
String rowNumClause) {
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("SELECT ").append(selectClause).append(" FROM (SELECT ").append(selectClause).append(", ")
|
||||
.append("ROW_NUMBER() OVER() as TMP_ROW_NUM");
|
||||
sql.append("SELECT ")
|
||||
.append(selectClause)
|
||||
.append(" FROM (SELECT ")
|
||||
.append(selectClause)
|
||||
.append(", ")
|
||||
.append("ROW_NUMBER() OVER() as TMP_ROW_NUM");
|
||||
sql.append(" FROM (SELECT ").append(selectClause).append(" FROM ").append(this.getFromClause());
|
||||
SqlPagingQueryUtils.buildWhereClause(this, remainingPageQuery, sql);
|
||||
sql.append(" ORDER BY ").append(SqlPagingQueryUtils.buildSortClause(this));
|
||||
|
||||
@@ -29,8 +29,12 @@ public class H2PagingQueryProvider extends AbstractSqlPagingQueryProvider {
|
||||
|
||||
@Override
|
||||
public String getPageQuery(Pageable pageable) {
|
||||
String limitClause = new StringBuilder().append("OFFSET ").append(pageable.getOffset())
|
||||
.append(" ROWS FETCH NEXT ").append(pageable.getPageSize()).append(" ROWS ONLY").toString();
|
||||
String limitClause = new StringBuilder().append("OFFSET ")
|
||||
.append(pageable.getOffset())
|
||||
.append(" ROWS FETCH NEXT ")
|
||||
.append(pageable.getPageSize())
|
||||
.append(" ROWS ONLY")
|
||||
.toString();
|
||||
return SqlPagingQueryUtils.generateLimitJumpToQuery(this, limitClause);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,8 +29,11 @@ public class HsqlPagingQueryProvider extends AbstractSqlPagingQueryProvider {
|
||||
|
||||
@Override
|
||||
public String getPageQuery(Pageable pageable) {
|
||||
String topClause = new StringBuilder().append("LIMIT ").append(pageable.getOffset()).append(" ")
|
||||
.append(pageable.getPageSize()).toString();
|
||||
String topClause = new StringBuilder().append("LIMIT ")
|
||||
.append(pageable.getOffset())
|
||||
.append(" ")
|
||||
.append(pageable.getPageSize())
|
||||
.toString();
|
||||
return SqlPagingQueryUtils.generateTopJumpToQuery(this, topClause);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,8 +29,11 @@ public class MariaDbPagingQueryProvider extends AbstractSqlPagingQueryProvider {
|
||||
|
||||
@Override
|
||||
public String getPageQuery(Pageable pageable) {
|
||||
String topClause = new StringBuilder().append("LIMIT ").append(pageable.getOffset()).append(", ")
|
||||
.append(pageable.getPageSize()).toString();
|
||||
String topClause = new StringBuilder().append("LIMIT ")
|
||||
.append(pageable.getOffset())
|
||||
.append(", ")
|
||||
.append(pageable.getPageSize())
|
||||
.toString();
|
||||
return SqlPagingQueryUtils.generateLimitJumpToQuery(this, topClause);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,11 @@ public class MySqlPagingQueryProvider extends AbstractSqlPagingQueryProvider {
|
||||
|
||||
@Override
|
||||
public String getPageQuery(Pageable pageable) {
|
||||
String topClause = new StringBuilder().append("LIMIT ").append(pageable.getOffset()).append(", ")
|
||||
.append(pageable.getPageSize()).toString();
|
||||
String topClause = new StringBuilder().append("LIMIT ")
|
||||
.append(pageable.getOffset())
|
||||
.append(", ")
|
||||
.append(pageable.getPageSize())
|
||||
.toString();
|
||||
return SqlPagingQueryUtils.generateLimitJumpToQuery(this, topClause);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,8 +37,12 @@ public class OraclePagingQueryProvider extends AbstractSqlPagingQueryProvider {
|
||||
private String generateRowNumSqlQueryWithNesting(String selectClause, boolean remainingPageQuery,
|
||||
String rowNumClause) {
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("SELECT ").append(selectClause).append(" FROM (SELECT ").append(selectClause).append(", ")
|
||||
.append("ROWNUM as TMP_ROW_NUM");
|
||||
sql.append("SELECT ")
|
||||
.append(selectClause)
|
||||
.append(" FROM (SELECT ")
|
||||
.append(selectClause)
|
||||
.append(", ")
|
||||
.append("ROWNUM as TMP_ROW_NUM");
|
||||
sql.append(" FROM (SELECT ").append(selectClause).append(" FROM ").append(this.getFromClause());
|
||||
SqlPagingQueryUtils.buildWhereClause(this, remainingPageQuery, sql);
|
||||
sql.append(" ORDER BY ").append(SqlPagingQueryUtils.buildSortClause(this));
|
||||
|
||||
@@ -29,8 +29,11 @@ public class PostgresPagingQueryProvider extends AbstractSqlPagingQueryProvider
|
||||
|
||||
@Override
|
||||
public String getPageQuery(Pageable pageable) {
|
||||
String limitClause = new StringBuilder().append("LIMIT ").append(pageable.getPageSize()).append(" OFFSET ")
|
||||
.append(pageable.getOffset()).toString();
|
||||
String limitClause = new StringBuilder().append("LIMIT ")
|
||||
.append(pageable.getPageSize())
|
||||
.append(" OFFSET ")
|
||||
.append(pageable.getOffset())
|
||||
.toString();
|
||||
return SqlPagingQueryUtils.generateLimitJumpToQuery(this, limitClause);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,9 +37,16 @@ public class SqlServerPagingQueryProvider extends AbstractSqlPagingQueryProvider
|
||||
private String generateRowNumSqlQueryWithNesting(String selectClause, boolean remainingPageQuery,
|
||||
String rowNumClause) {
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("SELECT ").append(selectClause).append(" FROM (SELECT ").append(selectClause).append(", ")
|
||||
.append("ROW_NUMBER() OVER (ORDER BY ").append(SqlPagingQueryUtils.buildSortClause(this))
|
||||
.append(") AS TMP_ROW_NUM ").append(" FROM ").append(getFromClause());
|
||||
sql.append("SELECT ")
|
||||
.append(selectClause)
|
||||
.append(" FROM (SELECT ")
|
||||
.append(selectClause)
|
||||
.append(", ")
|
||||
.append("ROW_NUMBER() OVER (ORDER BY ")
|
||||
.append(SqlPagingQueryUtils.buildSortClause(this))
|
||||
.append(") AS TMP_ROW_NUM ")
|
||||
.append(" FROM ")
|
||||
.append(getFromClause());
|
||||
SqlPagingQueryUtils.buildWhereClause(this, remainingPageQuery, sql);
|
||||
sql.append(") TASK_EXECUTION_PAGE ");
|
||||
sql.append(" WHERE ").append(rowNumClause);
|
||||
|
||||
@@ -125,14 +125,14 @@ public enum DatabaseType {
|
||||
if (StringUtils.hasText(databaseProductName) && !databaseProductName.equals("DB2/Linux")
|
||||
&& databaseProductName.startsWith("DB2")) {
|
||||
String databaseProductVersion = JdbcUtils
|
||||
.extractDatabaseMetaData(dataSource, new DatabaseMetaDataCallback() {
|
||||
.extractDatabaseMetaData(dataSource, new DatabaseMetaDataCallback() {
|
||||
|
||||
@Override
|
||||
public Object processMetaData(DatabaseMetaData dbmd)
|
||||
throws SQLException, MetaDataAccessException {
|
||||
return dbmd.getDatabaseProductVersion();
|
||||
}
|
||||
}).toString();
|
||||
@Override
|
||||
public Object processMetaData(DatabaseMetaData dbmd) throws SQLException, MetaDataAccessException {
|
||||
return dbmd.getDatabaseProductVersion();
|
||||
}
|
||||
})
|
||||
.toString();
|
||||
|
||||
if (databaseProductVersion.startsWith("ARI")) {
|
||||
databaseProductName = "DB2VSE";
|
||||
@@ -140,9 +140,9 @@ public enum DatabaseType {
|
||||
else if (databaseProductVersion.startsWith("DSN")) {
|
||||
databaseProductName = "DB2ZOS";
|
||||
}
|
||||
else if (databaseProductName.indexOf("AS") != -1
|
||||
&& (databaseProductVersion.startsWith("QSQ") || databaseProductVersion
|
||||
.substring(databaseProductVersion.indexOf('V')).matches("V\\dR\\d[mM]\\d"))) {
|
||||
else if (databaseProductName.indexOf("AS") != -1 && (databaseProductVersion.startsWith("QSQ")
|
||||
|| databaseProductVersion.substring(databaseProductVersion.indexOf('V'))
|
||||
.matches("V\\dR\\d[mM]\\d"))) {
|
||||
databaseProductName = "DB2AS400";
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -137,7 +137,7 @@ public class TaskExecutionDaoFactoryBean implements FactoryBean<TaskExecutionDao
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
((JdbcTaskExecutionDao) this.dao)
|
||||
.setTaskIncrementer(incrementerFactory.getIncrementer(databaseType, this.tablePrefix + "SEQ"));
|
||||
.setTaskIncrementer(incrementerFactory.getIncrementer(databaseType, this.tablePrefix + "SEQ"));
|
||||
}
|
||||
|
||||
private boolean isSqlServerTableSequenceAvailable(String incrementerName) {
|
||||
|
||||
@@ -40,9 +40,9 @@ public class SimpleSingleTaskAutoConfigurationTests {
|
||||
public void testConfiguration() {
|
||||
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class,
|
||||
SimpleTaskAutoConfiguration.class, SingleTaskConfiguration.class))
|
||||
.withPropertyValues("spring.cloud.task.singleInstanceEnabled=true");
|
||||
.withConfiguration(AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class,
|
||||
SimpleTaskAutoConfiguration.class, SingleTaskConfiguration.class))
|
||||
.withPropertyValues("spring.cloud.task.singleInstanceEnabled=true");
|
||||
applicationContextRunner.run((context) -> {
|
||||
SingleInstanceTaskListener singleInstanceTaskListener = context.getBean(SingleInstanceTaskListener.class);
|
||||
|
||||
|
||||
@@ -41,10 +41,10 @@ public class SimpleSingleTaskAutoConfigurationWithDataSourceTests {
|
||||
public void testConfiguration() {
|
||||
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class,
|
||||
SimpleTaskAutoConfiguration.class, SingleTaskConfiguration.class,
|
||||
EmbeddedDataSourceConfiguration.class))
|
||||
.withPropertyValues("spring.cloud.task.singleInstanceEnabled=true");
|
||||
.withConfiguration(
|
||||
AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class, SimpleTaskAutoConfiguration.class,
|
||||
SingleTaskConfiguration.class, EmbeddedDataSourceConfiguration.class))
|
||||
.withPropertyValues("spring.cloud.task.singleInstanceEnabled=true");
|
||||
applicationContextRunner.run((context) -> {
|
||||
SingleInstanceTaskListener singleInstanceTaskListener = context.getBean(SingleInstanceTaskListener.class);
|
||||
|
||||
|
||||
@@ -63,8 +63,8 @@ public class SimpleTaskAutoConfigurationTests {
|
||||
@Test
|
||||
public void testRepository() {
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class,
|
||||
SimpleTaskAutoConfiguration.class, SingleTaskConfiguration.class));
|
||||
.withConfiguration(AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class,
|
||||
SimpleTaskAutoConfiguration.class, SingleTaskConfiguration.class));
|
||||
applicationContextRunner.run((context) -> {
|
||||
|
||||
TaskRepository taskRepository = context.getBean(TaskRepository.class);
|
||||
@@ -77,9 +77,9 @@ public class SimpleTaskAutoConfigurationTests {
|
||||
@Test
|
||||
public void testAutoConfigurationDisabled() {
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class,
|
||||
SimpleTaskAutoConfiguration.class, SingleTaskConfiguration.class))
|
||||
.withPropertyValues("spring.cloud.task.autoconfiguration.enabled=false");
|
||||
.withConfiguration(AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class,
|
||||
SimpleTaskAutoConfiguration.class, SingleTaskConfiguration.class))
|
||||
.withPropertyValues("spring.cloud.task.autoconfiguration.enabled=false");
|
||||
Executable executable = () -> {
|
||||
applicationContextRunner.run((context) -> {
|
||||
context.getBean(TaskRepository.class);
|
||||
@@ -93,10 +93,11 @@ public class SimpleTaskAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testRepositoryInitialized() {
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner().withConfiguration(
|
||||
AutoConfigurations.of(EmbeddedDataSourceConfiguration.class, PropertyPlaceholderAutoConfiguration.class,
|
||||
SimpleTaskAutoConfiguration.class, SingleTaskConfiguration.class))
|
||||
.withUserConfiguration(TaskLifecycleListenerConfiguration.class);
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(EmbeddedDataSourceConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class, SimpleTaskAutoConfiguration.class,
|
||||
SingleTaskConfiguration.class))
|
||||
.withUserConfiguration(TaskLifecycleListenerConfiguration.class);
|
||||
applicationContextRunner.run((context) -> {
|
||||
TaskExplorer taskExplorer = context.getBean(TaskExplorer.class);
|
||||
assertThat(taskExplorer.getTaskExecutionCount()).isEqualTo(1L);
|
||||
@@ -105,17 +106,18 @@ public class SimpleTaskAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testRepositoryBeansDependOnTaskRepositoryInitializer() {
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner().withConfiguration(
|
||||
AutoConfigurations.of(EmbeddedDataSourceConfiguration.class, PropertyPlaceholderAutoConfiguration.class,
|
||||
SimpleTaskAutoConfiguration.class, SingleTaskConfiguration.class))
|
||||
.withUserConfiguration(TaskLifecycleListenerConfiguration.class);
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(EmbeddedDataSourceConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class, SimpleTaskAutoConfiguration.class,
|
||||
SingleTaskConfiguration.class))
|
||||
.withUserConfiguration(TaskLifecycleListenerConfiguration.class);
|
||||
applicationContextRunner.run((context) -> {
|
||||
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
|
||||
String[] taskRepositoryNames = beanFactory.getBeanNamesForType(TaskRepository.class);
|
||||
assertThat(taskRepositoryNames).isNotEmpty();
|
||||
for (String taskRepositoryName : taskRepositoryNames) {
|
||||
assertThat(beanFactory.getBeanDefinition(taskRepositoryName).getDependsOn())
|
||||
.contains("taskRepositoryInitializer");
|
||||
.contains("taskRepositoryInitializer");
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -123,11 +125,11 @@ public class SimpleTaskAutoConfigurationTests {
|
||||
@Test
|
||||
public void testRepositoryNotInitialized() {
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(EmbeddedDataSourceConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class, SimpleTaskAutoConfiguration.class,
|
||||
SingleTaskConfiguration.class))
|
||||
.withUserConfiguration(TaskLifecycleListenerConfiguration.class)
|
||||
.withPropertyValues("spring.cloud.task.tablePrefix=foobarless");
|
||||
.withConfiguration(AutoConfigurations.of(EmbeddedDataSourceConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class, SimpleTaskAutoConfiguration.class,
|
||||
SingleTaskConfiguration.class))
|
||||
.withUserConfiguration(TaskLifecycleListenerConfiguration.class)
|
||||
.withPropertyValues("spring.cloud.task.tablePrefix=foobarless");
|
||||
|
||||
verifyExceptionThrownDefaultExecutable(ApplicationContextException.class, applicationContextRunner);
|
||||
}
|
||||
@@ -135,11 +137,11 @@ public class SimpleTaskAutoConfigurationTests {
|
||||
@Test
|
||||
public void testTaskNameResolver() {
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(EmbeddedDataSourceConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class, SimpleTaskAutoConfiguration.class,
|
||||
SingleTaskConfiguration.class))
|
||||
.withUserConfiguration(TaskLifecycleListenerConfiguration.class)
|
||||
.withPropertyValues("spring.cloud.task.name=myTestName");
|
||||
.withConfiguration(AutoConfigurations.of(EmbeddedDataSourceConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class, SimpleTaskAutoConfiguration.class,
|
||||
SingleTaskConfiguration.class))
|
||||
.withUserConfiguration(TaskLifecycleListenerConfiguration.class)
|
||||
.withPropertyValues("spring.cloud.task.name=myTestName");
|
||||
applicationContextRunner.run((context) -> {
|
||||
TaskNameResolver taskNameResolver = context.getBean(TaskNameResolver.class);
|
||||
assertThat(taskNameResolver.getTaskName()).isEqualTo("myTestName");
|
||||
@@ -149,9 +151,9 @@ public class SimpleTaskAutoConfigurationTests {
|
||||
@Test
|
||||
public void testMultipleConfigurers() {
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class,
|
||||
SimpleTaskAutoConfiguration.class, SingleTaskConfiguration.class))
|
||||
.withUserConfiguration(MultipleConfigurers.class);
|
||||
.withConfiguration(AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class,
|
||||
SimpleTaskAutoConfiguration.class, SingleTaskConfiguration.class))
|
||||
.withUserConfiguration(MultipleConfigurers.class);
|
||||
|
||||
verifyExceptionThrownDefaultExecutable(BeanCreationException.class,
|
||||
"Error creating bean " + "with name 'simpleTaskAutoConfiguration': Invocation of init method failed",
|
||||
@@ -161,9 +163,9 @@ public class SimpleTaskAutoConfigurationTests {
|
||||
@Test
|
||||
public void testMultipleDataSources() {
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class,
|
||||
SimpleTaskAutoConfiguration.class, SingleTaskConfiguration.class))
|
||||
.withUserConfiguration(MultipleDataSources.class);
|
||||
.withConfiguration(AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class,
|
||||
SimpleTaskAutoConfiguration.class, SingleTaskConfiguration.class))
|
||||
.withUserConfiguration(MultipleDataSources.class);
|
||||
|
||||
verifyExceptionThrownDefaultExecutable(BeanCreationException.class,
|
||||
"Error creating bean " + "with name 'simpleTaskAutoConfiguration': Invocation of init method failed",
|
||||
@@ -205,10 +207,11 @@ public class SimpleTaskAutoConfigurationTests {
|
||||
*/
|
||||
@Test
|
||||
public void testWithDataSourceProxy() {
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner().withConfiguration(
|
||||
AutoConfigurations.of(EmbeddedDataSourceConfiguration.class, PropertyPlaceholderAutoConfiguration.class,
|
||||
SimpleTaskAutoConfiguration.class, SingleTaskConfiguration.class))
|
||||
.withUserConfiguration(DataSourceProxyConfiguration.class);
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(EmbeddedDataSourceConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class, SimpleTaskAutoConfiguration.class,
|
||||
SingleTaskConfiguration.class))
|
||||
.withUserConfiguration(DataSourceProxyConfiguration.class);
|
||||
applicationContextRunner.run((context) -> {
|
||||
assertThat(context.getBeanNamesForType(DataSource.class).length).isEqualTo(2);
|
||||
SimpleTaskAutoConfiguration taskConfiguration = context.getBean(SimpleTaskAutoConfiguration.class);
|
||||
|
||||
@@ -77,11 +77,11 @@ public class TaskCoreTests {
|
||||
|
||||
String output = capturedOutput.toString();
|
||||
assertThat(output.contains(CREATE_TASK_MESSAGE)).as("Test results do not show create task message: " + output)
|
||||
.isTrue();
|
||||
.isTrue();
|
||||
assertThat(output.contains(UPDATE_TASK_MESSAGE)).as("Test results do not show success message: " + output)
|
||||
.isTrue();
|
||||
.isTrue();
|
||||
assertThat(output.contains(SUCCESS_EXIT_CODE_MESSAGE)).as("Test results have incorrect exit code: " + output)
|
||||
.isTrue();
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,11 +95,11 @@ public class TaskCoreTests {
|
||||
|
||||
String output = capturedOutput.toString();
|
||||
assertThat(output.contains(CREATE_TASK_MESSAGE)).as("Test results do not show create task message: " + output)
|
||||
.isTrue();
|
||||
.isTrue();
|
||||
assertThat(output.contains(UPDATE_TASK_MESSAGE)).as("Test results do not show success message: " + output)
|
||||
.isTrue();
|
||||
.isTrue();
|
||||
assertThat(output.contains(SUCCESS_EXIT_CODE_MESSAGE)).as("Test results have incorrect exit code: " + output)
|
||||
.isTrue();
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -117,11 +117,11 @@ public class TaskCoreTests {
|
||||
|
||||
String output = capturedOutput.toString();
|
||||
assertThat(output.contains(CREATE_TASK_MESSAGE)).as("Test results do not show create task message: " + output)
|
||||
.isTrue();
|
||||
.isTrue();
|
||||
assertThat(output.contains(UPDATE_TASK_MESSAGE)).as("Test results do not show success message: " + output)
|
||||
.isTrue();
|
||||
.isTrue();
|
||||
assertThat(output.contains(EXCEPTION_EXIT_CODE_MESSAGE)).as("Test results have incorrect exit code: " + output)
|
||||
.isTrue();
|
||||
.isTrue();
|
||||
assertThat(output.contains(ERROR_MESSAGE)).as("Test results have incorrect exit message: " + output).isTrue();
|
||||
assertThat(output.contains(EXCEPTION_MESSAGE)).as("Test results have exception message: " + output).isTrue();
|
||||
}
|
||||
@@ -141,7 +141,8 @@ public class TaskCoreTests {
|
||||
|
||||
String output = capturedOutput.toString();
|
||||
assertThat(output.contains(EXCEPTION_INVALID_TASK_EXECUTION_ID))
|
||||
.as("Test results do not show the correct exception message: " + output).isTrue();
|
||||
.as("Test results do not show the correct exception message: " + output)
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@EnableTask
|
||||
|
||||
@@ -52,10 +52,10 @@ public class DefaultTaskConfigurerTests {
|
||||
public void resourcelessTransactionManagerTest() {
|
||||
DefaultTaskConfigurer defaultTaskConfigurer = new DefaultTaskConfigurer();
|
||||
assertThat(defaultTaskConfigurer.getTransactionManager().getClass().getName())
|
||||
.isEqualTo("org.springframework.batch.support.transaction.ResourcelessTransactionManager");
|
||||
.isEqualTo("org.springframework.batch.support.transaction.ResourcelessTransactionManager");
|
||||
defaultTaskConfigurer = new DefaultTaskConfigurer("foo");
|
||||
assertThat(defaultTaskConfigurer.getTransactionManager().getClass().getName())
|
||||
.isEqualTo("org.springframework.batch.support.transaction.ResourcelessTransactionManager");
|
||||
.isEqualTo("org.springframework.batch.support.transaction.ResourcelessTransactionManager");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -66,20 +66,20 @@ public class DefaultTaskConfigurerTests {
|
||||
DefaultTaskConfigurer defaultTaskConfigurer = new DefaultTaskConfigurer(this.dataSource,
|
||||
TaskProperties.DEFAULT_TABLE_PREFIX, localContext);
|
||||
assertThat(defaultTaskConfigurer.getTransactionManager().getClass().getName())
|
||||
.isEqualTo("org.springframework.jdbc.support.JdbcTransactionManager");
|
||||
.isEqualTo("org.springframework.jdbc.support.JdbcTransactionManager");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dataSourceTransactionManagerTest() {
|
||||
DefaultTaskConfigurer defaultTaskConfigurer = new DefaultTaskConfigurer(this.dataSource);
|
||||
assertThat(defaultTaskConfigurer.getTransactionManager().getClass().getName())
|
||||
.isEqualTo("org.springframework.jdbc.support.JdbcTransactionManager");
|
||||
.isEqualTo("org.springframework.jdbc.support.JdbcTransactionManager");
|
||||
defaultTaskConfigurer = new DefaultTaskConfigurer(this.dataSource, "FOO", null);
|
||||
assertThat(defaultTaskConfigurer.getTransactionManager().getClass().getName())
|
||||
.isEqualTo("org.springframework.jdbc.support.JdbcTransactionManager");
|
||||
.isEqualTo("org.springframework.jdbc.support.JdbcTransactionManager");
|
||||
defaultTaskConfigurer = new DefaultTaskConfigurer(this.dataSource, "FOO", this.context);
|
||||
assertThat(defaultTaskConfigurer.getTransactionManager().getClass().getName())
|
||||
.isEqualTo("org.springframework.jdbc.support.JdbcTransactionManager");
|
||||
.isEqualTo("org.springframework.jdbc.support.JdbcTransactionManager");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -51,9 +51,9 @@ public class RepositoryTransactionManagerConfigurationTests {
|
||||
@Test
|
||||
public void testZeroCustomTransactionManagerConfiguration() {
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class,
|
||||
SimpleTaskAutoConfiguration.class, ZeroTransactionManagerConfiguration.class))
|
||||
.withPropertyValues("application.name=transactionManagerTask");
|
||||
.withConfiguration(AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class,
|
||||
SimpleTaskAutoConfiguration.class, ZeroTransactionManagerConfiguration.class))
|
||||
.withPropertyValues("application.name=transactionManagerTask");
|
||||
|
||||
applicationContextRunner.run((context) -> {
|
||||
DataSource dataSource = context.getBean("dataSource", DataSource.class);
|
||||
@@ -76,9 +76,9 @@ public class RepositoryTransactionManagerConfigurationTests {
|
||||
|
||||
private void testConfiguration(Class configurationClass) {
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class,
|
||||
SimpleTaskAutoConfiguration.class, configurationClass))
|
||||
.withPropertyValues("application.name=transactionManagerTask");
|
||||
.withConfiguration(AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class,
|
||||
SimpleTaskAutoConfiguration.class, configurationClass))
|
||||
.withPropertyValues("application.name=transactionManagerTask");
|
||||
|
||||
applicationContextRunner.run((context) -> {
|
||||
DataSource dataSource = context.getBean("dataSource", DataSource.class);
|
||||
|
||||
@@ -63,15 +63,17 @@ class ObservationIntegrationTests {
|
||||
void testSuccessfulObservation() {
|
||||
List<FinishedSpan> finishedSpans = finishedSpans();
|
||||
|
||||
SpansAssert.then(finishedSpans).thenASpanWithNameEqualTo("my-command-line-runner")
|
||||
.hasTag("spring.cloud.task.runner.bean-name", "myCommandLineRunner").backToSpans()
|
||||
.thenASpanWithNameEqualTo("my-application-runner")
|
||||
.hasTag("spring.cloud.task.runner.bean-name", "myApplicationRunner");
|
||||
SpansAssert.then(finishedSpans)
|
||||
.thenASpanWithNameEqualTo("my-command-line-runner")
|
||||
.hasTag("spring.cloud.task.runner.bean-name", "myCommandLineRunner")
|
||||
.backToSpans()
|
||||
.thenASpanWithNameEqualTo("my-application-runner")
|
||||
.hasTag("spring.cloud.task.runner.bean-name", "myApplicationRunner");
|
||||
MeterRegistryAssert.then(this.meterRegistry)
|
||||
.hasTimerWithNameAndTags("spring.cloud.task.runner",
|
||||
KeyValues.of("spring.cloud.task.runner.bean-name", "myCommandLineRunner"))
|
||||
.hasTimerWithNameAndTags("spring.cloud.task.runner",
|
||||
KeyValues.of("spring.cloud.task.runner.bean-name", "myApplicationRunner"));
|
||||
.hasTimerWithNameAndTags("spring.cloud.task.runner",
|
||||
KeyValues.of("spring.cloud.task.runner.bean-name", "myCommandLineRunner"))
|
||||
.hasTimerWithNameAndTags("spring.cloud.task.runner",
|
||||
KeyValues.of("spring.cloud.task.runner.bean-name", "myApplicationRunner"));
|
||||
}
|
||||
|
||||
private List<FinishedSpan> finishedSpans() {
|
||||
|
||||
@@ -80,7 +80,7 @@ public class TaskExecutionListenerTests {
|
||||
public void testTaskCreate() {
|
||||
setupContextForTaskExecutionListener();
|
||||
DefaultTaskListenerConfiguration.TestTaskExecutionListener taskExecutionListener = this.context
|
||||
.getBean(DefaultTaskListenerConfiguration.TestTaskExecutionListener.class);
|
||||
.getBean(DefaultTaskListenerConfiguration.TestTaskExecutionListener.class);
|
||||
TaskExecution taskExecution = new TaskExecution(0, null, "wombat", LocalDateTime.now(), LocalDateTime.now(),
|
||||
null, new ArrayList<>(), null, null);
|
||||
verifyListenerResults(false, false, taskExecution, taskExecutionListener);
|
||||
@@ -131,15 +131,16 @@ public class TaskExecutionListenerTests {
|
||||
public void testAfterTaskErrorCreate() {
|
||||
setupContextForAfterTaskErrorAnnotatedListener();
|
||||
AfterTaskErrorAnnotationConfiguration.AnnotatedTaskListener taskExecutionListener = this.context
|
||||
.getBean(AfterTaskErrorAnnotationConfiguration.AnnotatedTaskListener.class);
|
||||
.getBean(AfterTaskErrorAnnotationConfiguration.AnnotatedTaskListener.class);
|
||||
this.context.publishEvent(new ApplicationReadyEvent(new SpringApplication(), new String[0], this.context,
|
||||
Duration.ofSeconds(50)));
|
||||
|
||||
assertThat(taskExecutionListener.isTaskStartup()).isTrue();
|
||||
assertThat(taskExecutionListener.isTaskEnd()).isTrue();
|
||||
assertThat(taskExecutionListener.getTaskExecution().getExitMessage()).isEqualTo(TestListener.END_MESSAGE);
|
||||
assertThat(taskExecutionListener.getTaskExecution().getErrorMessage()
|
||||
.contains("Failed to process @BeforeTask or @AfterTask annotation because: AfterTaskFailure")).isTrue();
|
||||
assertThat(taskExecutionListener.getTaskExecution()
|
||||
.getErrorMessage()
|
||||
.contains("Failed to process @BeforeTask or @AfterTask annotation because: AfterTaskFailure")).isTrue();
|
||||
assertThat(taskExecutionListener.getThrowable()).isNull();
|
||||
}
|
||||
|
||||
@@ -151,7 +152,7 @@ public class TaskExecutionListenerTests {
|
||||
public void testTaskUpdate() {
|
||||
setupContextForTaskExecutionListener();
|
||||
DefaultTaskListenerConfiguration.TestTaskExecutionListener taskExecutionListener = this.context
|
||||
.getBean(DefaultTaskListenerConfiguration.TestTaskExecutionListener.class);
|
||||
.getBean(DefaultTaskListenerConfiguration.TestTaskExecutionListener.class);
|
||||
this.context.publishEvent(new ApplicationReadyEvent(new SpringApplication(), new String[0], this.context,
|
||||
Duration.ofSeconds(50)));
|
||||
|
||||
@@ -170,10 +171,10 @@ public class TaskExecutionListenerTests {
|
||||
setupContextForTaskExecutionListener();
|
||||
SpringApplication application = new SpringApplication();
|
||||
DefaultTaskListenerConfiguration.TestTaskExecutionListener taskExecutionListener = this.context
|
||||
.getBean(DefaultTaskListenerConfiguration.TestTaskExecutionListener.class);
|
||||
.getBean(DefaultTaskListenerConfiguration.TestTaskExecutionListener.class);
|
||||
this.context.publishEvent(new ApplicationFailedEvent(application, new String[0], this.context, exception));
|
||||
this.context.publishEvent(
|
||||
new ApplicationReadyEvent(application, new String[0], this.context, Duration.ofSeconds(50)));
|
||||
this.context
|
||||
.publishEvent(new ApplicationReadyEvent(application, new String[0], this.context, Duration.ofSeconds(50)));
|
||||
|
||||
TaskExecution taskExecution = new TaskExecution(0, 1, "wombat", LocalDateTime.now(), LocalDateTime.now(), null,
|
||||
new ArrayList<>(), null, null);
|
||||
@@ -188,7 +189,7 @@ public class TaskExecutionListenerTests {
|
||||
public void testAnnotationCreate() {
|
||||
setupContextForAnnotatedListener();
|
||||
DefaultAnnotationConfiguration.AnnotatedTaskListener annotatedListener = this.context
|
||||
.getBean(DefaultAnnotationConfiguration.AnnotatedTaskListener.class);
|
||||
.getBean(DefaultAnnotationConfiguration.AnnotatedTaskListener.class);
|
||||
TaskExecution taskExecution = new TaskExecution(0, null, "wombat", LocalDateTime.now(), LocalDateTime.now(),
|
||||
null, new ArrayList<>(), null, null);
|
||||
verifyListenerResults(false, false, taskExecution, annotatedListener);
|
||||
@@ -202,7 +203,7 @@ public class TaskExecutionListenerTests {
|
||||
public void testAnnotationUpdate() {
|
||||
setupContextForAnnotatedListener();
|
||||
DefaultAnnotationConfiguration.AnnotatedTaskListener annotatedListener = this.context
|
||||
.getBean(DefaultAnnotationConfiguration.AnnotatedTaskListener.class);
|
||||
.getBean(DefaultAnnotationConfiguration.AnnotatedTaskListener.class);
|
||||
this.context.publishEvent(new ApplicationReadyEvent(new SpringApplication(), new String[0], this.context,
|
||||
Duration.ofSeconds(50)));
|
||||
|
||||
@@ -221,10 +222,10 @@ public class TaskExecutionListenerTests {
|
||||
setupContextForAnnotatedListener();
|
||||
SpringApplication application = new SpringApplication();
|
||||
DefaultAnnotationConfiguration.AnnotatedTaskListener annotatedListener = this.context
|
||||
.getBean(DefaultAnnotationConfiguration.AnnotatedTaskListener.class);
|
||||
.getBean(DefaultAnnotationConfiguration.AnnotatedTaskListener.class);
|
||||
this.context.publishEvent(new ApplicationFailedEvent(application, new String[0], this.context, exception));
|
||||
this.context.publishEvent(
|
||||
new ApplicationReadyEvent(application, new String[0], this.context, Duration.ofSeconds(50)));
|
||||
this.context
|
||||
.publishEvent(new ApplicationReadyEvent(application, new String[0], this.context, Duration.ofSeconds(50)));
|
||||
|
||||
TaskExecution taskExecution = new TaskExecution(0, 1, "wombat", LocalDateTime.now(), LocalDateTime.now(), null,
|
||||
new ArrayList<>(), null, null);
|
||||
@@ -240,8 +241,9 @@ public class TaskExecutionListenerTests {
|
||||
assertThat(actualListener.getTaskExecution().getExitMessage()).isEqualTo(TestListener.END_MESSAGE);
|
||||
assertThat(actualListener.getThrowable()).isNotNull();
|
||||
assertThat(actualListener.getThrowable() instanceof RuntimeException).isTrue();
|
||||
assertThat(actualListener.getTaskExecution().getErrorMessage()
|
||||
.startsWith("java.lang.RuntimeException: This was expected")).isTrue();
|
||||
assertThat(actualListener.getTaskExecution()
|
||||
.getErrorMessage()
|
||||
.startsWith("java.lang.RuntimeException: This was expected")).isTrue();
|
||||
}
|
||||
else if (isTaskEnd) {
|
||||
assertThat(actualListener.getTaskExecution().getExitMessage()).isEqualTo(TestListener.END_MESSAGE);
|
||||
@@ -257,7 +259,7 @@ public class TaskExecutionListenerTests {
|
||||
assertThat(actualListener.getTaskExecution().getExecutionId()).isEqualTo(taskExecution.getExecutionId());
|
||||
assertThat(actualListener.getTaskExecution().getExitCode()).isEqualTo(taskExecution.getExitCode());
|
||||
assertThat(actualListener.getTaskExecution().getExternalExecutionId())
|
||||
.isEqualTo(taskExecution.getExternalExecutionId());
|
||||
.isEqualTo(taskExecution.getExternalExecutionId());
|
||||
}
|
||||
|
||||
private void setupContextForTaskExecutionListener() {
|
||||
|
||||
@@ -130,8 +130,8 @@ public class TaskLifecycleListenerTests {
|
||||
SpringApplication application = new SpringApplication();
|
||||
this.taskExplorer = this.context.getBean(TaskExplorer.class);
|
||||
this.context.publishEvent(new ApplicationFailedEvent(application, new String[0], this.context, exception));
|
||||
this.context.publishEvent(
|
||||
new ApplicationReadyEvent(application, new String[0], this.context, Duration.ofSeconds(50)));
|
||||
this.context
|
||||
.publishEvent(new ApplicationReadyEvent(application, new String[0], this.context, Duration.ofSeconds(50)));
|
||||
|
||||
verifyTaskExecution(0, true, 1, exception, null);
|
||||
}
|
||||
@@ -148,8 +148,8 @@ public class TaskLifecycleListenerTests {
|
||||
this.taskExplorer = this.context.getBean(TaskExplorer.class);
|
||||
this.context.publishEvent(new ExitCodeEvent(this.context, exitCode));
|
||||
this.context.publishEvent(new ApplicationFailedEvent(application, new String[0], this.context, exception));
|
||||
this.context.publishEvent(
|
||||
new ApplicationReadyEvent(application, new String[0], this.context, Duration.ofSeconds(50)));
|
||||
this.context
|
||||
.publishEvent(new ApplicationReadyEvent(application, new String[0], this.context, Duration.ofSeconds(50)));
|
||||
|
||||
verifyTaskExecution(0, true, exitCode, exception, null);
|
||||
assertThat(TestListener.getStartupOrderList().size()).isEqualTo(2);
|
||||
@@ -197,7 +197,8 @@ public class TaskLifecycleListenerTests {
|
||||
taskLifecycleListener.start();
|
||||
String output = capturedOutput.toString();
|
||||
assertThat(output.contains("Multiple start events have been received"))
|
||||
.as("Test results do not show error message: " + output).isTrue();
|
||||
.as("Test results do not show error message: " + output)
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -266,7 +267,8 @@ public class TaskLifecycleListenerTests {
|
||||
|
||||
if (update) {
|
||||
assertThat(taskExecution.getEndTime().isAfter(taskExecution.getStartTime())
|
||||
|| taskExecution.getEndTime().isEqual(taskExecution.getStartTime())).isTrue();
|
||||
|| taskExecution.getEndTime().isEqual(taskExecution.getStartTime()))
|
||||
.isTrue();
|
||||
assertThat(taskExecution.getExitCode()).isNotNull();
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -83,7 +83,7 @@ public class TaskListenerExecutorObjectFactoryTests {
|
||||
@Test
|
||||
public void verifyTaskStartupListener() {
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
|
||||
.withUserConfiguration(TaskExecutionListenerConfiguration.class);
|
||||
.withUserConfiguration(TaskExecutionListenerConfiguration.class);
|
||||
|
||||
applicationContextRunner.run((context) -> {
|
||||
setup(context);
|
||||
@@ -96,7 +96,7 @@ public class TaskListenerExecutorObjectFactoryTests {
|
||||
@Test
|
||||
public void verifyTaskFailedListener() {
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
|
||||
.withUserConfiguration(TaskExecutionListenerConfiguration.class);
|
||||
.withUserConfiguration(TaskExecutionListenerConfiguration.class);
|
||||
|
||||
applicationContextRunner.run((context) -> {
|
||||
setup(context);
|
||||
@@ -110,7 +110,7 @@ public class TaskListenerExecutorObjectFactoryTests {
|
||||
@Test
|
||||
public void verifyTaskEndListener() {
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
|
||||
.withUserConfiguration(TaskExecutionListenerConfiguration.class);
|
||||
.withUserConfiguration(TaskExecutionListenerConfiguration.class);
|
||||
|
||||
applicationContextRunner.run((context) -> {
|
||||
setup(context);
|
||||
@@ -123,7 +123,7 @@ public class TaskListenerExecutorObjectFactoryTests {
|
||||
@Test
|
||||
public void verifyAllListener() {
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
|
||||
.withUserConfiguration(TaskExecutionListenerConfiguration.class);
|
||||
.withUserConfiguration(TaskExecutionListenerConfiguration.class);
|
||||
|
||||
applicationContextRunner.run((context) -> {
|
||||
setup(context);
|
||||
@@ -142,7 +142,7 @@ public class TaskListenerExecutorObjectFactoryTests {
|
||||
@Test
|
||||
public void verifyTaskStartupListenerWithMultipleInstances() {
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
|
||||
.withUserConfiguration(TaskExecutionListenerMultipleInstanceConfiguration.class);
|
||||
.withUserConfiguration(TaskExecutionListenerMultipleInstanceConfiguration.class);
|
||||
|
||||
applicationContextRunner.run((context) -> {
|
||||
setup(context);
|
||||
@@ -155,7 +155,7 @@ public class TaskListenerExecutorObjectFactoryTests {
|
||||
@Test
|
||||
public void verifyTaskFailedListenerWithMultipleInstances() {
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
|
||||
.withUserConfiguration(TaskExecutionListenerMultipleInstanceConfiguration.class);
|
||||
.withUserConfiguration(TaskExecutionListenerMultipleInstanceConfiguration.class);
|
||||
|
||||
applicationContextRunner.run((context) -> {
|
||||
setup(context);
|
||||
@@ -169,7 +169,7 @@ public class TaskListenerExecutorObjectFactoryTests {
|
||||
@Test
|
||||
public void verifyTaskEndListenerWithMultipleInstances() {
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
|
||||
.withUserConfiguration(TaskExecutionListenerMultipleInstanceConfiguration.class);
|
||||
.withUserConfiguration(TaskExecutionListenerMultipleInstanceConfiguration.class);
|
||||
|
||||
applicationContextRunner.run((context) -> {
|
||||
setup(context);
|
||||
@@ -182,7 +182,7 @@ public class TaskListenerExecutorObjectFactoryTests {
|
||||
@Test
|
||||
public void verifyAllListenerWithMultipleInstances() {
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
|
||||
.withUserConfiguration(TaskExecutionListenerMultipleInstanceConfiguration.class);
|
||||
.withUserConfiguration(TaskExecutionListenerMultipleInstanceConfiguration.class);
|
||||
|
||||
applicationContextRunner.run((context) -> {
|
||||
setup(context);
|
||||
|
||||
@@ -90,7 +90,8 @@ public class TaskObservationsTests {
|
||||
|
||||
verifyDefaultKeyValues();
|
||||
TaskExecutionObservation.TASK_ACTIVE.getDefaultConvention();
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags("spring.cloud.task", Tags
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags("spring.cloud.task", Tags
|
||||
.of(TaskExecutionObservation.TaskKeyValues.TASK_STATUS.asString(), TaskObservations.STATUS_SUCCESS));
|
||||
|
||||
verifyLongTaskTimerAfterStop(longTaskTimer, "myTask72", "123");
|
||||
@@ -111,23 +112,29 @@ public class TaskObservationsTests {
|
||||
taskObservations.onTaskEnd(taskExecution);
|
||||
|
||||
// Test Timer
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_NAME.asString(), UNKNOWN));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_NAME.asString(), UNKNOWN));
|
||||
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_EXECUTION_ID.asString(), "123"));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_EXECUTION_ID.asString(), "123"));
|
||||
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_PARENT_EXECUTION_ID.asString(), UNKNOWN));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_PARENT_EXECUTION_ID.asString(), UNKNOWN));
|
||||
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_EXTERNAL_EXECUTION_ID.asString(), UNKNOWN));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_EXTERNAL_EXECUTION_ID.asString(), UNKNOWN));
|
||||
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_EXIT_CODE.asString(), "0"));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_EXIT_CODE.asString(), "0"));
|
||||
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX, Tags
|
||||
.of(TaskExecutionObservation.TaskKeyValues.TASK_STATUS.asString(), TaskObservations.STATUS_SUCCESS));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX, Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_STATUS.asString(),
|
||||
TaskObservations.STATUS_SUCCESS));
|
||||
|
||||
verifyLongTaskTimerAfterStop(longTaskTimer, "unknown", "123");
|
||||
|
||||
@@ -148,20 +155,25 @@ public class TaskObservationsTests {
|
||||
taskExecution.setExitCode(1);
|
||||
taskObservations.onTaskEnd(taskExecution);
|
||||
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_NAME.asString(), "myTask72"));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_NAME.asString(), "myTask72"));
|
||||
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_EXECUTION_ID.asString(), "123"));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_EXECUTION_ID.asString(), "123"));
|
||||
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_PARENT_EXECUTION_ID.asString(), "-1"));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_PARENT_EXECUTION_ID.asString(), "-1"));
|
||||
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_EXIT_CODE.asString(), "1"));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_EXIT_CODE.asString(), "1"));
|
||||
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX, Tags
|
||||
.of(TaskExecutionObservation.TaskKeyValues.TASK_STATUS.asString(), TaskObservations.STATUS_FAILURE));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX, Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_STATUS.asString(),
|
||||
TaskObservations.STATUS_FAILURE));
|
||||
|
||||
verifyLongTaskTimerAfterStop(longTaskTimer, "myTask72", "123");
|
||||
}
|
||||
@@ -194,30 +206,38 @@ public class TaskObservationsTests {
|
||||
|
||||
verifyDefaultKeyValues();
|
||||
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_CF_ORG_NAME.asString(), ORGANIZATION_NAME));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_CF_ORG_NAME.asString(), ORGANIZATION_NAME));
|
||||
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_CF_SPACE_ID.asString(), SPACE_ID));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_CF_SPACE_ID.asString(), SPACE_ID));
|
||||
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_CF_SPACE_NAME.asString(), SPACE_NAME));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_CF_SPACE_NAME.asString(), SPACE_NAME));
|
||||
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_CF_APP_NAME.asString(), APPLICATION_NAME));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_CF_APP_NAME.asString(), APPLICATION_NAME));
|
||||
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_CF_APP_ID.asString(), APPLICATION_ID));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_CF_APP_ID.asString(), APPLICATION_ID));
|
||||
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_CF_APP_VERSION.asString(), APPLICATION_VERSION));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX, Tags
|
||||
.of(TaskExecutionObservation.TaskKeyValues.TASK_CF_APP_VERSION.asString(), APPLICATION_VERSION));
|
||||
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_CF_INSTANCE_INDEX.asString(), INSTANCE_INDEX));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_CF_INSTANCE_INDEX.asString(), INSTANCE_INDEX));
|
||||
|
||||
// Test Timer
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_NAME.asString(), "myTask72"));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_NAME.asString(), "myTask72"));
|
||||
|
||||
verifyLongTaskTimerAfterStop(longTaskTimer, "myTask72", "123");
|
||||
}
|
||||
@@ -225,13 +245,13 @@ public class TaskObservationsTests {
|
||||
@Test
|
||||
public void testCloudVariablesUninitialized() {
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(CloudConfigurationForDefaultValues.class));
|
||||
.withConfiguration(AutoConfigurations.of(CloudConfigurationForDefaultValues.class));
|
||||
applicationContextRunner.run((context) -> {
|
||||
TaskObservationCloudKeyValues taskObservationCloudKeyValues = context
|
||||
.getBean(TaskObservationCloudKeyValues.class);
|
||||
.getBean(TaskObservationCloudKeyValues.class);
|
||||
|
||||
assertThat(taskObservationCloudKeyValues).as("taskObservationCloudKeyValues should not be null")
|
||||
.isNotNull();
|
||||
.isNotNull();
|
||||
|
||||
this.taskObservations = new TaskObservations(this.observationRegistry, taskObservationCloudKeyValues, null);
|
||||
|
||||
@@ -244,30 +264,38 @@ public class TaskObservationsTests {
|
||||
|
||||
verifyDefaultKeyValues();
|
||||
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_CF_ORG_NAME.asString(), "default"));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_CF_ORG_NAME.asString(), "default"));
|
||||
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_CF_SPACE_ID.asString(), UNKNOWN));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_CF_SPACE_ID.asString(), UNKNOWN));
|
||||
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_CF_SPACE_NAME.asString(), UNKNOWN));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_CF_SPACE_NAME.asString(), UNKNOWN));
|
||||
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_CF_APP_NAME.asString(), UNKNOWN));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_CF_APP_NAME.asString(), UNKNOWN));
|
||||
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_CF_APP_ID.asString(), UNKNOWN));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_CF_APP_ID.asString(), UNKNOWN));
|
||||
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_CF_APP_VERSION.asString(), UNKNOWN));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_CF_APP_VERSION.asString(), UNKNOWN));
|
||||
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_CF_INSTANCE_INDEX.asString(), "0"));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_CF_INSTANCE_INDEX.asString(), "0"));
|
||||
|
||||
// Test Timer
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_NAME.asString(), "myTask72"));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_NAME.asString(), "myTask72"));
|
||||
|
||||
verifyLongTaskTimerAfterStop(longTaskTimer, "myTask72", "123");
|
||||
});
|
||||
@@ -285,42 +313,48 @@ public class TaskObservationsTests {
|
||||
private LongTaskTimer initializeBasicTest(String taskName, String executionId) {
|
||||
// Test Long Task Timer while the task is running.
|
||||
LongTaskTimer longTaskTimer = simpleMeterRegistry
|
||||
.find(TaskExecutionObservation.TASK_ACTIVE.getPrefix() + ".active").longTaskTimer();
|
||||
.find(TaskExecutionObservation.TASK_ACTIVE.getPrefix() + ".active")
|
||||
.longTaskTimer();
|
||||
System.out.println(simpleMeterRegistry.getMetersAsString());
|
||||
assertThat(longTaskTimer).withFailMessage("LongTask timer should be created on Task start").isNotNull();
|
||||
assertThat(longTaskTimer.activeTasks()).isEqualTo(1);
|
||||
assertThat(longTaskTimer.getId().getTag(TaskExecutionObservation.TaskKeyValues.TASK_NAME.asString()))
|
||||
.isEqualTo(taskName);
|
||||
.isEqualTo(taskName);
|
||||
assertThat(longTaskTimer.getId().getTag(TaskExecutionObservation.TaskKeyValues.TASK_EXECUTION_ID.asString()))
|
||||
.isEqualTo(executionId);
|
||||
.isEqualTo(executionId);
|
||||
return longTaskTimer;
|
||||
}
|
||||
|
||||
private void verifyDefaultKeyValues() {
|
||||
// Test Timer
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_NAME.asString(), "myTask72"));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_NAME.asString(), "myTask72"));
|
||||
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_EXECUTION_ID.asString(), "123"));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_EXECUTION_ID.asString(), "123"));
|
||||
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_PARENT_EXECUTION_ID.asString(), "-1"));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_PARENT_EXECUTION_ID.asString(), "-1"));
|
||||
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_EXIT_CODE.asString(), "0"));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX,
|
||||
Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_EXIT_CODE.asString(), "0"));
|
||||
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry).hasTimerWithNameAndTags(PREFIX, Tags
|
||||
.of(TaskExecutionObservation.TaskKeyValues.TASK_STATUS.asString(), TaskObservations.STATUS_SUCCESS));
|
||||
MeterRegistryAssert.assertThat(this.simpleMeterRegistry)
|
||||
.hasTimerWithNameAndTags(PREFIX, Tags.of(TaskExecutionObservation.TaskKeyValues.TASK_STATUS.asString(),
|
||||
TaskObservations.STATUS_SUCCESS));
|
||||
}
|
||||
|
||||
private void verifyLongTaskTimerAfterStop(LongTaskTimer longTaskTimer, String taskName, String executionId) {
|
||||
// Test Long Task Timer after the task has completed.
|
||||
assertThat(longTaskTimer.activeTasks()).isEqualTo(0);
|
||||
assertThat(longTaskTimer.getId().getTag(TaskExecutionObservation.TaskKeyValues.TASK_NAME.asString()))
|
||||
.isEqualTo(taskName);
|
||||
.isEqualTo(taskName);
|
||||
assertThat(longTaskTimer.getId().getTag(TaskExecutionObservation.TaskKeyValues.TASK_EXECUTION_ID.asString()))
|
||||
.isEqualTo(executionId);
|
||||
.isEqualTo(executionId);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
@@ -42,8 +42,8 @@ class H2TaskRepositoryIntegrationTests {
|
||||
void testTaskRepository(ModeEnum mode) {
|
||||
String connectionUrl = String.format("jdbc:h2:mem:%s;DB_CLOSE_DELAY=-1;MODE=%s", UUID.randomUUID(), mode);
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
|
||||
.withUserConfiguration(TestConfiguration.class).withBean(DataSource.class,
|
||||
() -> new SimpleDriverDataSource(new org.h2.Driver(), connectionUrl, "sa", ""));
|
||||
.withUserConfiguration(TestConfiguration.class)
|
||||
.withBean(DataSource.class, () -> new SimpleDriverDataSource(new org.h2.Driver(), connectionUrl, "sa", ""));
|
||||
|
||||
applicationContextRunner.run((context -> {
|
||||
TaskExplorer taskExplorer = context.getBean(TaskExplorer.class);
|
||||
|
||||
@@ -53,7 +53,7 @@ public class MariaDbTaskRepositoryIntegrationTests {
|
||||
@Test
|
||||
public void testTaskExplorer() {
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
|
||||
.withUserConfiguration(MariaDbTaskRepositoryIntegrationTests.TestConfiguration.class);
|
||||
.withUserConfiguration(MariaDbTaskRepositoryIntegrationTests.TestConfiguration.class);
|
||||
|
||||
applicationContextRunner.run((context -> {
|
||||
TaskExplorer taskExplorer = context.getBean(TaskExplorer.class);
|
||||
@@ -80,7 +80,7 @@ public class MariaDbTaskRepositoryIntegrationTests {
|
||||
if (firstTime) {
|
||||
ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator();
|
||||
databasePopulator
|
||||
.addScript(new ClassPathResource("/org/springframework/cloud/task/schema-mariadb.sql"));
|
||||
.addScript(new ClassPathResource("/org/springframework/cloud/task/schema-mariadb.sql"));
|
||||
databasePopulator.execute(datasource);
|
||||
firstTime = false;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public abstract class BaseTaskExecutionDaoTestCases {
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
assertThat(e.getMessage())
|
||||
.isEqualTo("Task names must not contain any empty elements but 2 of 4 were empty or null.");
|
||||
.isEqualTo("Task names must not contain any empty elements but 2 of 4 were empty or null.");
|
||||
return;
|
||||
}
|
||||
fail("Expected an IllegalArgumentException to be thrown.");
|
||||
@@ -82,7 +82,8 @@ public abstract class BaseTaskExecutionDaoTestCases {
|
||||
initializeRepositoryNotInOrderWithMultipleTaskExecutions();
|
||||
final List<TaskExecution> latestTaskExecutions = this.dao.getLatestTaskExecutionsByTaskNames("FOO1");
|
||||
assertThat(latestTaskExecutions.size() == 1)
|
||||
.as("Expected only 1 taskExecution but got " + latestTaskExecutions.size()).isTrue();
|
||||
.as("Expected only 1 taskExecution but got " + latestTaskExecutions.size())
|
||||
.isTrue();
|
||||
|
||||
final TaskExecution lastTaskExecution = latestTaskExecutions.get(0);
|
||||
assertThat(lastTaskExecution.getTaskName()).isEqualTo("FOO1");
|
||||
@@ -102,7 +103,8 @@ public abstract class BaseTaskExecutionDaoTestCases {
|
||||
final List<TaskExecution> latestTaskExecutions = this.dao.getLatestTaskExecutionsByTaskNames("FOO1", "FOO3",
|
||||
"FOO4");
|
||||
assertThat(latestTaskExecutions.size() == 3)
|
||||
.as("Expected 3 taskExecutions but got " + latestTaskExecutions.size()).isTrue();
|
||||
.as("Expected 3 taskExecutions but got " + latestTaskExecutions.size())
|
||||
.isTrue();
|
||||
|
||||
LocalDateTime startDateTime = latestTaskExecutions.get(0).getStartTime();
|
||||
assertThat(startDateTime.getYear()).isEqualTo(2016);
|
||||
@@ -142,7 +144,8 @@ public abstract class BaseTaskExecutionDaoTestCases {
|
||||
long executionIdOffset = initializeRepositoryNotInOrderWithMultipleTaskExecutions();
|
||||
final List<TaskExecution> latestTaskExecutions = this.dao.getLatestTaskExecutionsByTaskNames("FOO5");
|
||||
assertThat(latestTaskExecutions.size() == 1)
|
||||
.as("Expected only 1 taskExecution but got " + latestTaskExecutions.size()).isTrue();
|
||||
.as("Expected only 1 taskExecution but got " + latestTaskExecutions.size())
|
||||
.isTrue();
|
||||
|
||||
LocalDateTime startDateTime = latestTaskExecutions.get(0).getStartTime();
|
||||
|
||||
@@ -187,7 +190,7 @@ public abstract class BaseTaskExecutionDaoTestCases {
|
||||
initializeRepositoryNotInOrderWithMultipleTaskExecutions();
|
||||
final TaskExecution latestTaskExecution = this.dao.getLatestTaskExecutionForTaskName("Bar5");
|
||||
assertThat(latestTaskExecution).as("Expected the latestTaskExecution to be null but got" + latestTaskExecution)
|
||||
.isNull();
|
||||
.isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -288,13 +291,19 @@ public abstract class BaseTaskExecutionDaoTestCases {
|
||||
}
|
||||
|
||||
private LocalDateTime getDate(int year, int month, int day, int hour, int minute) {
|
||||
return LocalDateTime.now().withYear(year).withMonth(month).withDayOfMonth(day).withHour(hour).withMinute(minute)
|
||||
.withSecond(0);
|
||||
return LocalDateTime.now()
|
||||
.withYear(year)
|
||||
.withMonth(month)
|
||||
.withDayOfMonth(day)
|
||||
.withHour(hour)
|
||||
.withMinute(minute)
|
||||
.withSecond(0);
|
||||
}
|
||||
|
||||
private long createTaskExecution(TaskExecution te) {
|
||||
return this.dao.createTaskExecution(te.getTaskName(), te.getStartTime(), te.getArguments(),
|
||||
te.getExternalExecutionId()).getExecutionId();
|
||||
return this.dao
|
||||
.createTaskExecution(te.getTaskName(), te.getStartTime(), te.getArguments(), te.getExternalExecutionId())
|
||||
.getExecutionId();
|
||||
}
|
||||
|
||||
protected TaskExecution getTaskExecution(String taskName, String externalExecutionId) {
|
||||
|
||||
@@ -219,7 +219,8 @@ public class JdbcTaskExecutionDaoMariaDBIntegrationTests extends BaseTaskExecuti
|
||||
initializeRepositoryNotInOrderWithMultipleTaskExecutions();
|
||||
assertThat(
|
||||
this.dao.findRunningTaskExecutions("FOO1", PageRequest.of(1, Integer.MAX_VALUE, Sort.by("START_TIME")))
|
||||
.getTotalElements()).isEqualTo(4);
|
||||
.getTotalElements())
|
||||
.isEqualTo(4);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -227,9 +228,9 @@ public class JdbcTaskExecutionDaoMariaDBIntegrationTests extends BaseTaskExecuti
|
||||
public void testFindRunningTaskExecutionsIllegalSort() {
|
||||
initializeRepositoryNotInOrderWithMultipleTaskExecutions();
|
||||
assertThatThrownBy(() -> this.dao
|
||||
.findRunningTaskExecutions("FOO1", PageRequest.of(1, Integer.MAX_VALUE, Sort.by("ILLEGAL_SORT")))
|
||||
.getTotalElements()).isInstanceOf(IllegalArgumentException.class)
|
||||
.hasMessage("Invalid sort option selected: ILLEGAL_SORT");
|
||||
.findRunningTaskExecutions("FOO1", PageRequest.of(1, Integer.MAX_VALUE, Sort.by("ILLEGAL_SORT")))
|
||||
.getTotalElements()).isInstanceOf(IllegalArgumentException.class)
|
||||
.hasMessage("Invalid sort option selected: ILLEGAL_SORT");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -238,7 +239,8 @@ public class JdbcTaskExecutionDaoMariaDBIntegrationTests extends BaseTaskExecuti
|
||||
initializeRepositoryNotInOrderWithMultipleTaskExecutions();
|
||||
assertThat(
|
||||
this.dao.findRunningTaskExecutions("FOO1", PageRequest.of(1, Integer.MAX_VALUE, Sort.by("StArT_TiMe")))
|
||||
.getTotalElements()).isEqualTo(4);
|
||||
.getTotalElements())
|
||||
.isEqualTo(4);
|
||||
}
|
||||
|
||||
private TaskExecution initializeTaskExecutionWithExternalExecutionId() {
|
||||
@@ -282,7 +284,7 @@ public class JdbcTaskExecutionDaoMariaDBIntegrationTests extends BaseTaskExecuti
|
||||
if (firstTime) {
|
||||
ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator();
|
||||
databasePopulator
|
||||
.addScript(new ClassPathResource("/org/springframework/cloud/task/schema-mariadb.sql"));
|
||||
.addScript(new ClassPathResource("/org/springframework/cloud/task/schema-mariadb.sql"));
|
||||
databasePopulator.execute(datasource);
|
||||
firstTime = false;
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ public class TaskExecutionDaoTests extends BaseTaskExecutionDaoTestCases {
|
||||
getDao(testType);
|
||||
initializeRepositoryNotInOrderWithMultipleTaskExecutions();
|
||||
assertThat(this.dao.findRunningTaskExecutions("FOO1", PageRequest.of(1, 4, Sort.by("START_TIME")))
|
||||
.getTotalElements()).isEqualTo(4);
|
||||
.getTotalElements()).isEqualTo(4);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -243,9 +243,9 @@ public class TaskExecutionDaoTests extends BaseTaskExecutionDaoTestCases {
|
||||
public void testFindRunningTaskExecutionsIllegalSort() {
|
||||
initializeRepositoryNotInOrderWithMultipleTaskExecutions();
|
||||
assertThatThrownBy(() -> this.dao
|
||||
.findRunningTaskExecutions("FOO1", PageRequest.of(1, Integer.MAX_VALUE, Sort.by("ILLEGAL_SORT")))
|
||||
.getTotalElements()).isInstanceOf(IllegalArgumentException.class)
|
||||
.hasMessage("Invalid sort option selected: ILLEGAL_SORT");
|
||||
.findRunningTaskExecutions("FOO1", PageRequest.of(1, Integer.MAX_VALUE, Sort.by("ILLEGAL_SORT")))
|
||||
.getTotalElements()).isInstanceOf(IllegalArgumentException.class)
|
||||
.hasMessage("Invalid sort option selected: ILLEGAL_SORT");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -254,7 +254,8 @@ public class TaskExecutionDaoTests extends BaseTaskExecutionDaoTestCases {
|
||||
initializeRepositoryNotInOrderWithMultipleTaskExecutions();
|
||||
assertThat(
|
||||
this.dao.findRunningTaskExecutions("FOO1", PageRequest.of(1, Integer.MAX_VALUE, Sort.by("StArT_TiMe")))
|
||||
.getTotalElements()).isEqualTo(4);
|
||||
.getTotalElements())
|
||||
.isEqualTo(4);
|
||||
}
|
||||
|
||||
private TaskExecution initializeTaskExecutionWithExternalExecutionId() {
|
||||
|
||||
@@ -79,8 +79,8 @@ public class FindAllPagingQueryProviderTests {
|
||||
public void testGeneratedQuery(String databaseProductName, String expectedQuery) throws Exception {
|
||||
String actualQuery = TestDBUtils.getPagingQueryProvider(databaseProductName).getPageQuery(this.pageable);
|
||||
assertThat(actualQuery)
|
||||
.as(String.format("the generated query for %s, was not the expected query", databaseProductName))
|
||||
.isEqualTo(expectedQuery);
|
||||
.as(String.format("the generated query for %s, was not the expected query", databaseProductName))
|
||||
.isEqualTo(expectedQuery);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -75,8 +75,8 @@ public class WhereClausePagingQueryProviderTests {
|
||||
"TASK_EXECUTION_ID = '0000'");
|
||||
String actualQuery = pagingQueryProvider.getPageQuery(this.pageable);
|
||||
assertThat(actualQuery)
|
||||
.as(String.format("the generated query for %s, was not the expected query", databaseProductName))
|
||||
.isEqualTo(expectedQuery);
|
||||
.as(String.format("the generated query for %s, was not the expected query", databaseProductName))
|
||||
.isEqualTo(expectedQuery);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -96,7 +96,8 @@ public class SimpleTaskExplorerTests {
|
||||
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", testType)).isNotNull();
|
||||
.as(String.format("expected a taskExecution but got null for test type %s", testType))
|
||||
.isNotNull();
|
||||
TestVerifierUtils.verifyTaskExecution(expectedResults.get(taskExecutionId), actualTaskExecution);
|
||||
}
|
||||
}
|
||||
@@ -109,7 +110,7 @@ public class SimpleTaskExplorerTests {
|
||||
|
||||
TaskExecution actualTaskExecution = this.taskExplorer.getTaskExecution(-5);
|
||||
assertThat(actualTaskExecution).as(String.format("expected null for actualTaskExecution %s", testType))
|
||||
.isNull();
|
||||
.isNull();
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@@ -119,9 +120,9 @@ public class SimpleTaskExplorerTests {
|
||||
Map<Long, TaskExecution> expectedResults = createSampleDataSet(5);
|
||||
for (Map.Entry<Long, TaskExecution> entry : expectedResults.entrySet()) {
|
||||
String taskName = entry.getValue().getTaskName();
|
||||
assertThat(this.taskExplorer.getTaskExecutionCountByTaskName(taskName)).as(
|
||||
String.format("task count for task name did not match expected result for testType %s", testType))
|
||||
.isEqualTo(1);
|
||||
assertThat(this.taskExplorer.getTaskExecutionCountByTaskName(taskName))
|
||||
.as(String.format("task count for task name did not match expected result for testType %s", testType))
|
||||
.isEqualTo(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +132,8 @@ public class SimpleTaskExplorerTests {
|
||||
testDefaultContext(testType);
|
||||
createSampleDataSet(33);
|
||||
assertThat(this.taskExplorer.getTaskExecutionCount())
|
||||
.as(String.format("task count did not match expected result for test Type %s", testType)).isEqualTo(33);
|
||||
.as(String.format("task count did not match expected result for test Type %s", testType))
|
||||
.isEqualTo(33);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@@ -140,7 +142,8 @@ public class SimpleTaskExplorerTests {
|
||||
testDefaultContext(testType);
|
||||
createSampleDataSet(33);
|
||||
assertThat(this.taskExplorer.getRunningTaskExecutionCount())
|
||||
.as(String.format("task count did not match expected result for test Type %s", testType)).isEqualTo(33);
|
||||
.as(String.format("task count did not match expected result for test Type %s", testType))
|
||||
.isEqualTo(33);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@@ -164,17 +167,19 @@ public class SimpleTaskExplorerTests {
|
||||
Pageable pageable = PageRequest.of(0, 10);
|
||||
|
||||
Page<TaskExecution> actualResults = this.taskExplorer.findRunningTaskExecutions(TASK_NAME, pageable);
|
||||
assertThat(actualResults.getNumberOfElements()).as(String
|
||||
.format("Running task count for task name did not match expected result for testType %s", testType))
|
||||
.isEqualTo(TEST_COUNT);
|
||||
assertThat(actualResults.getNumberOfElements())
|
||||
.as(String.format("Running task count for task name did not match expected result for testType %s",
|
||||
testType))
|
||||
.isEqualTo(TEST_COUNT);
|
||||
|
||||
for (TaskExecution result : actualResults) {
|
||||
assertThat(expectedResults.containsKey(result.getExecutionId()))
|
||||
.as(String.format("result returned from repo %s not expected for testType %s",
|
||||
result.getExecutionId(), testType))
|
||||
.isTrue();
|
||||
.as(String.format("result returned from repo %s not expected for testType %s", result.getExecutionId(),
|
||||
testType))
|
||||
.isTrue();
|
||||
assertThat(result.getEndTime())
|
||||
.as(String.format("result had non null for endTime for the testType %s", testType)).isNull();
|
||||
.as(String.format("result had non null for endTime for the testType %s", testType))
|
||||
.isNull();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,10 +190,10 @@ public class SimpleTaskExplorerTests {
|
||||
Map<Long, TaskExecution> sampleDataSet = createSampleDataSet(33);
|
||||
sampleDataSet.values().forEach(taskExecution -> {
|
||||
Page<TaskExecution> taskExecutionsByExecutionId = this.taskExplorer
|
||||
.findTaskExecutionsByExecutionId(taskExecution.getExternalExecutionId(), PageRequest.of(0, 5));
|
||||
.findTaskExecutionsByExecutionId(taskExecution.getExternalExecutionId(), PageRequest.of(0, 5));
|
||||
assertThat(taskExecutionsByExecutionId.getTotalElements()).isEqualTo(1);
|
||||
assertThat(this.taskExplorer
|
||||
.getTaskExecutionCountByExternalExecutionId(taskExecution.getExternalExecutionId())).isEqualTo(1);
|
||||
.getTaskExecutionCountByExternalExecutionId(taskExecution.getExternalExecutionId())).isEqualTo(1);
|
||||
TaskExecution resultTaskExecution = taskExecutionsByExecutionId.getContent().get(0);
|
||||
assertThat(resultTaskExecution.getExecutionId()).isEqualTo(taskExecution.getExecutionId());
|
||||
});
|
||||
@@ -223,7 +228,7 @@ public class SimpleTaskExplorerTests {
|
||||
assertThat(expectedResults.keySet()).contains(taskExecution.getExecutionId());
|
||||
});
|
||||
assertThat(this.taskExplorer.getTaskExecutionCountByExternalExecutionId(EXTERNAL_EXECUTION_ID))
|
||||
.isEqualTo(SAME_EXTERNAL_ID_COUNT);
|
||||
.isEqualTo(SAME_EXTERNAL_ID_COUNT);
|
||||
|
||||
}
|
||||
|
||||
@@ -247,17 +252,18 @@ public class SimpleTaskExplorerTests {
|
||||
|
||||
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", testType))
|
||||
.isEqualTo(TEST_COUNT);
|
||||
assertThat(resultSet.getNumberOfElements())
|
||||
.as(String.format("Running task count for task name did not match expected result for testType %s",
|
||||
testType))
|
||||
.isEqualTo(TEST_COUNT);
|
||||
|
||||
for (TaskExecution result : resultSet) {
|
||||
assertThat(expectedResults.containsKey(result.getExecutionId())).as(
|
||||
String.format("result returned from %s repo %s not expected", testType, result.getExecutionId()))
|
||||
.isTrue();
|
||||
assertThat(expectedResults.containsKey(result.getExecutionId()))
|
||||
.as(String.format("result returned from %s repo %s not expected", testType, result.getExecutionId()))
|
||||
.isTrue();
|
||||
assertThat(result.getTaskName())
|
||||
.as(String.format("taskName for taskExecution is incorrect for testType %s", testType))
|
||||
.isEqualTo(TASK_NAME);
|
||||
.as(String.format("taskName for taskExecution is incorrect for testType %s", testType))
|
||||
.isEqualTo(TASK_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,7 +280,8 @@ public class SimpleTaskExplorerTests {
|
||||
List<String> actualTaskNames = this.taskExplorer.getTaskNames();
|
||||
for (String taskName : actualTaskNames) {
|
||||
assertThat(expectedResults.contains(taskName))
|
||||
.as(String.format("taskName was not in expected results for testType %s", testType)).isTrue();
|
||||
.as(String.format("taskName was not in expected results for testType %s", testType))
|
||||
.isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,9 +338,10 @@ public class SimpleTaskExplorerTests {
|
||||
Map<Long, TaskExecution> expectedResults = createSampleDataSet(5);
|
||||
for (Map.Entry<Long, TaskExecution> taskExecutionMapEntry : expectedResults.entrySet()) {
|
||||
TaskExecution latestTaskExecution = this.taskExplorer
|
||||
.getLatestTaskExecutionForTaskName(taskExecutionMapEntry.getValue().getTaskName());
|
||||
.getLatestTaskExecutionForTaskName(taskExecutionMapEntry.getValue().getTaskName());
|
||||
assertThat(latestTaskExecution)
|
||||
.as(String.format("expected a taskExecution but got null for test type %s", testType)).isNotNull();
|
||||
.as(String.format("expected a taskExecution but got null for test type %s", testType))
|
||||
.isNotNull();
|
||||
TestVerifierUtils.verifyTaskExecution(expectedResults.get(latestTaskExecution.getExecutionId()),
|
||||
latestTaskExecution);
|
||||
}
|
||||
@@ -352,11 +360,12 @@ public class SimpleTaskExplorerTests {
|
||||
}
|
||||
|
||||
final List<TaskExecution> latestTaskExecutions = this.taskExplorer
|
||||
.getLatestTaskExecutionsByTaskNames(taskNamesAsList.toArray(new String[taskNamesAsList.size()]));
|
||||
.getLatestTaskExecutionsByTaskNames(taskNamesAsList.toArray(new String[taskNamesAsList.size()]));
|
||||
|
||||
for (TaskExecution latestTaskExecution : latestTaskExecutions) {
|
||||
assertThat(latestTaskExecution)
|
||||
.as(String.format("expected a taskExecution but got null for test type %s", testType)).isNotNull();
|
||||
.as(String.format("expected a taskExecution but got null for test type %s", testType))
|
||||
.isNotNull();
|
||||
TestVerifierUtils.verifyTaskExecution(expectedResults.get(latestTaskExecution.getExecutionId()),
|
||||
latestTaskExecution);
|
||||
}
|
||||
@@ -370,9 +379,9 @@ public class SimpleTaskExplorerTests {
|
||||
Page<TaskExecution> taskPage = this.taskExplorer.findAll(pageable);
|
||||
int pagesExpected = (int) Math.ceil(totalNumberOfExecs / ((double) pageable.getPageSize()));
|
||||
assertThat(taskPage.getTotalPages()).as("actual page count return was not the expected total")
|
||||
.isEqualTo(pagesExpected);
|
||||
.isEqualTo(pagesExpected);
|
||||
assertThat(taskPage.getTotalElements()).as("actual element count was not the expected count")
|
||||
.isEqualTo(totalNumberOfExecs);
|
||||
.isEqualTo(totalNumberOfExecs);
|
||||
|
||||
// Verify pagination
|
||||
Pageable actualPageable = PageRequest.of(0, pageable.getPageSize());
|
||||
@@ -388,12 +397,12 @@ public class SimpleTaskExplorerTests {
|
||||
expectedPageSize = totalNumberOfExecs % pageable.getPageSize();
|
||||
}
|
||||
assertThat(actualTaskExecutions.size())
|
||||
.as(String.format("Element count on page did not match on the %n page", pageNumber))
|
||||
.isEqualTo(expectedPageSize);
|
||||
.as(String.format("Element count on page did not match on the %n page", pageNumber))
|
||||
.isEqualTo(expectedPageSize);
|
||||
for (TaskExecution actualExecution : actualTaskExecutions) {
|
||||
assertThat(actualExecution.getExecutionId())
|
||||
.as(String.format("Element on page %n did not match expected", pageNumber))
|
||||
.isEqualTo((long) expectedTaskExecutionIter.next());
|
||||
.as(String.format("Element on page %n did not match expected", pageNumber))
|
||||
.isEqualTo((long) expectedTaskExecutionIter.next());
|
||||
TestVerifierUtils.verifyTaskExecution(expectedResults.get(actualExecution.getExecutionId()),
|
||||
actualExecution);
|
||||
elementCount++;
|
||||
@@ -418,8 +427,8 @@ public class SimpleTaskExplorerTests {
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
|
||||
this.context.getAutowireCapableBeanFactory().autowireBeanProperties(this,
|
||||
AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false);
|
||||
this.context.getAutowireCapableBeanFactory()
|
||||
.autowireBeanProperties(this, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false);
|
||||
}
|
||||
|
||||
private void initializeMapExplorerTest() {
|
||||
@@ -427,8 +436,8 @@ public class SimpleTaskExplorerTests {
|
||||
this.context.register(TestConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
|
||||
this.context.getAutowireCapableBeanFactory().autowireBeanProperties(this,
|
||||
AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false);
|
||||
this.context.getAutowireCapableBeanFactory()
|
||||
.autowireBeanProperties(this, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false);
|
||||
}
|
||||
|
||||
private Map<Long, TaskExecution> createSampleDataSet(int count) {
|
||||
|
||||
@@ -35,7 +35,7 @@ public class SimpleTaskNameResolverTests {
|
||||
taskNameResolver.setApplicationContext(context);
|
||||
|
||||
assertThat(taskNameResolver.getTaskName()
|
||||
.startsWith("org.springframework.context.support.GenericApplicationContext")).isTrue();
|
||||
.startsWith("org.springframework.context.support.GenericApplicationContext")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -64,7 +64,7 @@ public class SimpleTaskRepositoryJdbcTests {
|
||||
@DirtiesContext
|
||||
public void testCreateEmptyExecution() {
|
||||
TaskExecution expectedTaskExecution = TaskExecutionCreator
|
||||
.createAndStoreEmptyTaskExecution(this.taskRepository);
|
||||
.createAndStoreEmptyTaskExecution(this.taskRepository);
|
||||
TaskExecution actualTaskExecution = TestDBUtils.getTaskExecutionFromDB(this.dataSource,
|
||||
expectedTaskExecution.getExecutionId());
|
||||
TestVerifierUtils.verifyTaskExecution(expectedTaskExecution, actualTaskExecution);
|
||||
@@ -74,7 +74,7 @@ public class SimpleTaskRepositoryJdbcTests {
|
||||
@DirtiesContext
|
||||
public void testCreateTaskExecutionNoParam() {
|
||||
TaskExecution expectedTaskExecution = TaskExecutionCreator
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
TaskExecution actualTaskExecution = TestDBUtils.getTaskExecutionFromDB(this.dataSource,
|
||||
expectedTaskExecution.getExecutionId());
|
||||
TestVerifierUtils.verifyTaskExecution(expectedTaskExecution, actualTaskExecution);
|
||||
@@ -84,7 +84,7 @@ public class SimpleTaskRepositoryJdbcTests {
|
||||
@DirtiesContext
|
||||
public void testCreateTaskExecutionWithParam() {
|
||||
TaskExecution expectedTaskExecution = TaskExecutionCreator
|
||||
.createAndStoreTaskExecutionWithParams(this.taskRepository);
|
||||
.createAndStoreTaskExecutionWithParams(this.taskRepository);
|
||||
TaskExecution actualTaskExecution = TestDBUtils.getTaskExecutionFromDB(this.dataSource,
|
||||
expectedTaskExecution.getExecutionId());
|
||||
TestVerifierUtils.verifyTaskExecution(expectedTaskExecution, actualTaskExecution);
|
||||
@@ -94,7 +94,7 @@ public class SimpleTaskRepositoryJdbcTests {
|
||||
@DirtiesContext
|
||||
public void startTaskExecutionWithParam() {
|
||||
TaskExecution expectedTaskExecution = TaskExecutionCreator
|
||||
.createAndStoreEmptyTaskExecution(this.taskRepository);
|
||||
.createAndStoreEmptyTaskExecution(this.taskRepository);
|
||||
|
||||
expectedTaskExecution.setArguments(Collections.singletonList("foo=" + UUID.randomUUID().toString()));
|
||||
expectedTaskExecution.setStartTime(LocalDateTime.now());
|
||||
@@ -112,7 +112,7 @@ public class SimpleTaskRepositoryJdbcTests {
|
||||
@DirtiesContext
|
||||
public void startTaskExecutionWithNoParam() {
|
||||
TaskExecution expectedTaskExecution = TaskExecutionCreator
|
||||
.createAndStoreEmptyTaskExecution(this.taskRepository);
|
||||
.createAndStoreEmptyTaskExecution(this.taskRepository);
|
||||
|
||||
expectedTaskExecution.setStartTime(LocalDateTime.now());
|
||||
expectedTaskExecution.setTaskName(UUID.randomUUID().toString());
|
||||
@@ -128,7 +128,7 @@ public class SimpleTaskRepositoryJdbcTests {
|
||||
@Test
|
||||
public void testUpdateExternalExecutionId() {
|
||||
TaskExecution expectedTaskExecution = TaskExecutionCreator
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
expectedTaskExecution.setExternalExecutionId(UUID.randomUUID().toString());
|
||||
this.taskRepository.updateExternalExecutionId(expectedTaskExecution.getExecutionId(),
|
||||
expectedTaskExecution.getExternalExecutionId());
|
||||
@@ -139,7 +139,7 @@ public class SimpleTaskRepositoryJdbcTests {
|
||||
@Test
|
||||
public void testUpdateNullExternalExecutionId() {
|
||||
TaskExecution expectedTaskExecution = TaskExecutionCreator
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
expectedTaskExecution.setExternalExecutionId(null);
|
||||
this.taskRepository.updateExternalExecutionId(expectedTaskExecution.getExecutionId(),
|
||||
expectedTaskExecution.getExternalExecutionId());
|
||||
@@ -150,7 +150,7 @@ public class SimpleTaskRepositoryJdbcTests {
|
||||
@Test
|
||||
public void testInvalidExecutionIdForExternalExecutionIdUpdate() {
|
||||
TaskExecution expectedTaskExecution = TaskExecutionCreator
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
expectedTaskExecution.setExternalExecutionId(null);
|
||||
assertThatExceptionOfType(IllegalStateException.class).isThrownBy(() -> {
|
||||
this.taskRepository.updateExternalExecutionId(-1, expectedTaskExecution.getExternalExecutionId());
|
||||
@@ -161,7 +161,7 @@ public class SimpleTaskRepositoryJdbcTests {
|
||||
@DirtiesContext
|
||||
public void startTaskExecutionWithParent() {
|
||||
TaskExecution expectedTaskExecution = TaskExecutionCreator
|
||||
.createAndStoreEmptyTaskExecution(this.taskRepository);
|
||||
.createAndStoreEmptyTaskExecution(this.taskRepository);
|
||||
|
||||
expectedTaskExecution.setStartTime(LocalDateTime.now());
|
||||
expectedTaskExecution.setTaskName(UUID.randomUUID().toString());
|
||||
@@ -179,7 +179,7 @@ public class SimpleTaskRepositoryJdbcTests {
|
||||
@DirtiesContext
|
||||
public void testCompleteTaskExecution() {
|
||||
TaskExecution expectedTaskExecution = TaskExecutionCreator
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
expectedTaskExecution.setEndTime(LocalDateTime.now());
|
||||
expectedTaskExecution.setExitCode(77);
|
||||
expectedTaskExecution.setExitMessage(UUID.randomUUID().toString());
|
||||
@@ -193,7 +193,7 @@ public class SimpleTaskRepositoryJdbcTests {
|
||||
@DirtiesContext
|
||||
public void testCreateTaskExecutionNoParamMaxExitDefaultMessageSize() {
|
||||
TaskExecution expectedTaskExecution = TaskExecutionCreator
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
expectedTaskExecution.setExitMessage(new String(new char[SimpleTaskRepository.MAX_EXIT_MESSAGE_SIZE + 1]));
|
||||
expectedTaskExecution.setEndTime(LocalDateTime.now());
|
||||
expectedTaskExecution.setExitCode(0);
|
||||
@@ -208,7 +208,7 @@ public class SimpleTaskRepositoryJdbcTests {
|
||||
simpleTaskRepository.setMaxExitMessageSize(5);
|
||||
|
||||
TaskExecution expectedTaskExecution = TaskExecutionCreator
|
||||
.createAndStoreTaskExecutionNoParams(simpleTaskRepository);
|
||||
.createAndStoreTaskExecutionNoParams(simpleTaskRepository);
|
||||
expectedTaskExecution.setExitMessage(new String(new char[SimpleTaskRepository.MAX_EXIT_MESSAGE_SIZE + 1]));
|
||||
expectedTaskExecution.setEndTime(LocalDateTime.now());
|
||||
expectedTaskExecution.setExitCode(0);
|
||||
@@ -220,13 +220,13 @@ public class SimpleTaskRepositoryJdbcTests {
|
||||
@DirtiesContext
|
||||
public void testCreateTaskExecutionNoParamMaxErrorDefaultMessageSize() {
|
||||
TaskExecution expectedTaskExecution = TaskExecutionCreator
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
expectedTaskExecution.setErrorMessage(new String(new char[SimpleTaskRepository.MAX_ERROR_MESSAGE_SIZE + 1]));
|
||||
expectedTaskExecution.setEndTime(LocalDateTime.now());
|
||||
expectedTaskExecution.setExitCode(0);
|
||||
TaskExecution actualTaskExecution = completeTaskExecution(expectedTaskExecution, this.taskRepository);
|
||||
assertThat(actualTaskExecution.getErrorMessage().length())
|
||||
.isEqualTo(SimpleTaskRepository.MAX_ERROR_MESSAGE_SIZE);
|
||||
.isEqualTo(SimpleTaskRepository.MAX_ERROR_MESSAGE_SIZE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -236,7 +236,7 @@ public class SimpleTaskRepositoryJdbcTests {
|
||||
simpleTaskRepository.setMaxErrorMessageSize(5);
|
||||
|
||||
TaskExecution expectedTaskExecution = TaskExecutionCreator
|
||||
.createAndStoreTaskExecutionNoParams(simpleTaskRepository);
|
||||
.createAndStoreTaskExecutionNoParams(simpleTaskRepository);
|
||||
expectedTaskExecution.setErrorMessage(new String(new char[SimpleTaskRepository.MAX_ERROR_MESSAGE_SIZE + 1]));
|
||||
expectedTaskExecution.setEndTime(LocalDateTime.now());
|
||||
expectedTaskExecution.setExitCode(0);
|
||||
@@ -302,7 +302,7 @@ public class SimpleTaskRepositoryJdbcTests {
|
||||
@DirtiesContext
|
||||
public void testCreateTaskExecutionNegativeException() {
|
||||
TaskExecution expectedTaskExecution = TaskExecutionCreator
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
expectedTaskExecution.setEndTime(LocalDateTime.now());
|
||||
expectedTaskExecution.setExitCode(-1);
|
||||
|
||||
@@ -317,7 +317,7 @@ public class SimpleTaskRepositoryJdbcTests {
|
||||
@DirtiesContext
|
||||
public void testCreateTaskExecutionNullEndTime() {
|
||||
TaskExecution expectedTaskExecution = TaskExecutionCreator
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
expectedTaskExecution.setExitCode(-1);
|
||||
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> {
|
||||
TaskExecutionCreator.completeExecution(this.taskRepository, expectedTaskExecution);
|
||||
|
||||
@@ -51,7 +51,7 @@ public class SimpleTaskRepositoryMapTests {
|
||||
@Test
|
||||
public void testCreateEmptyExecution() {
|
||||
TaskExecution expectedTaskExecution = TaskExecutionCreator
|
||||
.createAndStoreEmptyTaskExecution(this.taskRepository);
|
||||
.createAndStoreEmptyTaskExecution(this.taskRepository);
|
||||
TestVerifierUtils.verifyTaskExecution(expectedTaskExecution,
|
||||
getSingleTaskExecutionFromMapRepository(expectedTaskExecution.getExecutionId()));
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public class SimpleTaskRepositoryMapTests {
|
||||
@Test
|
||||
public void testCreateTaskExecutionNoParam() {
|
||||
TaskExecution expectedTaskExecution = TaskExecutionCreator
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
TestVerifierUtils.verifyTaskExecution(expectedTaskExecution,
|
||||
getSingleTaskExecutionFromMapRepository(expectedTaskExecution.getExecutionId()));
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public class SimpleTaskRepositoryMapTests {
|
||||
@Test
|
||||
public void testUpdateExternalExecutionId() {
|
||||
TaskExecution expectedTaskExecution = TaskExecutionCreator
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
expectedTaskExecution.setExternalExecutionId(UUID.randomUUID().toString());
|
||||
this.taskRepository.updateExternalExecutionId(expectedTaskExecution.getExecutionId(),
|
||||
expectedTaskExecution.getExternalExecutionId());
|
||||
@@ -78,7 +78,7 @@ public class SimpleTaskRepositoryMapTests {
|
||||
@Test
|
||||
public void testUpdateNullExternalExecutionId() {
|
||||
TaskExecution expectedTaskExecution = TaskExecutionCreator
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
expectedTaskExecution.setExternalExecutionId(null);
|
||||
this.taskRepository.updateExternalExecutionId(expectedTaskExecution.getExecutionId(),
|
||||
expectedTaskExecution.getExternalExecutionId());
|
||||
@@ -89,7 +89,7 @@ public class SimpleTaskRepositoryMapTests {
|
||||
@Test
|
||||
public void testInvalidExecutionIdForExternalExecutionIdUpdate() {
|
||||
TaskExecution expectedTaskExecution = TaskExecutionCreator
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
expectedTaskExecution.setExternalExecutionId(null);
|
||||
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> {
|
||||
this.taskRepository.updateExternalExecutionId(-1, expectedTaskExecution.getExternalExecutionId());
|
||||
@@ -99,7 +99,7 @@ public class SimpleTaskRepositoryMapTests {
|
||||
@Test
|
||||
public void testCreateTaskExecutionWithParam() {
|
||||
TaskExecution expectedTaskExecution = TaskExecutionCreator
|
||||
.createAndStoreTaskExecutionWithParams(this.taskRepository);
|
||||
.createAndStoreTaskExecutionWithParams(this.taskRepository);
|
||||
TestVerifierUtils.verifyTaskExecution(expectedTaskExecution,
|
||||
getSingleTaskExecutionFromMapRepository(expectedTaskExecution.getExecutionId()));
|
||||
}
|
||||
@@ -107,7 +107,7 @@ public class SimpleTaskRepositoryMapTests {
|
||||
@Test
|
||||
public void startTaskExecutionWithParam() {
|
||||
TaskExecution expectedTaskExecution = TaskExecutionCreator
|
||||
.createAndStoreEmptyTaskExecution(this.taskRepository);
|
||||
.createAndStoreEmptyTaskExecution(this.taskRepository);
|
||||
|
||||
expectedTaskExecution.setArguments(Collections.singletonList("foo=" + UUID.randomUUID().toString()));
|
||||
expectedTaskExecution.setStartTime(LocalDateTime.now());
|
||||
@@ -124,7 +124,7 @@ public class SimpleTaskRepositoryMapTests {
|
||||
@Test
|
||||
public void startTaskExecutionWithNoParam() {
|
||||
TaskExecution expectedTaskExecution = TaskExecutionCreator
|
||||
.createAndStoreEmptyTaskExecution(this.taskRepository);
|
||||
.createAndStoreEmptyTaskExecution(this.taskRepository);
|
||||
|
||||
expectedTaskExecution.setStartTime(LocalDateTime.now());
|
||||
expectedTaskExecution.setTaskName(UUID.randomUUID().toString());
|
||||
@@ -140,7 +140,7 @@ public class SimpleTaskRepositoryMapTests {
|
||||
@Test
|
||||
public void startTaskExecutionWithParent() {
|
||||
TaskExecution expectedTaskExecution = TaskExecutionCreator
|
||||
.createAndStoreEmptyTaskExecution(this.taskRepository);
|
||||
.createAndStoreEmptyTaskExecution(this.taskRepository);
|
||||
|
||||
expectedTaskExecution.setStartTime(LocalDateTime.now());
|
||||
expectedTaskExecution.setTaskName(UUID.randomUUID().toString());
|
||||
@@ -157,7 +157,7 @@ public class SimpleTaskRepositoryMapTests {
|
||||
@Test
|
||||
public void testCompleteTaskExecution() {
|
||||
TaskExecution expectedTaskExecution = TaskExecutionCreator
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
expectedTaskExecution.setEndTime(LocalDateTime.now());
|
||||
expectedTaskExecution.setExitCode(0);
|
||||
TaskExecution actualTaskExecution = TaskExecutionCreator.completeExecution(this.taskRepository,
|
||||
@@ -167,7 +167,7 @@ public class SimpleTaskRepositoryMapTests {
|
||||
|
||||
private TaskExecution getSingleTaskExecutionFromMapRepository(long taskExecutionId) {
|
||||
Map<Long, TaskExecution> taskMap = ((MapTaskExecutionDao) ((SimpleTaskRepository) this.taskRepository)
|
||||
.getTaskExecutionDao()).getTaskExecutions();
|
||||
.getTaskExecutionDao()).getTaskExecutions();
|
||||
assertTrue("taskExecutionId must be in MapTaskExecutionRepository", taskMap.containsKey(taskExecutionId));
|
||||
return taskMap.get(taskExecutionId);
|
||||
}
|
||||
@@ -175,7 +175,7 @@ public class SimpleTaskRepositoryMapTests {
|
||||
@Test
|
||||
public void testCreateTaskExecutionNullEndTime() {
|
||||
TaskExecution expectedTaskExecution = TaskExecutionCreator
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
.createAndStoreTaskExecutionNoParams(this.taskRepository);
|
||||
expectedTaskExecution.setExitCode(-1);
|
||||
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> {
|
||||
TaskExecutionCreator.completeExecution(this.taskRepository, expectedTaskExecution);
|
||||
|
||||
@@ -58,7 +58,7 @@ public class TaskDatabaseInitializerTests {
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertThat(new JdbcTemplate(this.context.getBean(DataSource.class)).queryForList("select * from TASK_EXECUTION")
|
||||
.size()).isEqualTo(0);
|
||||
.size()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -58,7 +58,7 @@ public final class TestVerifierUtils {
|
||||
*/
|
||||
public static Appender getMockAppender() {
|
||||
ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory
|
||||
.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
|
||||
.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
|
||||
final Appender mockAppender = mock(Appender.class);
|
||||
when(mockAppender.getName()).thenReturn("MOCK");
|
||||
root.addAppender(mockAppender);
|
||||
@@ -131,55 +131,63 @@ public final class TestVerifierUtils {
|
||||
*/
|
||||
public static void verifyTaskExecution(TaskExecution expectedTaskExecution, TaskExecution actualTaskExecution) {
|
||||
assertThat(actualTaskExecution.getExecutionId()).as("taskExecutionId must be equal")
|
||||
.isEqualTo(expectedTaskExecution.getExecutionId());
|
||||
.isEqualTo(expectedTaskExecution.getExecutionId());
|
||||
if (actualTaskExecution.getStartTime() != null) {
|
||||
assertThat(actualTaskExecution.getStartTime().getHour() == expectedTaskExecution.getStartTime().getHour())
|
||||
.as("startTime hour must be equal").isTrue();
|
||||
.as("startTime hour must be equal")
|
||||
.isTrue();
|
||||
assertThat(
|
||||
actualTaskExecution.getStartTime().getMinute() == expectedTaskExecution.getStartTime().getMinute())
|
||||
.as("startTime minute must be equal").isTrue();
|
||||
.as("startTime minute must be equal")
|
||||
.isTrue();
|
||||
assertThat(
|
||||
actualTaskExecution.getStartTime().getSecond() == expectedTaskExecution.getStartTime().getSecond())
|
||||
.as("startTime second must be equal").isTrue();
|
||||
.as("startTime second must be equal")
|
||||
.isTrue();
|
||||
assertThat(actualTaskExecution.getStartTime().getDayOfYear() == expectedTaskExecution.getStartTime()
|
||||
.getDayOfYear()).as("startTime day must be equal").isTrue();
|
||||
.getDayOfYear()).as("startTime day must be equal").isTrue();
|
||||
assertThat(actualTaskExecution.getStartTime().getYear() == expectedTaskExecution.getStartTime().getYear())
|
||||
.as("startTime year must be equal").isTrue();
|
||||
.as("startTime year must be equal")
|
||||
.isTrue();
|
||||
assertThat(actualTaskExecution.getStartTime().getMonthValue() == expectedTaskExecution.getStartTime()
|
||||
.getMonthValue()).as("startTime month must be equal").isTrue();
|
||||
.getMonthValue()).as("startTime month must be equal").isTrue();
|
||||
}
|
||||
if (actualTaskExecution.getEndTime() != null) {
|
||||
assertThat(actualTaskExecution.getEndTime().getHour() == expectedTaskExecution.getEndTime().getHour())
|
||||
.as("endTime hour must be equal").isTrue();
|
||||
.as("endTime hour must be equal")
|
||||
.isTrue();
|
||||
assertThat(actualTaskExecution.getEndTime().getMinute() == expectedTaskExecution.getEndTime().getMinute())
|
||||
.as("endTime minute must be equal").isTrue();
|
||||
.as("endTime minute must be equal")
|
||||
.isTrue();
|
||||
assertThat(actualTaskExecution.getEndTime().getSecond() == expectedTaskExecution.getEndTime().getSecond())
|
||||
.as("endTime second must be equal").isTrue();
|
||||
.as("endTime second must be equal")
|
||||
.isTrue();
|
||||
assertThat(actualTaskExecution.getEndTime().getDayOfYear() == expectedTaskExecution.getEndTime()
|
||||
.getDayOfYear()).as("endTime day must be equal").isTrue();
|
||||
.getDayOfYear()).as("endTime day must be equal").isTrue();
|
||||
assertThat(actualTaskExecution.getEndTime().getYear() == expectedTaskExecution.getEndTime().getYear())
|
||||
.as("endTime year must be equal").isTrue();
|
||||
.as("endTime year must be equal")
|
||||
.isTrue();
|
||||
assertThat(actualTaskExecution.getEndTime().getMonthValue() == expectedTaskExecution.getEndTime()
|
||||
.getMonthValue()).as("endTime month must be equal").isTrue();
|
||||
.getMonthValue()).as("endTime month must be equal").isTrue();
|
||||
}
|
||||
assertThat(actualTaskExecution.getExitCode()).as("exitCode must be equal")
|
||||
.isEqualTo(expectedTaskExecution.getExitCode());
|
||||
.isEqualTo(expectedTaskExecution.getExitCode());
|
||||
assertThat(actualTaskExecution.getTaskName()).as("taskName must be equal")
|
||||
.isEqualTo(expectedTaskExecution.getTaskName());
|
||||
.isEqualTo(expectedTaskExecution.getTaskName());
|
||||
assertThat(actualTaskExecution.getExitMessage()).as("exitMessage must be equal")
|
||||
.isEqualTo(expectedTaskExecution.getExitMessage());
|
||||
.isEqualTo(expectedTaskExecution.getExitMessage());
|
||||
assertThat(actualTaskExecution.getErrorMessage()).as("errorMessage must be equal")
|
||||
.isEqualTo(expectedTaskExecution.getErrorMessage());
|
||||
.isEqualTo(expectedTaskExecution.getErrorMessage());
|
||||
assertThat(actualTaskExecution.getExternalExecutionId()).as("externalExecutionId must be equal")
|
||||
.isEqualTo(expectedTaskExecution.getExternalExecutionId());
|
||||
.isEqualTo(expectedTaskExecution.getExternalExecutionId());
|
||||
assertThat(actualTaskExecution.getParentExecutionId()).as("parentExecutionId must be equal")
|
||||
.isEqualTo(expectedTaskExecution.getParentExecutionId());
|
||||
.isEqualTo(expectedTaskExecution.getParentExecutionId());
|
||||
|
||||
if (expectedTaskExecution.getArguments() != null) {
|
||||
assertThat(actualTaskExecution.getArguments()).as("arguments should not be null").isNotNull();
|
||||
assertThat(actualTaskExecution.getArguments().size())
|
||||
.as("arguments result set count should match expected count")
|
||||
.isEqualTo(expectedTaskExecution.getArguments().size());
|
||||
.as("arguments result set count should match expected count")
|
||||
.isEqualTo(expectedTaskExecution.getArguments().size());
|
||||
}
|
||||
else {
|
||||
assertThat(actualTaskExecution.getArguments()).as("arguments should be null").isNull();
|
||||
|
||||
Reference in New Issue
Block a user