@@ -457,23 +457,7 @@ private MethodSelector selectMethod(Class<?> suiteClass, SelectMethod annotation
457
457
458
458
private MethodSelector toMethodSelector (Class <?> suiteClass , SelectMethod annotation ) {
459
459
if (!annotation .value ().isEmpty ()) {
460
- Preconditions .condition (annotation .type () == Class .class ,
461
- () -> prefixErrorMessageForInvalidSelectMethodUsage (suiteClass ,
462
- "type must not be set in conjunction with fully qualified method name" ));
463
- Preconditions .condition (annotation .typeName ().isEmpty (),
464
- () -> prefixErrorMessageForInvalidSelectMethodUsage (suiteClass ,
465
- "type name must not be set in conjunction with fully qualified method name" ));
466
- Preconditions .condition (annotation .name ().isEmpty (),
467
- () -> prefixErrorMessageForInvalidSelectMethodUsage (suiteClass ,
468
- "method name must not be set in conjunction with fully qualified method name" ));
469
- Preconditions .condition (annotation .parameterTypes ().length == 0 ,
470
- () -> prefixErrorMessageForInvalidSelectMethodUsage (suiteClass ,
471
- "parameter types must not be set in conjunction with fully qualified method name" ));
472
- Preconditions .condition (annotation .parameterTypeNames ().isEmpty (),
473
- () -> prefixErrorMessageForInvalidSelectMethodUsage (suiteClass ,
474
- "parameter type names must not be set in conjunction with fully qualified method name" ));
475
-
476
- return DiscoverySelectors .selectMethod (annotation .value ());
460
+ return toMethodSelectorFromFQMN (suiteClass , annotation );
477
461
}
478
462
479
463
Class <?> type = annotation .type () == Class .class ? null : annotation .type ();
@@ -487,25 +471,44 @@ private MethodSelector toMethodSelector(Class<?> suiteClass, SelectMethod annota
487
471
() -> prefixErrorMessageForInvalidSelectMethodUsage (suiteClass ,
488
472
"either parameter type names or parameter types must be set but not both" ));
489
473
}
474
+ return toMethodSelector (suiteClass , type , typeName , parameterTypes , methodName , parameterTypeNames );
475
+ }
476
+
477
+ private static MethodSelector toMethodSelectorFromFQMN (Class <?> suiteClass , SelectMethod annotation ) {
478
+ Preconditions .condition (annotation .type () == Class .class ,
479
+ () -> prefixErrorMessageForInvalidSelectMethodUsage (suiteClass ,
480
+ "type must not be set in conjunction with fully qualified method name" ));
481
+ Preconditions .condition (annotation .typeName ().isEmpty (),
482
+ () -> prefixErrorMessageForInvalidSelectMethodUsage (suiteClass ,
483
+ "type name must not be set in conjunction with fully qualified method name" ));
484
+ Preconditions .condition (annotation .name ().isEmpty (),
485
+ () -> prefixErrorMessageForInvalidSelectMethodUsage (suiteClass ,
486
+ "method name must not be set in conjunction with fully qualified method name" ));
487
+ Preconditions .condition (annotation .parameterTypes ().length == 0 ,
488
+ () -> prefixErrorMessageForInvalidSelectMethodUsage (suiteClass ,
489
+ "parameter types must not be set in conjunction with fully qualified method name" ));
490
+ Preconditions .condition (annotation .parameterTypeNames ().isEmpty (),
491
+ () -> prefixErrorMessageForInvalidSelectMethodUsage (suiteClass ,
492
+ "parameter type names must not be set in conjunction with fully qualified method name" ));
493
+
494
+ return DiscoverySelectors .selectMethod (annotation .value ());
495
+ }
496
+
497
+ private static MethodSelector toMethodSelector (Class <?> suiteClass , Class <?> type , String typeName ,
498
+ Class <?>[] parameterTypes , String methodName , String parameterTypeNames ) {
490
499
if (type == null ) {
491
500
Preconditions .notBlank (typeName , () -> prefixErrorMessageForInvalidSelectMethodUsage (suiteClass ,
492
501
"type must be set or type name must not be blank" ));
493
- if (parameterTypes == null ) {
494
- return DiscoverySelectors .selectMethod (typeName , methodName , parameterTypeNames );
495
- }
496
- else {
497
- return DiscoverySelectors .selectMethod (typeName , methodName , parameterTypes );
498
- }
502
+ return parameterTypes == null //
503
+ ? DiscoverySelectors .selectMethod (typeName , methodName , parameterTypeNames ) //
504
+ : DiscoverySelectors .selectMethod (typeName , methodName , parameterTypes );
499
505
}
500
506
else {
501
507
Preconditions .condition (typeName == null , () -> prefixErrorMessageForInvalidSelectMethodUsage (suiteClass ,
502
508
"either type name or type must be set but not both" ));
503
- if (parameterTypes == null ) {
504
- return DiscoverySelectors .selectMethod (type , methodName , parameterTypeNames );
505
- }
506
- else {
507
- return DiscoverySelectors .selectMethod (type , methodName , parameterTypes );
508
- }
509
+ return parameterTypes == null //
510
+ ? DiscoverySelectors .selectMethod (type , methodName , parameterTypeNames ) //
511
+ : DiscoverySelectors .selectMethod (type , methodName , parameterTypes );
509
512
}
510
513
}
511
514
0 commit comments