1818
1919import com .mongodb .assertions .Assertions ;
2020import com .mongodb .lang .NonNull ;
21- import com .mongodb .lang .Nullable ;
2221
2322import java .util .ArrayList ;
2423import java .util .Arrays ;
3433import static com .mongodb .client .unified .UnifiedTestModifications .Modifier .SLEEP_AFTER_CURSOR_CLOSE ;
3534import static com .mongodb .client .unified .UnifiedTestModifications .Modifier .SLEEP_AFTER_CURSOR_OPEN ;
3635import static com .mongodb .client .unified .UnifiedTestModifications .Modifier .WAIT_FOR_BATCH_CURSOR_CREATION ;
37- import static org .junit .jupiter .api .Assumptions .assumeFalse ;
3836
3937public final class UnifiedTestModifications {
4038 public static void doSkips (final TestDef def ) {
@@ -90,7 +88,7 @@ public static void doSkips(final TestDef def) {
9088 // added as part of https://jira.mongodb.org/browse/JAVA-4976 , but unknown Jira to complete
9189 // The implementation of the functionality related to clearing the connection pool before closing the connection
9290 // will be carried out once the specification is finalized and ready.
93- def .skipTodo ("" )
91+ def .skipUnknownReason ("" )
9492 .test ("connection-monitoring-and-pooling/logging" , "connection-logging" , "Connection checkout fails due to error establishing connection" );
9593
9694 // load-balancers
@@ -129,7 +127,7 @@ public static void doSkips(final TestDef def) {
129127 .test ("crud" , "count" , "Deprecated count without a filter" )
130128 .test ("crud" , "count" , "Deprecated count with a filter" )
131129 .test ("crud" , "count" , "Deprecated count with skip and limit" );
132- def .skipTodo ("See downstream changes comment on https://jira.mongodb.org/browse/JAVA-4275" )
130+ def .skipUnknownReason ("See downstream changes comment on https://jira.mongodb.org/browse/JAVA-4275" )
133131 .test ("crud" , "findOneAndReplace-hint-unacknowledged" , "Unacknowledged findOneAndReplace with hint string on 4.4+ server" )
134132 .test ("crud" , "findOneAndReplace-hint-unacknowledged" , "Unacknowledged findOneAndReplace with hint document on 4.4+ server" )
135133 .test ("crud" , "findOneAndUpdate-hint-unacknowledged" , "Unacknowledged findOneAndUpdate with hint string on 4.4+ server" )
@@ -292,54 +290,54 @@ private TestDef(final String dir, final String file, final String test, final bo
292290 * Test is skipped because it is pending implementation, and there is
293291 * a Jira ticket tracking this which has more information.
294292 *
295- * @param skip reason for skipping the test; must start with a Jira URL
293+ * @param ticket reason for skipping the test; must start with a Jira URL
296294 */
297- public TestApplicator skipJira (final String skip ) {
298- Assertions .assertTrue (skip .startsWith ("https://jira.mongodb.org/browse/JAVA-" ));
299- return new TestApplicator (this , skip );
295+ public TestApplicator skipJira (final String ticket ) {
296+ Assertions .assertTrue (ticket .startsWith ("https://jira.mongodb.org/browse/JAVA-" ));
297+ return new TestApplicator (this , ticket );
300298 }
301299
302300 /**
303301 * Test is skipped because the feature under test was deprecated, and
304302 * was removed in the Java driver.
305303 *
306- * @param skip reason for skipping the test
304+ * @param reason reason for skipping the test
307305 */
308- public TestApplicator skipDeprecated (final String skip ) {
309- return new TestApplicator (this , skip );
306+ public TestApplicator skipDeprecated (final String reason ) {
307+ return new TestApplicator (this , reason );
310308 }
311309
312310 /**
313311 * Test is skipped because the Java driver cannot comply with the spec.
314312 *
315- * @param skip reason for skipping the test
313+ * @param reason reason for skipping the test
316314 */
317- public TestApplicator skipNoncompliant (final String skip ) {
318- return new TestApplicator (this , skip );
315+ public TestApplicator skipNoncompliant (final String reason ) {
316+ return new TestApplicator (this , reason );
319317 }
320318
321319 /**
322320 * Test is skipped because the Java Reactive driver cannot comply with the spec.
323321 *
324- * @param skip reason for skipping the test
322+ * @param reason reason for skipping the test
325323 */
326- public TestApplicator skipNoncompliantReactive (final String skip ) {
327- return new TestApplicator (this , skip );
324+ public TestApplicator skipNoncompliantReactive (final String reason ) {
325+ return new TestApplicator (this , reason );
328326 }
329327
330328 /**
331329 * The test is skipped, as specified. This should be paired with a
332330 * "when" clause.
333331 */
334- public TestApplicator skipAccordingToSpec (final String skip ) {
335- return new TestApplicator (this , skip );
332+ public TestApplicator skipAccordingToSpec (final String reason ) {
333+ return new TestApplicator (this , reason );
336334 }
337335
338336 /**
339337 * The test is skipped for an unknown reason.
340338 */
341- public TestApplicator skipTodo (final String skip ) {
342- return new TestApplicator (this , skip );
339+ public TestApplicator skipUnknownReason (final String reason ) {
340+ return new TestApplicator (this , reason );
343341 }
344342
345343 public TestApplicator modify (final Modifier ... modifiers ) {
@@ -360,10 +358,6 @@ public boolean wasAssignedModifier(final Modifier modifier) {
360358 */
361359 public static final class TestApplicator {
362360 private final TestDef testDef ;
363-
364- private final boolean shouldSkip ;
365- @ Nullable
366- private final String reasonToApply ;
367361 private final List <Modifier > modifiersToApply ;
368362 private Supplier <Boolean > precondition ;
369363 private boolean matchWasPerformed = false ;
@@ -372,32 +366,24 @@ private TestApplicator(
372366 final TestDef testDef ,
373367 final List <Modifier > modifiersToApply ) {
374368 this .testDef = testDef ;
375- this .shouldSkip = false ;
376- this .reasonToApply = null ;
377369 this .modifiersToApply = modifiersToApply ;
378370 }
379371
380372 private TestApplicator (
381373 final TestDef testDef ,
382374 @ NonNull
383- final String reason ) {
375+ final String skipReason ) {
384376 this .testDef = testDef ;
385- this .shouldSkip = true ;
386- this .reasonToApply = reason ;
387- this .modifiersToApply = new ArrayList <>();
377+ this .modifiersToApply = Arrays .asList (Modifier .SKIP );
388378 }
389379
390380 private TestApplicator onMatch (final boolean match ) {
391381 matchWasPerformed = true ;
392382 if (precondition != null && !precondition .get ()) {
393383 return this ;
394384 }
395- if (shouldSkip ) {
396- assumeFalse (match , reasonToApply );
397- } else {
398- if (match ) {
399- this .testDef .modifiers .addAll (this .modifiersToApply );
400- }
385+ if (match ) {
386+ this .testDef .modifiers .addAll (this .modifiersToApply );
401387 }
402388 return this ;
403389 }
@@ -510,5 +496,9 @@ public enum Modifier {
510496 * Reactive only.
511497 */
512498 WAIT_FOR_BATCH_CURSOR_CREATION ,
499+ /**
500+ * Skip the test.
501+ */
502+ SKIP ,
513503 }
514504}
0 commit comments