Search in sources :

Example 1 with GradleVersions

use of org.springframework.boot.testsupport.gradle.testkit.GradleVersions in project spring-boot by spring-projects.

the class GradleCompatibilityExtension method provideTestTemplateInvocationContexts.

@Override
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(ExtensionContext context) {
    Stream<String> gradleVersions = GRADLE_VERSIONS.stream();
    GradleCompatibility gradleCompatibility = AnnotationUtils.findAnnotation(context.getRequiredTestClass(), GradleCompatibility.class).get();
    if (StringUtils.hasText(gradleCompatibility.versionsLessThan())) {
        GradleVersion upperExclusive = GradleVersion.version(gradleCompatibility.versionsLessThan());
        gradleVersions = gradleVersions.filter((version) -> GradleVersion.version(version).compareTo(upperExclusive) < 0);
    }
    return gradleVersions.flatMap((version) -> {
        List<TestTemplateInvocationContext> invocationContexts = new ArrayList<>();
        invocationContexts.add(new GradleVersionTestTemplateInvocationContext(version, false));
        boolean configurationCache = gradleCompatibility.configurationCache();
        if (configurationCache) {
            invocationContexts.add(new GradleVersionTestTemplateInvocationContext(version, true));
        }
        return invocationContexts.stream();
    });
}
Also used : GradleBuild(org.springframework.boot.testsupport.gradle.testkit.GradleBuild) Arrays(java.util.Arrays) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) ArrayList(java.util.ArrayList) Extension(org.junit.jupiter.api.extension.Extension) List(java.util.List) TestTemplate(org.junit.jupiter.api.TestTemplate) Stream(java.util.stream.Stream) GradleVersions(org.springframework.boot.testsupport.gradle.testkit.GradleVersions) TestTemplateInvocationContext(org.junit.jupiter.api.extension.TestTemplateInvocationContext) GradleBuildExtension(org.springframework.boot.testsupport.gradle.testkit.GradleBuildExtension) TestTemplateInvocationContextProvider(org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider) AnnotationUtils(org.junit.platform.commons.util.AnnotationUtils) GradleVersion(org.gradle.util.GradleVersion) StringUtils(org.springframework.util.StringUtils) ArrayList(java.util.ArrayList) TestTemplateInvocationContext(org.junit.jupiter.api.extension.TestTemplateInvocationContext) GradleVersion(org.gradle.util.GradleVersion)

Aggregations

ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Stream (java.util.stream.Stream)1 GradleVersion (org.gradle.util.GradleVersion)1 TestTemplate (org.junit.jupiter.api.TestTemplate)1 Extension (org.junit.jupiter.api.extension.Extension)1 ExtensionContext (org.junit.jupiter.api.extension.ExtensionContext)1 TestTemplateInvocationContext (org.junit.jupiter.api.extension.TestTemplateInvocationContext)1 TestTemplateInvocationContextProvider (org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider)1 AnnotationUtils (org.junit.platform.commons.util.AnnotationUtils)1 GradleBuild (org.springframework.boot.testsupport.gradle.testkit.GradleBuild)1 GradleBuildExtension (org.springframework.boot.testsupport.gradle.testkit.GradleBuildExtension)1 GradleVersions (org.springframework.boot.testsupport.gradle.testkit.GradleVersions)1 StringUtils (org.springframework.util.StringUtils)1