55
66package io .opentelemetry .contrib .jfr .connection ;
77
8- import static org .junit . jupiter .api .Assertions .assertEquals ;
9- import static org .junit . jupiter .api .Assertions .assertThrows ;
8+ import static org .assertj . core .api .Assertions .assertThat ;
9+ import static org .assertj . core .api .Assertions .assertThatThrownBy ;
1010
1111import com .google .errorprone .annotations .Keep ;
1212import java .util .HashMap ;
@@ -33,14 +33,14 @@ private static Stream<Arguments> testGetName() {
3333 @ MethodSource
3434 void testGetName (String testValue , String expected ) {
3535 RecordingOptions opts = new RecordingOptions .Builder ().name (testValue ).build ();
36- assertEquals ( expected , opts .getName ());
36+ assertThat ( opts .getName ()). isEqualTo ( expected );
3737 }
3838
3939 @ Test
4040 void testGetNameDefault () {
4141 String expected = "" ;
4242 RecordingOptions opts = new RecordingOptions .Builder ().build ();
43- assertEquals ( expected , opts .getName ());
43+ assertThat ( opts .getName ()). isEqualTo ( expected );
4444 }
4545
4646 @ Keep
@@ -64,14 +64,14 @@ static Stream<Arguments> testGetMaxAge() {
6464 @ MethodSource
6565 void testGetMaxAge (String testValue , String expected ) {
6666 RecordingOptions opts = new RecordingOptions .Builder ().maxAge (testValue ).build ();
67- assertEquals ( expected , opts .getMaxAge ());
67+ assertThat ( opts .getMaxAge ()). isEqualTo ( expected );
6868 }
6969
7070 @ Test
7171 void testGetMaxAgeDefault () {
7272 String expected = "0" ;
7373 RecordingOptions opts = new RecordingOptions .Builder ().build ();
74- assertEquals ( expected , opts .getMaxAge ());
74+ assertThat ( opts .getMaxAge ()). isEqualTo ( expected );
7575 }
7676
7777 @ Keep
@@ -91,9 +91,8 @@ private static Stream<Arguments> testGetMaxAgeNegative() {
9191 @ ParameterizedTest
9292 @ MethodSource
9393 void testGetMaxAgeNegative (String badValue ) {
94- assertThrows (
95- IllegalArgumentException .class ,
96- () -> new RecordingOptions .Builder ().maxAge (badValue ).build ());
94+ assertThatThrownBy (() -> new RecordingOptions .Builder ().maxAge (badValue ).build ())
95+ .isInstanceOf (IllegalArgumentException .class );
9796 }
9897
9998 @ Keep
@@ -113,14 +112,14 @@ private static Stream<Arguments> testGetMaxSize() {
113112 @ MethodSource
114113 void testGetMaxSize (String testValue , String expected ) {
115114 RecordingOptions opts = new RecordingOptions .Builder ().maxSize (testValue ).build ();
116- assertEquals ( expected , opts .getMaxSize ());
115+ assertThat ( opts .getMaxSize ()). isEqualTo ( expected );
117116 }
118117
119118 @ Test
120119 void testGetMaxSizeDefault () {
121120 String expected = "0" ;
122121 RecordingOptions opts = new RecordingOptions .Builder ().build ();
123- assertEquals ( expected , opts .getMaxSize ());
122+ assertThat ( opts .getMaxSize ()). isEqualTo ( expected );
124123 }
125124
126125 @ Keep
@@ -135,30 +134,29 @@ private static Stream<Arguments> testGetMaxSizeNegative() {
135134 @ ParameterizedTest
136135 @ MethodSource
137136 void testGetMaxSizeNegative (String badValue ) {
138- assertThrows (
139- IllegalArgumentException .class ,
140- () -> new RecordingOptions .Builder ().maxSize (badValue ).build ());
137+ assertThatThrownBy (() -> new RecordingOptions .Builder ().maxSize (badValue ).build ())
138+ .isInstanceOf (IllegalArgumentException .class );
141139 }
142140
143141 @ Test
144142 void testGetDumpOnExit () {
145143 String expected = "true" ;
146144 RecordingOptions opts = new RecordingOptions .Builder ().dumpOnExit (expected ).build ();
147- assertEquals ( expected , opts .getDumpOnExit ());
145+ assertThat ( opts .getDumpOnExit ()). isEqualTo ( expected );
148146 }
149147
150148 @ Test
151149 void testGetDumpOnExitDefault () {
152150 String expected = "false" ;
153151 RecordingOptions opts = new RecordingOptions .Builder ().build ();
154- assertEquals ( expected , opts .getDumpOnExit ());
152+ assertThat ( opts .getDumpOnExit ()). isEqualTo ( expected );
155153 }
156154
157155 @ Test
158156 void testGetDumpOnExitBadValue () {
159157 String expected = "false" ;
160158 RecordingOptions opts = new RecordingOptions .Builder ().dumpOnExit ("BAD_VALUE" ).build ();
161- assertEquals ( expected , opts .getDumpOnExit ());
159+ assertThat ( opts .getDumpOnExit ()). isEqualTo ( expected );
162160 }
163161
164162 @ Keep
@@ -175,35 +173,35 @@ private static Stream<Arguments> testGetDestination() {
175173 @ MethodSource
176174 void testGetDestination (String testValue , String expected ) {
177175 RecordingOptions opts = new RecordingOptions .Builder ().destination (testValue ).build ();
178- assertEquals ( expected , opts .getDestination ());
176+ assertThat ( opts .getDestination ()). isEqualTo ( expected );
179177 }
180178
181179 @ Test
182180 void testGetDestinationDefault () {
183181 String expected = "" ;
184182 RecordingOptions opts = new RecordingOptions .Builder ().build ();
185- assertEquals ( expected , opts .getDestination ());
183+ assertThat ( opts .getDestination ()). isEqualTo ( expected );
186184 }
187185
188186 @ Test
189187 void testGetDisk () {
190188 String expected = "true" ;
191189 RecordingOptions opts = new RecordingOptions .Builder ().disk (expected ).build ();
192- assertEquals ( expected , opts .getDisk ());
190+ assertThat ( opts .getDisk ()). isEqualTo ( expected );
193191 }
194192
195193 @ Test
196194 void testGetDiskDefault () {
197195 String expected = "false" ;
198196 RecordingOptions opts = new RecordingOptions .Builder ().build ();
199- assertEquals ( expected , opts .getDisk ());
197+ assertThat ( opts .getDisk ()). isEqualTo ( expected );
200198 }
201199
202200 @ Test
203201 void testGetDiskBadValue () {
204202 String expected = "false" ;
205203 RecordingOptions opts = new RecordingOptions .Builder ().disk ("BAD_VALUE" ).build ();
206- assertEquals ( expected , opts .getDisk ());
204+ assertThat ( opts .getDisk ()). isEqualTo ( expected );
207205 }
208206
209207 @ Keep
@@ -227,14 +225,14 @@ private static Stream<Arguments> testGetDuration() {
227225 @ MethodSource
228226 void testGetDuration (String testValue , String expected ) {
229227 RecordingOptions opts = new RecordingOptions .Builder ().duration (testValue ).build ();
230- assertEquals ( expected , opts .getDuration ());
228+ assertThat ( opts .getDuration ()). isEqualTo ( expected );
231229 }
232230
233231 @ Test
234232 void testGetDurationDefault () {
235233 String expected = "0" ;
236234 RecordingOptions opts = new RecordingOptions .Builder ().build ();
237- assertEquals ( expected , opts .getDuration ());
235+ assertThat ( opts .getDuration ()). isEqualTo ( expected );
238236 }
239237
240238 @ Keep
@@ -254,9 +252,8 @@ private static Stream<Arguments> testGetDurationNegative() {
254252 @ ParameterizedTest
255253 @ MethodSource
256254 void testGetDurationNegative (String badValue ) {
257- assertThrows (
258- IllegalArgumentException .class ,
259- () -> new RecordingOptions .Builder ().duration (badValue ).build ());
255+ assertThatThrownBy (() -> new RecordingOptions .Builder ().duration (badValue ).build ())
256+ .isInstanceOf (IllegalArgumentException .class );
260257 }
261258
262259 @ Test
@@ -279,7 +276,7 @@ void testGetRecordingOptions() {
279276 .disk ("true" )
280277 .duration ("120 s" )
281278 .build ();
282- assertEquals ( expected , opts .getRecordingOptions ());
279+ assertThat ( opts .getRecordingOptions ()). isEqualTo ( expected );
283280 }
284281
285282 @ Test
@@ -289,6 +286,6 @@ void testGetRecordingOptionsDefaults() {
289286 // to insure consistent behaviour.
290287 expected .put ("disk" , "false" );
291288 RecordingOptions opts = new RecordingOptions .Builder ().build ();
292- assertEquals ( expected , opts .getRecordingOptions ());
289+ assertThat ( opts .getRecordingOptions ()). isEqualTo ( expected );
293290 }
294291}
0 commit comments