Skip to content

Commit dea4bb8

Browse files
committed
Polishing
Closes #1895.
1 parent 709bc53 commit dea4bb8

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/descriptor/MethodSourceSupport.java

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,8 @@
1010

1111
package org.junit.jupiter.engine.descriptor;
1212

13-
import static org.apiguardian.api.API.Status.INTERNAL;
14-
1513
import java.net.URI;
1614

17-
import org.apiguardian.api.API;
18-
import org.junit.platform.commons.PreconditionViolationException;
1915
import org.junit.platform.commons.util.Preconditions;
2016
import org.junit.platform.commons.util.ReflectionUtils;
2117
import org.junit.platform.engine.discovery.DiscoverySelectors;
@@ -29,26 +25,24 @@
2925
* @see MethodSource
3026
* @see MethodSelector
3127
*/
32-
@API(status = INTERNAL, since = "5.5")
3328
class MethodSourceSupport {
3429

3530
static final String METHOD_SCHEME = "method";
3631

3732
/**
3833
* Create a new {@code MethodSource} from the supplied {@link URI}.
3934
*
40-
* <p>The supplied {@link URI} should be of the form {@code method:<FQMN>} where FQMN is the fully qualified method name
41-
* see {@link DiscoverySelectors#selectMethod(String)} for the supported formats.
35+
* <p>The supplied {@link URI} should be of the form {@code method:<FQMN>}
36+
* where FQMN is the fully qualified method name. See
37+
* {@link DiscoverySelectors#selectMethod(String)} for the supported formats.
4238
*
43-
* <p></p>The {@link URI#getSchemeSpecificPart() schemeSpecificPart} component of the {@code URI}
44-
* will be used as fully qualified class name. The {@linkplain URI#getFragment() fragment} component of the {@code URI}
39+
* <p></p>The {@link URI#getSchemeSpecificPart() scheme-specific part}
40+
* component of the {@code URI} will be used as fully qualified class name.
41+
* The {@linkplain URI#getFragment() fragment} component of the {@code URI}
4542
* will be used to retrieve the method name and method parameter types.
4643
*
4744
* @param uri the {@code URI} for the method; never {@code null}
4845
* @return a new {@code MethodSource}; never {@code null}
49-
* @throws PreconditionViolationException if the supplied {@code URI} is
50-
* {@code null} or if the scheme of the supplied {@code URI} is not equal to the {@link #METHOD_SCHEME}
51-
* or if {@code URI#getSchemeSpecificPart()} is {@code null} or if {@code URI#getFragment()} is {@code null}
5246
* @since 5.5
5347
* @see #METHOD_SCHEME
5448
* @see DiscoverySelectors#selectMethod(String)
@@ -57,12 +51,14 @@ static MethodSource from(URI uri) {
5751
Preconditions.notNull(uri, "URI must not be null");
5852
Preconditions.condition(METHOD_SCHEME.equals(uri.getScheme()),
5953
() -> "URI [" + uri + "] must have [" + METHOD_SCHEME + "] scheme");
60-
String schemeSpecificPart = uri.getSchemeSpecificPart();
61-
Preconditions.notNull(schemeSpecificPart,
62-
"Invalid method URI. Consult the Javadoc for org.junit.platform.engine.discovery.DiscoverySelectors.selectMethod(String) for details on the supported formats.");
63-
String fragment = uri.getFragment();
64-
Preconditions.notNull(fragment,
65-
"Invalid method URI. Consult the Javadoc for org.junit.platform.engine.discovery.DiscoverySelectors.selectMethod(String) for details on the supported formats.");
54+
String schemeSpecificPart = Preconditions.notNull(uri.getSchemeSpecificPart(),
55+
() -> "Invalid method URI (scheme-specific part must not be null). Please consult the Javadoc of "
56+
+ DiscoverySelectors.class.getName()
57+
+ "#selectMethod(String) for details on the supported formats.");
58+
String fragment = Preconditions.notNull(uri.getFragment(),
59+
() -> "Invalid method URI (fragment must not be null). Please consult the Javadoc of "
60+
+ DiscoverySelectors.class.getName()
61+
+ "#selectMethod(String) for details on the supported formats.");
6662

6763
String fullyQualifiedMethodName = schemeSpecificPart + "#" + fragment;
6864
String[] methodSpec = ReflectionUtils.parseFullyQualifiedMethodName(fullyQualifiedMethodName);

junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/descriptor/TestFactoryTestDescriptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ static TestSource fromUri(URI uri) {
169169
if (CLASSPATH_SCHEME.equals(uri.getScheme())) {
170170
return ClasspathResourceSource.from(uri);
171171
}
172-
else if (METHOD_SCHEME.equals(uri.getScheme())) {
172+
if (METHOD_SCHEME.equals(uri.getScheme())) {
173173
return MethodSourceSupport.from(uri);
174174
}
175175
return UriSource.from(uri);

0 commit comments

Comments
 (0)