2727import org .springframework .boot .test .system .OutputCaptureExtension ;
2828
2929
30- import static junit .framework .TestCase .assertTrue ;
31- import static org .junit .Assert .assertEquals ;
30+ import static org .assertj .core .api .Assertions .assertThat ;
3231
3332/**
3433 * Verifies that the Task Application outputs the correct task log entries.
@@ -50,24 +49,18 @@ public void testBatchJobApp(CapturedOutput capturedOutput) throws Exception {
5049 SpringApplication .run (BatchJobApplication .class );
5150
5251 String output = capturedOutput .toString ();
53- assertTrue ("Unable to find the timestamp: " + output ,
54- output .contains (JOB_RUN_MESSAGE ));
55- assertTrue ("Test results do not show create task message: " + output ,
56- output .contains (CREATE_TASK_MESSAGE ));
57- assertTrue ("Test results do not show success message: " + output ,
58- output .contains (UPDATE_TASK_MESSAGE ));
59- assertTrue ("Test results do not show success message: " + output ,
60- output .contains (EXIT_CODE_MESSAGE ));
52+ assertThat (output ).contains (JOB_RUN_MESSAGE );
53+ assertThat (output ).contains (CREATE_TASK_MESSAGE );
54+ assertThat (output ).contains (UPDATE_TASK_MESSAGE );
55+ assertThat (output ).contains (EXIT_CODE_MESSAGE );
6156
6257 int i = output .indexOf (JOB_ASSOCIATION_MESSAGE );
6358
64- assertTrue ("Test results do not show the listener message: " + output ,
65- i > 0 );
59+ assertThat (i ).isGreaterThan (0 );
6660
6761 int j = output .indexOf (JOB_ASSOCIATION_MESSAGE , i + 1 );
6862
69- assertTrue ("Test results do not show the listener message: " + output ,
70- j > i );
63+ assertThat (j ).isGreaterThan (i );
7164
7265
7366 String taskTitle = "Demo Batch Job Task" ;
@@ -78,7 +71,7 @@ public void testBatchJobApp(CapturedOutput capturedOutput) throws Exception {
7871 while (matcher .find ()) {
7972 count ++;
8073 }
81- assertEquals ( "The number of task titles did not match expected: " , 1 , count );
74+ assertThat ( count ). isEqualTo ( 1 );
8275 }
8376
8477}
0 commit comments