Search in sources :

Example 1 with AppServerContainer

use of org.keycloak.testsuite.arquillian.annotation.AppServerContainer in project keycloak by keycloak.

the class AdapterTestExecutionDecider method getCorrespondingAnnotation.

private AppServerContainer getCorrespondingAnnotation(Method method) {
    AppServerContainers multipleAnnotations = method.getAnnotation(AppServerContainers.class);
    List<AppServerContainer> appServerContainers;
    if (multipleAnnotations != null) {
        // more than one @AppServerContainer annotation
        appServerContainers = Arrays.asList(multipleAnnotations.value());
    } else {
        // single @AppServerContainer annotation
        appServerContainers = Arrays.asList(method.getAnnotation(AppServerContainer.class));
    }
    return appServerContainers.stream().filter(annotation -> annotation.value().equals(testContextInstance.get().getAppServerContainerName())).findFirst().orElse(null);
}
Also used : AppServerContainer(org.keycloak.testsuite.arquillian.annotation.AppServerContainer) AppServerContainers(org.keycloak.testsuite.arquillian.annotation.AppServerContainers)

Example 2 with AppServerContainer

use of org.keycloak.testsuite.arquillian.annotation.AppServerContainer in project keycloak by keycloak.

the class AdapterTestExecutionDecider method getCorrespondingAnnotation.

private AppServerContainer getCorrespondingAnnotation(Class testClass) {
    Class<?> annotatedClass = AppServerTestEnricher.getNearestSuperclassWithAppServerAnnotation(testClass);
    AppServerContainers multipleAnnotations = annotatedClass.getAnnotation(AppServerContainers.class);
    List<AppServerContainer> appServerContainers;
    if (multipleAnnotations != null) {
        // more than one @AppServerContainer annotation
        appServerContainers = Arrays.asList(multipleAnnotations.value());
    } else {
        // single @AppServerContainer annotation
        appServerContainers = Arrays.asList(annotatedClass.getAnnotation(AppServerContainer.class));
    }
    return appServerContainers.stream().filter(annotation -> annotation.value().equals(testContextInstance.get().getAppServerContainerName())).findFirst().orElse(null);
}
Also used : AppServerContainer(org.keycloak.testsuite.arquillian.annotation.AppServerContainer) AppServerContainers(org.keycloak.testsuite.arquillian.annotation.AppServerContainers)

Example 3 with AppServerContainer

use of org.keycloak.testsuite.arquillian.annotation.AppServerContainer in project keycloak by keycloak.

the class AppServerTestEnricher method getAppServerQualifiers.

public static Set<String> getAppServerQualifiers(Class testClass) {
    Set<String> appServerQualifiers = new HashSet<>();
    Class<?> annotatedClass = getNearestSuperclassWithAppServerAnnotation(testClass);
    if (annotatedClass != null) {
        AppServerContainer[] appServerContainers = annotatedClass.getAnnotationsByType(AppServerContainer.class);
        for (AppServerContainer appServerContainer : appServerContainers) {
            appServerQualifiers.add(appServerContainer.value());
        }
    }
    for (Method method : testClass.getDeclaredMethods()) {
        if (method.isAnnotationPresent(AppServerContainers.class)) {
            for (AppServerContainer appServerContainer : method.getAnnotation(AppServerContainers.class).value()) {
                appServerQualifiers.add(appServerContainer.value());
            }
        }
        if (method.isAnnotationPresent(AppServerContainer.class)) {
            appServerQualifiers.add(method.getAnnotation(AppServerContainer.class).value());
        }
    }
    return appServerQualifiers;
}
Also used : AppServerContainer(org.keycloak.testsuite.arquillian.annotation.AppServerContainer) AppServerContainers(org.keycloak.testsuite.arquillian.annotation.AppServerContainers) Method(java.lang.reflect.Method) HashSet(java.util.HashSet)

Aggregations

AppServerContainer (org.keycloak.testsuite.arquillian.annotation.AppServerContainer)3 AppServerContainers (org.keycloak.testsuite.arquillian.annotation.AppServerContainers)3 Method (java.lang.reflect.Method)1 HashSet (java.util.HashSet)1