forked from junit-team/junit5
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce support for converting from a URI of the form method:<FQMN>…
… to a MethodSource Introduce support for converting from a URI of the form method:<FQMN> to a MethodSource, where FQMN is the fully qualified method name. See the Javadoc for DiscoverySelectors.selectMethod(String) for the supported formats for a FQMN. Closes junit-teamgh-1850
- Loading branch information
Showing
3 changed files
with
48 additions
and
6 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...t-jupiter-engine/src/main/java/org/junit/jupiter/engine/descriptor/MethodSourceUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.junit.jupiter.engine.descriptor; | ||
|
||
import org.junit.platform.commons.util.Preconditions; | ||
import org.junit.platform.commons.util.ReflectionUtils; | ||
import org.junit.platform.engine.support.descriptor.MethodSource; | ||
|
||
import java.net.URI; | ||
import java.util.Optional; | ||
|
||
class MethodSourceUtils { | ||
|
||
static final String METHOD_SCHEME = "method"; | ||
|
||
static MethodSource fromUri(URI uri) { | ||
Preconditions.notNull(uri, "URI must not be null"); | ||
Preconditions.condition(METHOD_SCHEME.equals(uri.getScheme()), | ||
() -> "URI [" + uri + "] must have [" + METHOD_SCHEME + "] scheme"); | ||
String fragment = Optional.ofNullable(uri.getFragment()).orElseThrow(() -> new IllegalArgumentException("Invalid method URI")); | ||
String fullyQualifiedMethodName = uri.getSchemeSpecificPart() + "#" + fragment; | ||
String[] methodSpecs = ReflectionUtils.parseFullyQualifiedMethodName(fullyQualifiedMethodName); | ||
return MethodSource.from(methodSpecs[0], methodSpecs[1], methodSpecs[2]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters