-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20816 from glefloch/fix/add-annotation-processor-…
…test Add gradle integration test leveraging annotation processor
- Loading branch information
Showing
24 changed files
with
479 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...ests/gradle/src/main/resources/annotation-processor-multi-module/application/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
plugins { | ||
id 'io.quarkus' | ||
} | ||
|
||
dependencies { | ||
implementation project(":common") | ||
implementation 'io.quarkus:quarkus-resteasy-jackson' | ||
} |
27 changes: 27 additions & 0 deletions
27
...ocessor-multi-module/application/src/main/java/org/acme/quarkus/sample/HelloResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.acme.quarkus.sample; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import org.acme.common.CarMapper; | ||
import org.acme.common.domain.Car; | ||
import org.acme.common.domain.CarDTO; | ||
|
||
@Path("/hello") | ||
public class HelloResource { | ||
|
||
private final CarMapper carMapper; | ||
|
||
public HelloResource(CarMapper carMapper) { | ||
this.carMapper = carMapper; | ||
} | ||
|
||
@GET | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public CarDTO hello() { | ||
Car car = new Car("foo", 4); | ||
return carMapper.carToCarDTO(car); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...sor-multi-module/application/src/test/java/org/acme/quarkus/sample/HelloResourceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.acme.quarkus.sample; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.hamcrest.CoreMatchers.containsString; | ||
|
||
@QuarkusTest | ||
public class HelloResourceTest { | ||
|
||
@Test | ||
public void testHelloEndpoint() { | ||
given() | ||
.when().get("/hello") | ||
.then() | ||
.statusCode(200) | ||
.body(containsString("seatNumber")); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
integration-tests/gradle/src/main/resources/annotation-processor-multi-module/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
buildscript { | ||
repositories { | ||
if (System.properties.containsKey('maven.repo.local')) { | ||
maven { | ||
url System.properties.get('maven.repo.local') | ||
} | ||
} else { | ||
mavenLocal() | ||
} | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} | ||
} | ||
|
||
apply plugin: 'java' | ||
|
||
group = 'com.quarkus.demo' | ||
version = '1.0' | ||
|
||
|
||
subprojects { | ||
|
||
apply plugin: 'java' | ||
|
||
test { | ||
dependsOn 'cleanTest' | ||
useJUnitPlatform() | ||
forkEvery 1 | ||
} | ||
|
||
repositories { | ||
if (System.properties.containsKey('maven.repo.local')) { | ||
maven { | ||
url System.properties.get('maven.repo.local') | ||
} | ||
} else { | ||
mavenLocal() | ||
} | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
|
||
implementation 'io.quarkus:quarkus-resteasy' | ||
|
||
testImplementation 'io.quarkus:quarkus-junit5' | ||
testImplementation 'io.rest-assured:rest-assured' | ||
|
||
implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}") | ||
|
||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...ion-tests/gradle/src/main/resources/annotation-processor-multi-module/common/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
plugins { | ||
id 'java-library' | ||
} | ||
|
||
dependencies { | ||
implementation "org.mapstruct:mapstruct:${mapstructVersion}" | ||
|
||
annotationProcessor "org.mapstruct:mapstruct-processor:${mapstructVersion}" | ||
} |
15 changes: 15 additions & 0 deletions
15
...ces/annotation-processor-multi-module/common/src/main/java/org/acme/common/CarMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.acme.common; | ||
|
||
import org.acme.common.domain.Car; | ||
import org.acme.common.domain.CarDTO; | ||
import org.mapstruct.InjectionStrategy; | ||
import org.mapstruct.Mapper; | ||
import org.mapstruct.Mapping; | ||
|
||
@Mapper(componentModel = "cdi", injectionStrategy = InjectionStrategy.CONSTRUCTOR) | ||
public interface CarMapper { | ||
|
||
@Mapping(source = "numberOfSeats", target = "seatNumber") | ||
CarDTO carToCarDTO(Car car); | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
...es/annotation-processor-multi-module/common/src/main/java/org/acme/common/domain/Car.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.acme.common.domain; | ||
|
||
public class Car { | ||
private String type; | ||
private Integer numberOfSeats; | ||
|
||
public Car() { | ||
} | ||
|
||
public Car(String type, Integer numberOfSeats) { | ||
this.type = type; | ||
this.numberOfSeats = numberOfSeats; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public void setType(String type) { | ||
this.type = type; | ||
} | ||
|
||
public Integer getNumberOfSeats() { | ||
return numberOfSeats; | ||
} | ||
|
||
public void setNumberOfSeats(Integer numberOfSeats) { | ||
this.numberOfSeats = numberOfSeats; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...annotation-processor-multi-module/common/src/main/java/org/acme/common/domain/CarDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.acme.common.domain; | ||
|
||
public class CarDTO { | ||
private String type; | ||
private Integer seatNumber; | ||
|
||
public CarDTO() { | ||
} | ||
|
||
public CarDTO(String type, Integer seatNumber) { | ||
this.type = type; | ||
this.seatNumber = seatNumber; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public void setType(String type) { | ||
this.type = type; | ||
} | ||
|
||
public Integer getSeatNumber() { | ||
return seatNumber; | ||
} | ||
|
||
public void setSeatNumber(Integer seatNumber) { | ||
this.seatNumber = seatNumber; | ||
} | ||
} |
Empty file.
4 changes: 4 additions & 0 deletions
4
...ation-tests/gradle/src/main/resources/annotation-processor-multi-module/gradle.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
quarkusPlatformArtifactId=quarkus-bom | ||
quarkusPlatformGroupId=io.quarkus | ||
|
||
mapstructVersion=${mapstruct.version} |
23 changes: 23 additions & 0 deletions
23
...gration-tests/gradle/src/main/resources/annotation-processor-multi-module/settings.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
pluginManagement { | ||
repositories { | ||
if (System.properties.containsKey('maven.repo.local')) { | ||
maven { | ||
url System.properties.get('maven.repo.local') | ||
} | ||
} else { | ||
mavenLocal() | ||
} | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} | ||
//noinspection GroovyAssignabilityCheck | ||
plugins { | ||
id 'io.quarkus' version "${quarkusPluginVersion}" | ||
} | ||
} | ||
|
||
rootProject.name = 'quarkus-annotation-processor-multi-module-build' | ||
|
||
include ':common' | ||
include ':application' | ||
|
40 changes: 40 additions & 0 deletions
40
integration-tests/gradle/src/main/resources/annotation-processor-simple-module/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
plugins { | ||
id 'java' | ||
id 'io.quarkus' | ||
} | ||
|
||
group = 'com.quarkus.demo' | ||
version = '1.0' | ||
|
||
test { | ||
dependsOn 'cleanTest' | ||
useJUnitPlatform() | ||
forkEvery 1 | ||
} | ||
|
||
repositories { | ||
if (System.properties.containsKey('maven.repo.local')) { | ||
maven { | ||
url System.properties.get('maven.repo.local') | ||
} | ||
} else { | ||
mavenLocal() | ||
} | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
|
||
implementation 'io.quarkus:quarkus-resteasy' | ||
implementation 'io.quarkus:quarkus-resteasy-jackson' | ||
implementation "org.mapstruct:mapstruct:${mapstructVersion}" | ||
|
||
annotationProcessor "org.mapstruct:mapstruct-processor:${mapstructVersion}" | ||
|
||
testImplementation 'io.quarkus:quarkus-junit5' | ||
testImplementation 'io.rest-assured:rest-assured' | ||
|
||
implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}") | ||
|
||
} | ||
|
4 changes: 4 additions & 0 deletions
4
...tion-tests/gradle/src/main/resources/annotation-processor-simple-module/gradle.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
quarkusPlatformArtifactId=quarkus-bom | ||
quarkusPlatformGroupId=io.quarkus | ||
|
||
mapstructVersion=${mapstruct.version} |
23 changes: 23 additions & 0 deletions
23
...ration-tests/gradle/src/main/resources/annotation-processor-simple-module/settings.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
pluginManagement { | ||
repositories { | ||
if (System.properties.containsKey('maven.repo.local')) { | ||
maven { | ||
url System.properties.get('maven.repo.local') | ||
} | ||
} else { | ||
mavenLocal() | ||
} | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} | ||
//noinspection GroovyAssignabilityCheck | ||
plugins { | ||
id 'io.quarkus' version "${quarkusPluginVersion}" | ||
} | ||
} | ||
|
||
rootProject.name = 'quarkus-annotation-processor-multi-module-build' | ||
|
||
include ':common' | ||
include ':application' | ||
|
15 changes: 15 additions & 0 deletions
15
...esources/annotation-processor-simple-module/src/main/java/org/acme/quarkus/CarMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.acme.quarkus; | ||
|
||
import org.acme.quarkus.domain.Car; | ||
import org.acme.quarkus.domain.CarDTO; | ||
import org.mapstruct.InjectionStrategy; | ||
import org.mapstruct.Mapper; | ||
import org.mapstruct.Mapping; | ||
|
||
@Mapper(componentModel = "cdi", injectionStrategy = InjectionStrategy.CONSTRUCTOR) | ||
public interface CarMapper { | ||
|
||
@Mapping(source = "numberOfSeats", target = "seatNumber") | ||
CarDTO carToCarDTO(Car car); | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
...sources/annotation-processor-simple-module/src/main/java/org/acme/quarkus/domain/Car.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.acme.quarkus.domain; | ||
|
||
public class Car { | ||
private String type; | ||
private Integer numberOfSeats; | ||
|
||
public Car() { | ||
} | ||
|
||
public Car(String type, Integer numberOfSeats) { | ||
this.type = type; | ||
this.numberOfSeats = numberOfSeats; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public void setType(String type) { | ||
this.type = type; | ||
} | ||
|
||
public Integer getNumberOfSeats() { | ||
return numberOfSeats; | ||
} | ||
|
||
public void setNumberOfSeats(Integer numberOfSeats) { | ||
this.numberOfSeats = numberOfSeats; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...rces/annotation-processor-simple-module/src/main/java/org/acme/quarkus/domain/CarDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.acme.quarkus.domain; | ||
|
||
public class CarDTO { | ||
private String type; | ||
private Integer seatNumber; | ||
|
||
public CarDTO() { | ||
} | ||
|
||
public CarDTO(String type, Integer seatNumber) { | ||
this.type = type; | ||
this.seatNumber = seatNumber; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public void setType(String type) { | ||
this.type = type; | ||
} | ||
|
||
public Integer getSeatNumber() { | ||
return seatNumber; | ||
} | ||
|
||
public void setSeatNumber(Integer seatNumber) { | ||
this.seatNumber = seatNumber; | ||
} | ||
} |
Oops, something went wrong.