Skip to content

Commit

Permalink
Merge pull request #20816 from glefloch/fix/add-annotation-processor-…
Browse files Browse the repository at this point in the history
…test

Add gradle integration test leveraging annotation processor
  • Loading branch information
aloubyansky authored Oct 19, 2021
2 parents b389005 + c0dc456 commit 91b0666
Show file tree
Hide file tree
Showing 24 changed files with 479 additions and 0 deletions.
4 changes: 4 additions & 0 deletions integration-tests/gradle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
<name>Quarkus - Integration Tests - Gradle tooling</name>
<description>Quarkus - Integration Tests - Gradle tooling</description>

<properties>
<mapstruct.version>1.4.2.Final</mapstruct.version>
</properties>

<dependencies>
<!-- All the following dependencies shall enforce the right build order
and proper upstream/downstream detection for incremental build.
Expand Down
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'
}
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);
}
}
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"));
}
}
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}")

}
}
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}"
}
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);

}
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;
}
}
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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
quarkusPlatformArtifactId=quarkus-bom
quarkusPlatformGroupId=io.quarkus

mapstructVersion=${mapstruct.version}
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'

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}")

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
quarkusPlatformArtifactId=quarkus-bom
quarkusPlatformGroupId=io.quarkus

mapstructVersion=${mapstruct.version}
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'

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);

}
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;
}
}
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;
}
}
Loading

0 comments on commit 91b0666

Please sign in to comment.