Replace Junit Exception assertions with AssertJ

This commit is contained in:
Glenn Renfro
2025-04-10 15:26:50 -04:00
parent 7ee5f6c939
commit 5e11a74258
2 changed files with 6 additions and 9 deletions

View File

@@ -24,7 +24,6 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -48,6 +47,7 @@ import org.springframework.cloud.task.configuration.SingleTaskConfiguration;
import org.springframework.core.Ordered;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;
/**
* @author Glenn Renfro.
@@ -318,12 +318,9 @@ public class JobExecutionEventTests {
.withPropertyValues("--spring.cloud.task.closecontext_enabled=false", "--spring.main.web-environment=false",
"spring.batch.job.jobName=FOO");
applicationContextRunner.run((context) -> {
NoSuchBeanDefinitionException exception = Assertions.assertThrows(NoSuchBeanDefinitionException.class,
() -> {
context.getBean("jobExecutionEventsListener");
});
assertThat(exception.getMessage())
.contains(String.format("No bean named 'jobExecutionEventsListener' available"));
assertThatThrownBy(() -> context.getBean("jobExecutionEventsListener"))
.isInstanceOf(NoSuchBeanDefinitionException.class)
.hasMessageContaining("No bean named 'jobExecutionEventsListener' available");
});
}

View File

@@ -23,7 +23,7 @@ import org.springframework.cloud.task.launcher.annotation.EnableTaskLauncher;
/**
* @author Glenn Renfro
*/
// @checkstyle:on
// @checkstyle:off
@SpringBootApplication
@EnableTaskLauncher
public class TaskLauncherSinkApplication {
@@ -33,4 +33,4 @@ public class TaskLauncherSinkApplication {
}
}
// @checkstyle:off
// @checkstyle:on