17
17
package com .mongodb .client .unified ;
18
18
19
19
import com .mongodb .assertions .Assertions ;
20
- import com .mongodb .lang .NonNull ;
21
- import com .mongodb .lang .Nullable ;
22
20
23
21
import java .util .ArrayList ;
24
22
import java .util .Arrays ;
30
28
import static com .mongodb .ClusterFixture .isServerlessTest ;
31
29
import static com .mongodb .ClusterFixture .isSharded ;
32
30
import static com .mongodb .ClusterFixture .serverVersionLessThan ;
31
+ import static com .mongodb .assertions .Assertions .assertNotNull ;
33
32
import static com .mongodb .client .unified .UnifiedTestModifications .Modifier .IGNORE_EXTRA_EVENTS ;
33
+ import static com .mongodb .client .unified .UnifiedTestModifications .Modifier .SKIP ;
34
34
import static com .mongodb .client .unified .UnifiedTestModifications .Modifier .SLEEP_AFTER_CURSOR_CLOSE ;
35
35
import static com .mongodb .client .unified .UnifiedTestModifications .Modifier .SLEEP_AFTER_CURSOR_OPEN ;
36
36
import static com .mongodb .client .unified .UnifiedTestModifications .Modifier .WAIT_FOR_BATCH_CURSOR_CREATION ;
37
- import static org .junit .jupiter .api .Assumptions .assumeFalse ;
38
37
39
38
public final class UnifiedTestModifications {
40
39
public static void doSkips (final TestDef def ) {
@@ -90,7 +89,7 @@ public static void doSkips(final TestDef def) {
90
89
// added as part of https://jira.mongodb.org/browse/JAVA-4976 , but unknown Jira to complete
91
90
// The implementation of the functionality related to clearing the connection pool before closing the connection
92
91
// will be carried out once the specification is finalized and ready.
93
- def .skipTodo ("" )
92
+ def .skipUnknownReason ("" )
94
93
.test ("connection-monitoring-and-pooling/logging" , "connection-logging" , "Connection checkout fails due to error establishing connection" );
95
94
96
95
// load-balancers
@@ -129,7 +128,7 @@ public static void doSkips(final TestDef def) {
129
128
.test ("crud" , "count" , "Deprecated count without a filter" )
130
129
.test ("crud" , "count" , "Deprecated count with a filter" )
131
130
.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" )
133
132
.test ("crud" , "findOneAndReplace-hint-unacknowledged" , "Unacknowledged findOneAndReplace with hint string on 4.4+ server" )
134
133
.test ("crud" , "findOneAndReplace-hint-unacknowledged" , "Unacknowledged findOneAndReplace with hint document on 4.4+ server" )
135
134
.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
292
291
* Test is skipped because it is pending implementation, and there is
293
292
* a Jira ticket tracking this which has more information.
294
293
*
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
296
295
*/
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 );
300
299
}
301
300
302
301
/**
303
302
* Test is skipped because the feature under test was deprecated, and
304
303
* was removed in the Java driver.
305
304
*
306
- * @param skip reason for skipping the test
305
+ * @param reason reason for skipping the test
307
306
*/
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 );
310
309
}
311
310
312
311
/**
313
312
* Test is skipped because the Java driver cannot comply with the spec.
314
313
*
315
- * @param skip reason for skipping the test
314
+ * @param reason reason for skipping the test
316
315
*/
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 );
319
318
}
320
319
321
320
/**
322
321
* Test is skipped because the Java Reactive driver cannot comply with the spec.
323
322
*
324
- * @param skip reason for skipping the test
323
+ * @param reason reason for skipping the test
325
324
*/
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 );
328
327
}
329
328
330
329
/**
331
330
* The test is skipped, as specified. This should be paired with a
332
331
* "when" clause.
333
332
*/
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 );
336
335
}
337
336
338
337
/**
339
338
* The test is skipped for an unknown reason.
340
339
*/
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 );
343
342
}
344
343
345
344
public TestApplicator modify (final Modifier ... modifiers ) {
346
- return new TestApplicator (this , Arrays . asList ( modifiers ) );
345
+ return new TestApplicator (this , null , modifiers );
347
346
}
348
347
349
348
public boolean isReactive () {
@@ -360,44 +359,28 @@ public boolean wasAssignedModifier(final Modifier modifier) {
360
359
*/
361
360
public static final class TestApplicator {
362
361
private final TestDef testDef ;
363
-
364
- private final boolean shouldSkip ;
365
- @ Nullable
366
- private final String reasonToApply ;
367
362
private final List <Modifier > modifiersToApply ;
368
363
private Supplier <Boolean > precondition ;
369
364
private boolean matchWasPerformed = false ;
370
365
371
366
private TestApplicator (
372
367
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 ) {
384
370
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
+ }
388
375
}
389
376
390
377
private TestApplicator onMatch (final boolean match ) {
391
378
matchWasPerformed = true ;
392
379
if (precondition != null && !precondition .get ()) {
393
380
return this ;
394
381
}
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 );
401
384
}
402
385
return this ;
403
386
}
@@ -510,5 +493,9 @@ public enum Modifier {
510
493
* Reactive only.
511
494
*/
512
495
WAIT_FOR_BATCH_CURSOR_CREATION ,
496
+ /**
497
+ * Skip the test.
498
+ */
499
+ SKIP ,
513
500
}
514
501
}
0 commit comments