Skip to content

Commit aef67ae

Browse files
alibeikov
authored andcommitted
HHH-19591: Refactor verifyMeterNotFoundException to use assertThrows
1 parent 8f08bda commit aef67ae

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

hibernate-micrometer/src/test/java/org/hibernate/test/stat/MicrometerStatisticsTest.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
import io.micrometer.core.instrument.search.MeterNotFoundException;
2020
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
2121

22+
import static org.junit.jupiter.api.Assertions.assertThrows;
23+
import static org.junit.jupiter.api.Assertions.assertTrue;
24+
2225

2326
/**
2427
* @author Erin Schnabel
@@ -136,10 +139,11 @@ public void testMicrometerMetrics() {
136139
}
137140

138141
void verifyMeterNotFoundException(String name) {
139-
try {
140-
registry.get(name).meter();
141-
Assert.fail(name + " should not have been found");
142-
} catch(MeterNotFoundException mnfe) {
143-
}
142+
MeterNotFoundException ex = assertThrows(
143+
MeterNotFoundException.class,
144+
() -> registry.get( name ).meter(), name + " should not have been found"
145+
);
146+
assertTrue( ex.getMessage().contains( name ) );
147+
144148
}
145149
}

0 commit comments

Comments
 (0)