1717package com .mongodb .client .unified ;
1818
1919import com .mongodb .assertions .Assertions ;
20- import com .mongodb .lang .NonNull ;
21- import com .mongodb .lang .Nullable ;
2220
2321import java .util .ArrayList ;
2422import java .util .Arrays ;
3028import static com .mongodb .ClusterFixture .isServerlessTest ;
3129import static com .mongodb .ClusterFixture .isSharded ;
3230import static com .mongodb .ClusterFixture .serverVersionLessThan ;
31+ import static com .mongodb .assertions .Assertions .assertNotNull ;
3332import static com .mongodb .client .unified .UnifiedTestModifications .Modifier .IGNORE_EXTRA_EVENTS ;
33+ import static com .mongodb .client .unified .UnifiedTestModifications .Modifier .SKIP ;
3434import static com .mongodb .client .unified .UnifiedTestModifications .Modifier .SLEEP_AFTER_CURSOR_CLOSE ;
3535import static com .mongodb .client .unified .UnifiedTestModifications .Modifier .SLEEP_AFTER_CURSOR_OPEN ;
3636import static com .mongodb .client .unified .UnifiedTestModifications .Modifier .WAIT_FOR_BATCH_CURSOR_CREATION ;
37- import static org .junit .jupiter .api .Assumptions .assumeFalse ;
3837
3938public final class UnifiedTestModifications {
4039 public static void doSkips (final TestDef def ) {
@@ -90,7 +89,7 @@ public static void doSkips(final TestDef def) {
9089 // added as part of https://jira.mongodb.org/browse/JAVA-4976 , but unknown Jira to complete
9190 // The implementation of the functionality related to clearing the connection pool before closing the connection
9291 // will be carried out once the specification is finalized and ready.
93- def .skipTodo ("" )
92+ def .skipUnknownReason ("" )
9493 .test ("connection-monitoring-and-pooling/logging" , "connection-logging" , "Connection checkout fails due to error establishing connection" );
9594
9695 // load-balancers
@@ -129,7 +128,7 @@ public static void doSkips(final TestDef def) {
129128 .test ("crud" , "count" , "Deprecated count without a filter" )
130129 .test ("crud" , "count" , "Deprecated count with a filter" )
131130 .test ("crud" , "count" , "Deprecated count with skip and limit" );
132- def .skipTodo ("See downstream changes comment on https://jira.mongodb.org/browse/JAVA-4275" )
131+ def .skipUnknownReason ("See downstream changes comment on https://jira.mongodb.org/browse/JAVA-4275" )
133132 .test ("crud" , "findOneAndReplace-hint-unacknowledged" , "Unacknowledged findOneAndReplace with hint string on 4.4+ server" )
134133 .test ("crud" , "findOneAndReplace-hint-unacknowledged" , "Unacknowledged findOneAndReplace with hint document on 4.4+ server" )
135134 .test ("crud" , "findOneAndUpdate-hint-unacknowledged" , "Unacknowledged findOneAndUpdate with hint string on 4.4+ server" )
@@ -292,58 +291,58 @@ private TestDef(final String dir, final String file, final String test, final bo
292291 * Test is skipped because it is pending implementation, and there is
293292 * a Jira ticket tracking this which has more information.
294293 *
295- * @param skip reason for skipping the test; must start with a Jira URL
294+ * @param ticket reason for skipping the test; must start with a Jira URL
296295 */
297- public TestApplicator skipJira (final String skip ) {
298- Assertions .assertTrue (skip .startsWith ("https://jira.mongodb.org/browse/JAVA-" ));
299- return new TestApplicator (this , skip );
296+ public TestApplicator skipJira (final String ticket ) {
297+ Assertions .assertTrue (ticket .startsWith ("https://jira.mongodb.org/browse/JAVA-" ));
298+ return new TestApplicator (this , ticket , SKIP );
300299 }
301300
302301 /**
303302 * Test is skipped because the feature under test was deprecated, and
304303 * was removed in the Java driver.
305304 *
306- * @param skip reason for skipping the test
305+ * @param reason reason for skipping the test
307306 */
308- public TestApplicator skipDeprecated (final String skip ) {
309- return new TestApplicator (this , skip );
307+ public TestApplicator skipDeprecated (final String reason ) {
308+ return new TestApplicator (this , reason , SKIP );
310309 }
311310
312311 /**
313312 * Test is skipped because the Java driver cannot comply with the spec.
314313 *
315- * @param skip reason for skipping the test
314+ * @param reason reason for skipping the test
316315 */
317- public TestApplicator skipNoncompliant (final String skip ) {
318- return new TestApplicator (this , skip );
316+ public TestApplicator skipNoncompliant (final String reason ) {
317+ return new TestApplicator (this , reason , SKIP );
319318 }
320319
321320 /**
322321 * Test is skipped because the Java Reactive driver cannot comply with the spec.
323322 *
324- * @param skip reason for skipping the test
323+ * @param reason reason for skipping the test
325324 */
326- public TestApplicator skipNoncompliantReactive (final String skip ) {
327- return new TestApplicator (this , skip );
325+ public TestApplicator skipNoncompliantReactive (final String reason ) {
326+ return new TestApplicator (this , reason , SKIP );
328327 }
329328
330329 /**
331330 * The test is skipped, as specified. This should be paired with a
332331 * "when" clause.
333332 */
334- public TestApplicator skipAccordingToSpec (final String skip ) {
335- return new TestApplicator (this , skip );
333+ public TestApplicator skipAccordingToSpec (final String reason ) {
334+ return new TestApplicator (this , reason , SKIP );
336335 }
337336
338337 /**
339338 * The test is skipped for an unknown reason.
340339 */
341- public TestApplicator skipTodo (final String skip ) {
342- return new TestApplicator (this , skip );
340+ public TestApplicator skipUnknownReason (final String reason ) {
341+ return new TestApplicator (this , reason , SKIP );
343342 }
344343
345344 public TestApplicator modify (final Modifier ... modifiers ) {
346- return new TestApplicator (this , Arrays . asList ( modifiers ) );
345+ return new TestApplicator (this , null , modifiers );
347346 }
348347
349348 public boolean isReactive () {
@@ -360,44 +359,28 @@ public boolean wasAssignedModifier(final Modifier modifier) {
360359 */
361360 public static final class TestApplicator {
362361 private final TestDef testDef ;
363-
364- private final boolean shouldSkip ;
365- @ Nullable
366- private final String reasonToApply ;
367362 private final List <Modifier > modifiersToApply ;
368363 private Supplier <Boolean > precondition ;
369364 private boolean matchWasPerformed = false ;
370365
371366 private TestApplicator (
372367 final TestDef testDef ,
373- final List <Modifier > modifiersToApply ) {
374- this .testDef = testDef ;
375- this .shouldSkip = false ;
376- this .reasonToApply = null ;
377- this .modifiersToApply = modifiersToApply ;
378- }
379-
380- private TestApplicator (
381- final TestDef testDef ,
382- @ NonNull
383- final String reason ) {
368+ final String reason ,
369+ final Modifier ... modifiersToApply ) {
384370 this .testDef = testDef ;
385- this .shouldSkip = true ;
386- this .reasonToApply = reason ;
387- this .modifiersToApply = new ArrayList <>();
371+ this .modifiersToApply = Arrays .asList (modifiersToApply );
372+ if (this .modifiersToApply .contains (SKIP )) {
373+ assertNotNull (reason );
374+ }
388375 }
389376
390377 private TestApplicator onMatch (final boolean match ) {
391378 matchWasPerformed = true ;
392379 if (precondition != null && !precondition .get ()) {
393380 return this ;
394381 }
395- if (shouldSkip ) {
396- assumeFalse (match , reasonToApply );
397- } else {
398- if (match ) {
399- this .testDef .modifiers .addAll (this .modifiersToApply );
400- }
382+ if (match ) {
383+ this .testDef .modifiers .addAll (this .modifiersToApply );
401384 }
402385 return this ;
403386 }
@@ -510,5 +493,9 @@ public enum Modifier {
510493 * Reactive only.
511494 */
512495 WAIT_FOR_BATCH_CURSOR_CREATION ,
496+ /**
497+ * Skip the test.
498+ */
499+ SKIP ,
513500 }
514501}
0 commit comments