Skip to content

Commit

Permalink
Update tests to new format of exception messages
Browse files Browse the repository at this point in the history
  • Loading branch information
cppwfs committed Mar 6, 2024
1 parent e4c52d1 commit d721ab7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import org.springframework.cloud.task.configuration.EnableTask;
import org.springframework.cloud.task.configuration.SimpleTaskAutoConfiguration;
import org.springframework.cloud.task.configuration.SingleTaskConfiguration;
import org.springframework.cloud.task.listener.TaskException;
import org.springframework.cloud.task.repository.TaskExecution;
import org.springframework.cloud.task.repository.TaskExplorer;
import org.springframework.context.ApplicationListener;
Expand All @@ -71,8 +72,7 @@
*/
public class TaskJobLauncherApplicationRunnerTests {

private static final String DEFAULT_ERROR_MESSAGE = "The following Jobs have failed: \n"
+ "Job jobA failed during execution for job instance id 1 with jobExecutionId of 1 \n";
private static final String DEFAULT_ERROR_MESSAGE = "Job jobA failed during execution for job instance id 1 with jobExecutionId of 1";

private ConfigurableApplicationContext applicationContext;

Expand Down Expand Up @@ -171,9 +171,8 @@ private void validateForFail(String errorMessage, Class<?> clazz, String[] enabl
Executable executable = () -> this.applicationContext = SpringApplication
.run(new Class[] { clazz, PropertyPlaceholderAutoConfiguration.class }, enabledArgs);

assertThatExceptionOfType(IllegalStateException.class).isThrownBy(executable::execute)
.havingCause()
.withMessage(errorMessage);
assertThatExceptionOfType(TaskException.class).isThrownBy(executable::execute)
.withMessageContaining(errorMessage);
}

@Component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ public class TaskCoreTests {
private static final String EXCEPTION_INVALID_TASK_EXECUTION_ID = "java.lang.IllegalArgumentException: "
+ "Invalid TaskExecution, ID 55 not found";

private static final String ERROR_MESSAGE = "errorMessage='java.lang.IllegalStateException: "
+ "Failed to execute CommandLineRunner";
private static final String ERROR_MESSAGE = "errorMessage='java.lang.IllegalStateException: " + "FOO EXCEPTION";

private ConfigurableApplicationContext applicationContext;

Expand Down

0 comments on commit d721ab7

Please sign in to comment.