use of io.quarkus.test.common.http.TestHTTPEndpoint in project quarkus by quarkusio.
the class QuarkusTestExtension method getEndpointPath.
public static String getEndpointPath(ExtensionContext context, List<Function<Class<?>, String>> testHttpEndpointProviders) {
String endpointPath = null;
TestHTTPEndpoint testHTTPEndpoint = context.getRequiredTestMethod().getAnnotation(TestHTTPEndpoint.class);
if (testHTTPEndpoint == null) {
Class<?> clazz = context.getRequiredTestClass();
while (true) {
// go up the hierarchy because most Native tests extend from a regular Quarkus test
testHTTPEndpoint = clazz.getAnnotation(TestHTTPEndpoint.class);
if (testHTTPEndpoint != null) {
break;
}
clazz = clazz.getSuperclass();
if (clazz == Object.class) {
break;
}
}
}
if (testHTTPEndpoint != null) {
for (Function<Class<?>, String> i : testHttpEndpointProviders) {
endpointPath = i.apply(testHTTPEndpoint.value());
if (endpointPath != null) {
break;
}
}
if (endpointPath == null) {
throw new RuntimeException("Cannot determine HTTP path for endpoint " + testHTTPEndpoint.value() + " for test method " + context.getRequiredTestMethod());
}
}
if (endpointPath != null) {
if (endpointPath.indexOf(':') != -1) {
return sanitizeEndpointPath(endpointPath);
}
}
return endpointPath;
}
Aggregations