From 12f0c4a8a6e4d99ed72ba9d800aff388b9b719a9 Mon Sep 17 00:00:00 2001 From: Patrick Boos Date: Mon, 4 Nov 2024 14:50:20 +0100 Subject: [PATCH] Use testFixtures --- .../spring-boot-starter-web/build.gradle | 4 +-- .../spring-boot-starter-webflux/build.gradle | 4 +-- test/openapi-web/build.gradle | 28 ++++++++++--------- test/openapi-webflux/build.gradle | 28 ++++++++++--------- test/test-utils/build.gradle | 16 +++++++---- .../DefaultSpringBootTestConfiguration.java | 0 .../validation/test/TestViolationLogger.java | 0 .../WithResponseStatusException.java | 0 .../WithoutResponseStatusException.java | 0 9 files changed, 44 insertions(+), 36 deletions(-) rename test/test-utils/src/{main => testFixtures}/java/com/getyourguide/openapi/validation/test/DefaultSpringBootTestConfiguration.java (100%) rename test/test-utils/src/{main => testFixtures}/java/com/getyourguide/openapi/validation/test/TestViolationLogger.java (100%) rename test/test-utils/src/{main => testFixtures}/java/com/getyourguide/openapi/validation/test/exception/WithResponseStatusException.java (100%) rename test/test-utils/src/{main => testFixtures}/java/com/getyourguide/openapi/validation/test/exception/WithoutResponseStatusException.java (100%) diff --git a/spring-boot-starter/spring-boot-starter-web/build.gradle b/spring-boot-starter/spring-boot-starter-web/build.gradle index 57f2e88..ca5be1b 100644 --- a/spring-boot-starter/spring-boot-starter-web/build.gradle +++ b/spring-boot-starter/spring-boot-starter-web/build.gradle @@ -21,8 +21,8 @@ dependencies { // TODO use spotbugs instead and also apply to all modules? implementation(libs.find.bugs) - testImplementation project(':test:test-utils') - testImplementation project(':test:openapi-web') + testImplementation(testFixtures(project(':test:test-utils'))) + testImplementation(testFixtures(project(':test:openapi-web'))) testImplementation 'org.springframework:spring-web' testImplementation 'org.springframework:spring-webmvc' testImplementation 'org.apache.tomcat.embed:tomcat-embed-core' // For jakarta.servlet.ServletContext diff --git a/spring-boot-starter/spring-boot-starter-webflux/build.gradle b/spring-boot-starter/spring-boot-starter-webflux/build.gradle index 5681a0c..1be442b 100644 --- a/spring-boot-starter/spring-boot-starter-webflux/build.gradle +++ b/spring-boot-starter/spring-boot-starter-webflux/build.gradle @@ -20,8 +20,8 @@ dependencies { // TODO use spotbugs instead and also apply to all modules? implementation(libs.find.bugs) - testImplementation project(':test:test-utils') - testImplementation project(':test:openapi-webflux') + testImplementation(testFixtures(project(':test:test-utils'))) + testImplementation(testFixtures(project(':test:openapi-webflux'))) testImplementation 'org.springframework.boot:spring-boot-starter-webflux' testImplementation 'io.projectreactor:reactor-test' testImplementation 'org.apache.tomcat.embed:tomcat-embed-core' // For jakarta.servlet.ServletContext diff --git a/test/openapi-web/build.gradle b/test/openapi-web/build.gradle index 1778508..abaea6a 100644 --- a/test/openapi-web/build.gradle +++ b/test/openapi-web/build.gradle @@ -2,35 +2,37 @@ import org.springframework.boot.gradle.plugin.SpringBootPlugin plugins { id 'java-library' + id 'java-test-fixtures' alias(libs.plugins.spring.boot) apply false alias(libs.plugins.openapi.generator) } dependencies { - implementation platform(SpringBootPlugin.BOM_COORDINATES) + testFixturesImplementation platform(SpringBootPlugin.BOM_COORDINATES) - compileOnly project(':openapi-validation-api') - compileOnly project(':openapi-validation-core') + testFixturesCompileOnly project(':openapi-validation-api') + testFixturesCompileOnly project(':openapi-validation-core') - compileOnly 'org.springframework.boot:spring-boot-starter' - compileOnly 'org.springframework:spring-web' + testFixturesCompileOnly 'org.springframework.boot:spring-boot-starter' + testFixturesCompileOnly 'org.springframework:spring-web' // TODO use spotbugs instead and also apply to all modules? - implementation(libs.find.bugs) + testFixturesImplementation(libs.find.bugs) - api 'org.springframework.boot:spring-boot-starter-test' + testFixturesApi platform(SpringBootPlugin.BOM_COORDINATES) + testFixturesApi 'org.springframework.boot:spring-boot-starter-test' // For openapi generated code - implementation 'org.springframework.boot:spring-boot-starter-validation' - implementation(libs.openapi.tools.jacksonDatabindNullable) - implementation(libs.jakarta.validation.api) - implementation(libs.swagger.annotations) - api 'org.apache.tomcat.embed:tomcat-embed-core' // For jakarta.servlet.ServletContext + testFixturesApi 'org.springframework.boot:spring-boot-starter-validation' + testFixturesApi(libs.openapi.tools.jacksonDatabindNullable) + testFixturesApi(libs.jakarta.validation.api) + testFixturesApi(libs.swagger.annotations) + testFixturesApi 'org.apache.tomcat.embed:tomcat-embed-core' // For jakarta.servlet.ServletContext } def generatedSourceDirectory = "$buildDir/generated/openapi" sourceSets { - main { + testFixtures { java { srcDir generatedSourceDirectory + '/src/main/java' } diff --git a/test/openapi-webflux/build.gradle b/test/openapi-webflux/build.gradle index 3613cb3..5473b78 100644 --- a/test/openapi-webflux/build.gradle +++ b/test/openapi-webflux/build.gradle @@ -2,35 +2,37 @@ import org.springframework.boot.gradle.plugin.SpringBootPlugin plugins { id 'java-library' + id 'java-test-fixtures' alias(libs.plugins.spring.boot) apply false alias(libs.plugins.openapi.generator) } dependencies { - implementation platform(SpringBootPlugin.BOM_COORDINATES) + testFixturesImplementation platform(SpringBootPlugin.BOM_COORDINATES) - compileOnly project(':openapi-validation-api') - compileOnly project(':openapi-validation-core') + testFixturesCompileOnly project(':openapi-validation-api') + testFixturesCompileOnly project(':openapi-validation-core') - compileOnly 'org.springframework.boot:spring-boot-starter' - compileOnly 'org.springframework:spring-webflux' + testFixturesCompileOnly 'org.springframework.boot:spring-boot-starter' + testFixturesCompileOnly 'org.springframework:spring-webflux' // TODO use spotbugs instead and also apply to all modules? - implementation(libs.find.bugs) + testFixturesImplementation(libs.find.bugs) - api 'org.springframework.boot:spring-boot-starter-test' + testFixturesApi platform(SpringBootPlugin.BOM_COORDINATES) + testFixturesApi 'org.springframework.boot:spring-boot-starter-test' // For openapi generated code - implementation 'org.springframework.boot:spring-boot-starter-validation' - implementation(libs.openapi.tools.jacksonDatabindNullable) - implementation(libs.jakarta.validation.api) - implementation(libs.swagger.annotations) - api 'org.apache.tomcat.embed:tomcat-embed-core' // For jakarta.servlet.ServletContext + testFixturesApi 'org.springframework.boot:spring-boot-starter-validation' + testFixturesApi(libs.openapi.tools.jacksonDatabindNullable) + testFixturesApi(libs.jakarta.validation.api) + testFixturesApi(libs.swagger.annotations) + testFixturesApi 'org.apache.tomcat.embed:tomcat-embed-core' // For jakarta.servlet.ServletContext } def generatedSourceDirectory = "$buildDir/generated/openapi" sourceSets { - main { + testFixtures { java { srcDir generatedSourceDirectory + '/src/main/java' } diff --git a/test/test-utils/build.gradle b/test/test-utils/build.gradle index d20371d..ac938c3 100644 --- a/test/test-utils/build.gradle +++ b/test/test-utils/build.gradle @@ -2,18 +2,22 @@ import org.springframework.boot.gradle.plugin.SpringBootPlugin plugins { id 'java-library' + id 'java-test-fixtures' alias(libs.plugins.spring.boot) apply false } dependencies { - implementation platform(SpringBootPlugin.BOM_COORDINATES) + testFixturesImplementation platform(SpringBootPlugin.BOM_COORDINATES) - compileOnly project(':openapi-validation-api') - compileOnly project(':openapi-validation-core') + testFixturesCompileOnly(libs.lombok) + testFixturesAnnotationProcessor(libs.lombok) + + testFixturesCompileOnly project(':openapi-validation-api') + testFixturesCompileOnly project(':openapi-validation-core') // TODO use spotbugs instead and also apply to all modules? - implementation(libs.find.bugs) + testFixturesImplementation(libs.find.bugs) - compileOnly 'org.springframework.boot:spring-boot-starter' - compileOnly 'org.springframework:spring-web' + testFixturesCompileOnly 'org.springframework.boot:spring-boot-starter' + testFixturesCompileOnly 'org.springframework:spring-web' } diff --git a/test/test-utils/src/main/java/com/getyourguide/openapi/validation/test/DefaultSpringBootTestConfiguration.java b/test/test-utils/src/testFixtures/java/com/getyourguide/openapi/validation/test/DefaultSpringBootTestConfiguration.java similarity index 100% rename from test/test-utils/src/main/java/com/getyourguide/openapi/validation/test/DefaultSpringBootTestConfiguration.java rename to test/test-utils/src/testFixtures/java/com/getyourguide/openapi/validation/test/DefaultSpringBootTestConfiguration.java diff --git a/test/test-utils/src/main/java/com/getyourguide/openapi/validation/test/TestViolationLogger.java b/test/test-utils/src/testFixtures/java/com/getyourguide/openapi/validation/test/TestViolationLogger.java similarity index 100% rename from test/test-utils/src/main/java/com/getyourguide/openapi/validation/test/TestViolationLogger.java rename to test/test-utils/src/testFixtures/java/com/getyourguide/openapi/validation/test/TestViolationLogger.java diff --git a/test/test-utils/src/main/java/com/getyourguide/openapi/validation/test/exception/WithResponseStatusException.java b/test/test-utils/src/testFixtures/java/com/getyourguide/openapi/validation/test/exception/WithResponseStatusException.java similarity index 100% rename from test/test-utils/src/main/java/com/getyourguide/openapi/validation/test/exception/WithResponseStatusException.java rename to test/test-utils/src/testFixtures/java/com/getyourguide/openapi/validation/test/exception/WithResponseStatusException.java diff --git a/test/test-utils/src/main/java/com/getyourguide/openapi/validation/test/exception/WithoutResponseStatusException.java b/test/test-utils/src/testFixtures/java/com/getyourguide/openapi/validation/test/exception/WithoutResponseStatusException.java similarity index 100% rename from test/test-utils/src/main/java/com/getyourguide/openapi/validation/test/exception/WithoutResponseStatusException.java rename to test/test-utils/src/testFixtures/java/com/getyourguide/openapi/validation/test/exception/WithoutResponseStatusException.java