|
1 | | -apply plugin: FtgoOpenApiCodeGenPlugin |
2 | | - |
3 | | -/* |
4 | 1 | plugins { |
5 | | - id 'org.hidetake.swagger.generator' version '2.18.1' |
| 2 | + id 'java' |
6 | 3 | } |
7 | | -*/ |
8 | 4 |
|
9 | | -apply plugin: 'docker-compose' |
| 5 | +java { |
| 6 | + toolchain { |
| 7 | + languageVersion = JavaLanguageVersion.of(17) |
| 8 | + } |
| 9 | +} |
10 | 10 |
|
11 | | -dependencies { |
12 | | - swaggerCodegen 'org.openapitools:openapi-generator-cli:3.3.4' // or OpenAPI Generator |
| 11 | +repositories { |
| 12 | + mavenCentral() |
| 13 | + maven { url eventuateMavenRepoUrl } |
13 | 14 | } |
14 | 15 |
|
15 | | -swaggerSources { |
16 | | - consumerService { |
17 | | - inputFile = file("${ftgoApiSpecsDir}/ftgo-consumer-service-swagger.json") |
18 | | - code { |
19 | | - language = 'java' |
20 | | - configFile = file('swagger-codegen-config/consumer-service.json') |
21 | | - components = ['models'] |
22 | | - // Supports additionalProperties: https://github.com/swagger-api/swagger-codegen#to-generate-a-sample-client-library |
23 | | - } |
24 | | - } |
25 | | - restaurantService { |
26 | | - inputFile = file("${ftgoApiSpecsDir}/ftgo-restaurant-service-api-spec/web/ftgo-restaurant-service-swagger.json") |
27 | | - code { |
28 | | - language = 'java' |
29 | | - configFile = file('swagger-codegen-config/restaurant-service.json') |
30 | | - components = ['models'] |
| 16 | +sourceSets { |
| 17 | + endToEndTest { |
| 18 | + java { |
| 19 | + srcDir 'src/endToEndTest/java' |
| 20 | + } |
| 21 | + resources { |
| 22 | + srcDir 'src/endToEndTest/resources' |
| 23 | + } |
| 24 | + compileClasspath += sourceSets.main.output |
| 25 | + runtimeClasspath += sourceSets.main.output |
31 | 26 | } |
32 | | - } |
| 27 | +} |
| 28 | + |
| 29 | +configurations { |
| 30 | + endToEndTestImplementation.extendsFrom implementation |
| 31 | + endToEndTestRuntimeOnly.extendsFrom runtimeOnly |
33 | 32 | } |
34 | 33 |
|
35 | 34 | dependencies { |
36 | | - ftgoApiSpecification project(":ftgo-consumer-service-api-spec") |
37 | | - ftgoApiSpecification project(":ftgo-restaurant-service-api-spec") |
| 35 | + // Eventuate Platform BOM |
| 36 | + endToEndTestImplementation platform("io.eventuate.platform:eventuate-platform-dependencies:$eventuatePlatformVersion") |
| 37 | + |
| 38 | + // Test Framework - JUnit 5 |
| 39 | + endToEndTestImplementation 'org.junit.jupiter:junit-jupiter:5.10.0' |
| 40 | + endToEndTestRuntimeOnly 'org.junit.platform:junit-platform-launcher' |
| 41 | + |
| 42 | + // REST Assured for API Testing (modern groupId) |
| 43 | + endToEndTestImplementation 'io.rest-assured:rest-assured:5.4.0' |
| 44 | + |
| 45 | + // Testcontainers |
| 46 | + endToEndTestImplementation "org.testcontainers:testcontainers:$testContainersVersion" |
| 47 | + endToEndTestImplementation "org.testcontainers:junit-jupiter:$testContainersVersion" |
| 48 | + |
| 49 | + // Eventuate Testcontainers support |
| 50 | + endToEndTestImplementation 'io.eventuate.common:eventuate-common-testcontainers' |
| 51 | + endToEndTestImplementation 'io.eventuate.messaging.kafka:eventuate-messaging-kafka-testcontainers' |
| 52 | + endToEndTestImplementation 'io.eventuate.cdc:eventuate-cdc-testcontainers' |
| 53 | + endToEndTestImplementation "io.eventuate.platform.testcontainer.support:eventuate-platform-testcontainer-support-service:$eventuatePlatformTestContainerSupportVersion" |
| 54 | + |
| 55 | + // Eventuate JSON mapper for object mapping |
| 56 | + endToEndTestImplementation 'io.eventuate.common:eventuate-common-json-mapper' |
38 | 57 |
|
39 | | - compile project(":ftgo-accounting-service-api") |
40 | | - compile project(":ftgo-consumer-service-api") |
41 | | - compile project(":ftgo-kitchen-service-api") |
42 | | - compile project(":ftgo-restaurant-service-api") |
43 | | - compile project(":ftgo-order-service-api") |
44 | | - compile project(":ftgo-delivery-service-api") |
| 58 | + // Spring Core for ClassUtils (used in ApplicationUnderTest factory) |
| 59 | + endToEndTestImplementation "org.springframework:spring-core:6.2.1" |
45 | 60 |
|
46 | | - compile "io.eventuate.util:eventuate-util-test" |
| 61 | + // Awaitility for polling/waiting (replaces Eventuate Eventually) |
| 62 | + endToEndTestImplementation 'org.awaitility:awaitility:4.2.0' |
47 | 63 |
|
48 | | - compile 'io.swagger:swagger-annotations:1.5.24' |
| 64 | + // Assertions |
| 65 | + endToEndTestImplementation 'org.assertj:assertj-core:3.24.2' |
49 | 66 |
|
50 | | - testCompile "org.springframework.boot:spring-boot-starter-test:$springBootVersion" |
51 | | - testCompile "com.jayway.restassured:rest-assured:$restAssuredVersion" |
52 | | - testCompile "com.jayway.jsonpath:json-path:2.3.0" |
53 | | - testCompile project(":ftgo-test-util") |
| 67 | + // Logging |
| 68 | + endToEndTestImplementation 'org.slf4j:slf4j-api:2.0.9' |
| 69 | + endToEndTestImplementation 'ch.qos.logback:logback-classic:1.4.14' |
54 | 70 |
|
| 71 | + // JSON Processing |
| 72 | + endToEndTestImplementation 'com.fasterxml.jackson.core:jackson-databind' |
| 73 | + endToEndTestImplementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310' |
55 | 74 |
|
| 75 | + // Main dependencies (for shared DTOs if any) |
| 76 | + implementation 'com.fasterxml.jackson.core:jackson-databind' |
56 | 77 | } |
57 | 78 |
|
58 | | -dockerCompose { |
59 | | - environment.put "EVENTUATE_COMMON_VERSION", eventuateCommonImageVersion |
60 | | - environment.put "EVENTUATE_CDC_VERSION", eventuateCdcImageVersion |
61 | | - environment.put "EVENTUATE_SAGA_VERSION", eventuateTramSagasImageVersion |
62 | | - environment.put "EVENTUATE_JAVA_BASE_IMAGE_VERSION", eventuateExamplesBaseImageVersion |
63 | | - environment.put "EVENTUATE_MESSAGING_KAFKA_IMAGE_VERSION", eventuateMessagingKafkaImageVersion |
| 79 | +task endToEndTest(type: Test) { |
| 80 | + description = 'Runs end-to-end tests' |
| 81 | + group = 'verification' |
64 | 82 |
|
65 | | - projectName = null |
| 83 | + testClassesDirs = sourceSets.endToEndTest.output.classesDirs |
| 84 | + classpath = sourceSets.endToEndTest.runtimeClasspath |
| 85 | + |
| 86 | + useJUnitPlatform() |
| 87 | + |
| 88 | + testLogging { |
| 89 | + events "passed", "skipped", "failed" |
| 90 | + exceptionFormat "full" |
| 91 | + } |
| 92 | + |
| 93 | + // Increase heap size for Testcontainers |
| 94 | + maxHeapSize = '2g' |
| 95 | + jvmArgs '-XX:MaxMetaspaceSize=512m' |
| 96 | + |
| 97 | + // Fork a new JVM for each test class |
| 98 | + forkEvery = 1 |
| 99 | + |
| 100 | + // Pass system properties |
| 101 | + if (project.hasProperty('endToEndTestMode')) |
| 102 | + systemProperty "endToEndTestMode", endToEndTestMode |
66 | 103 | } |
67 | 104 |
|
68 | | -test.dependsOn(composeUp) |
| 105 | +check.dependsOn endToEndTest |
| 106 | + |
| 107 | +// Docker Compose mode support |
| 108 | +task dockerComposeUp(type: Exec) { |
| 109 | + description = 'Starts all services using docker compose' |
| 110 | + group = 'application' |
| 111 | + |
| 112 | + workingDir = '../' |
| 113 | + commandLine 'docker', 'compose', 'up', '-d', '--wait' |
| 114 | +} |
| 115 | + |
| 116 | +if (project.hasProperty('endToEndTestMode') && endToEndTestMode == 'DockerCompose') { |
| 117 | + endToEndTest.dependsOn dockerComposeUp |
| 118 | +} |
0 commit comments