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" )
@@ -295,58 +294,58 @@ private TestDef(final String dir, final String file, final String test, final bo
295
294
* Test is skipped because it is pending implementation, and there is
296
295
* a Jira ticket tracking this which has more information.
297
296
*
298
- * @param skip reason for skipping the test; must start with a Jira URL
297
+ * @param ticket reason for skipping the test; must start with a Jira URL
299
298
*/
300
- public TestApplicator skipJira (final String skip ) {
301
- Assertions .assertTrue (skip .startsWith ("https://jira.mongodb.org/browse/JAVA-" ));
302
- return new TestApplicator (this , skip );
299
+ public TestApplicator skipJira (final String ticket ) {
300
+ Assertions .assertTrue (ticket .startsWith ("https://jira.mongodb.org/browse/JAVA-" ));
301
+ return new TestApplicator (this , ticket , SKIP );
303
302
}
304
303
305
304
/**
306
305
* Test is skipped because the feature under test was deprecated, and
307
306
* was removed in the Java driver.
308
307
*
309
- * @param skip reason for skipping the test
308
+ * @param reason reason for skipping the test
310
309
*/
311
- public TestApplicator skipDeprecated (final String skip ) {
312
- return new TestApplicator (this , skip );
310
+ public TestApplicator skipDeprecated (final String reason ) {
311
+ return new TestApplicator (this , reason , SKIP );
313
312
}
314
313
315
314
/**
316
315
* Test is skipped because the Java driver cannot comply with the spec.
317
316
*
318
- * @param skip reason for skipping the test
317
+ * @param reason reason for skipping the test
319
318
*/
320
- public TestApplicator skipNoncompliant (final String skip ) {
321
- return new TestApplicator (this , skip );
319
+ public TestApplicator skipNoncompliant (final String reason ) {
320
+ return new TestApplicator (this , reason , SKIP );
322
321
}
323
322
324
323
/**
325
324
* Test is skipped because the Java Reactive driver cannot comply with the spec.
326
325
*
327
- * @param skip reason for skipping the test
326
+ * @param reason reason for skipping the test
328
327
*/
329
- public TestApplicator skipNoncompliantReactive (final String skip ) {
330
- return new TestApplicator (this , skip );
328
+ public TestApplicator skipNoncompliantReactive (final String reason ) {
329
+ return new TestApplicator (this , reason , SKIP );
331
330
}
332
331
333
332
/**
334
333
* The test is skipped, as specified. This should be paired with a
335
334
* "when" clause.
336
335
*/
337
- public TestApplicator skipAccordingToSpec (final String skip ) {
338
- return new TestApplicator (this , skip );
336
+ public TestApplicator skipAccordingToSpec (final String reason ) {
337
+ return new TestApplicator (this , reason , SKIP );
339
338
}
340
339
341
340
/**
342
341
* The test is skipped for an unknown reason.
343
342
*/
344
- public TestApplicator skipTodo (final String skip ) {
345
- return new TestApplicator (this , skip );
343
+ public TestApplicator skipUnknownReason (final String reason ) {
344
+ return new TestApplicator (this , reason , SKIP );
346
345
}
347
346
348
347
public TestApplicator modify (final Modifier ... modifiers ) {
349
- return new TestApplicator (this , Arrays . asList ( modifiers ) );
348
+ return new TestApplicator (this , null , modifiers );
350
349
}
351
350
352
351
public boolean isReactive () {
@@ -363,44 +362,28 @@ public boolean wasAssignedModifier(final Modifier modifier) {
363
362
*/
364
363
public static final class TestApplicator {
365
364
private final TestDef testDef ;
366
-
367
- private final boolean shouldSkip ;
368
- @ Nullable
369
- private final String reasonToApply ;
370
365
private final List <Modifier > modifiersToApply ;
371
366
private Supplier <Boolean > precondition ;
372
367
private boolean matchWasPerformed = false ;
373
368
374
369
private TestApplicator (
375
370
final TestDef testDef ,
376
- final List <Modifier > modifiersToApply ) {
377
- this .testDef = testDef ;
378
- this .shouldSkip = false ;
379
- this .reasonToApply = null ;
380
- this .modifiersToApply = modifiersToApply ;
381
- }
382
-
383
- private TestApplicator (
384
- final TestDef testDef ,
385
- @ NonNull
386
- final String reason ) {
371
+ final String reason ,
372
+ final Modifier ... modifiersToApply ) {
387
373
this .testDef = testDef ;
388
- this .shouldSkip = true ;
389
- this .reasonToApply = reason ;
390
- this .modifiersToApply = new ArrayList <>();
374
+ this .modifiersToApply = Arrays .asList (modifiersToApply );
375
+ if (this .modifiersToApply .contains (SKIP )) {
376
+ assertNotNull (reason );
377
+ }
391
378
}
392
379
393
380
private TestApplicator onMatch (final boolean match ) {
394
381
matchWasPerformed = true ;
395
382
if (precondition != null && !precondition .get ()) {
396
383
return this ;
397
384
}
398
- if (shouldSkip ) {
399
- assumeFalse (match , reasonToApply );
400
- } else {
401
- if (match ) {
402
- this .testDef .modifiers .addAll (this .modifiersToApply );
403
- }
385
+ if (match ) {
386
+ this .testDef .modifiers .addAll (this .modifiersToApply );
404
387
}
405
388
return this ;
406
389
}
@@ -513,5 +496,9 @@ public enum Modifier {
513
496
* Reactive only.
514
497
*/
515
498
WAIT_FOR_BATCH_CURSOR_CREATION ,
499
+ /**
500
+ * Skip the test.
501
+ */
502
+ SKIP ,
516
503
}
517
504
}
0 commit comments