Skip to content

Commit 6efe4a5

Browse files
committed
add integration tests
1 parent 8db2d2b commit 6efe4a5

File tree

7 files changed

+1470
-9
lines changed

7 files changed

+1470
-9
lines changed

server/deployment/src/main/java/io/quarkiverse/openapi/server/generator/deployment/codegen/ApicurioCodegenWrapper.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import org.apache.commons.io.IOUtils;
2020
import org.eclipse.microprofile.config.Config;
21-
import org.jsonschema2pojo.DefaultGenerationConfig;
2221
import org.slf4j.Logger;
2322
import org.slf4j.LoggerFactory;
2423

@@ -67,14 +66,7 @@ public void generate(Path openApiResource) throws CodeGenException {
6766
FileInputStream openApiStream = new FileInputStream(openApiFile)) {
6867
OpenApi2JaxRs generator = new OpenApi2JaxRs() {
6968
{
70-
config = new DefaultGenerationConfig() {
71-
@Override
72-
public boolean isGenerateBuilders() {
73-
Boolean generateBuildersValue = getGenerateBuildersValue();
74-
log.debug("Generate Builders={}", generateBuildersValue);
75-
return generateBuildersValue;
76-
}
77-
};
69+
config = new ConfigurableGenerationConfig(ApicurioCodegenWrapper.this.config);
7870
}
7971
};
8072
generator.setSettings(projectSettings);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package io.quarkiverse.openapi.server.generator.deployment.codegen;
2+
3+
import org.eclipse.microprofile.config.Config;
4+
import org.jsonschema2pojo.DefaultGenerationConfig;
5+
import org.slf4j.Logger;
6+
import org.slf4j.LoggerFactory;
7+
8+
public class ConfigurableGenerationConfig extends DefaultGenerationConfig {
9+
10+
private static final Logger log = LoggerFactory.getLogger(ConfigurableGenerationConfig.class);
11+
12+
private final boolean generateBuilders;
13+
14+
public ConfigurableGenerationConfig(Config config) {
15+
generateBuilders = config
16+
.getOptionalValue("quarkus.openapi.generator.options.generate-builders", Boolean.class)
17+
.orElse(Boolean.FALSE);
18+
log.info("generateBuilders={}", generateBuilders);
19+
}
20+
21+
@Override
22+
public boolean isGenerateBuilders() {
23+
return generateBuilders;
24+
}
25+
26+
}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<parent>
4+
<artifactId>quarkus-openapi-generator-server-integration-tests-parent</artifactId>
5+
<groupId>io.quarkiverse.openapi.generator</groupId>
6+
<version>3.0.0-SNAPSHOT</version>
7+
<relativePath>../pom.xml</relativePath>
8+
</parent>
9+
<modelVersion>4.0.0</modelVersion>
10+
11+
<artifactId>quarkus-openapi-generator-server-integration-tests-resteasy</artifactId>
12+
<name>Quarkus - OpenAPI Generator - Server - Integration Tests - Resteasy</name>
13+
14+
<dependencies>
15+
<dependency>
16+
<groupId>io.quarkus</groupId>
17+
<artifactId>quarkus-undertow</artifactId>
18+
</dependency>
19+
<dependency>
20+
<groupId>io.quarkus</groupId>
21+
<artifactId>quarkus-resteasy</artifactId>
22+
</dependency>
23+
<dependency>
24+
<groupId>io.quarkus</groupId>
25+
<artifactId>quarkus-resteasy-jackson</artifactId>
26+
</dependency>
27+
<dependency>
28+
<groupId>io.quarkiverse.openapi.generator</groupId>
29+
<artifactId>quarkus-openapi-generator-server</artifactId>
30+
</dependency>
31+
<dependency>
32+
<groupId>io.quarkus</groupId>
33+
<artifactId>quarkus-junit5</artifactId>
34+
<scope>test</scope>
35+
</dependency>
36+
<dependency>
37+
<groupId>io.quarkus</groupId>
38+
<artifactId>quarkus-test-common</artifactId>
39+
<scope>test</scope>
40+
</dependency>
41+
<dependency>
42+
<groupId>org.junit.jupiter</groupId>
43+
<artifactId>junit-jupiter</artifactId>
44+
<scope>test</scope>
45+
</dependency>
46+
<dependency>
47+
<groupId>io.rest-assured</groupId>
48+
<artifactId>rest-assured</artifactId>
49+
<scope>test</scope>
50+
</dependency>
51+
<dependency>
52+
<groupId>io.quarkus</groupId>
53+
<artifactId>quarkus-smallrye-openapi</artifactId>
54+
</dependency>
55+
</dependencies>
56+
57+
<build>
58+
<pluginManagement>
59+
<plugins>
60+
<plugin>
61+
<groupId>io.quarkus</groupId>
62+
<artifactId>quarkus-maven-plugin</artifactId>
63+
<version>${quarkus.version}</version>
64+
</plugin>
65+
<plugin>
66+
<artifactId>maven-surefire-plugin</artifactId>
67+
<version>${version.surefire.plugin}</version>
68+
<configuration>
69+
<systemPropertyVariables>
70+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
71+
<maven.home>${maven.home}</maven.home>
72+
<maven.repo>${settings.localRepository}</maven.repo>
73+
</systemPropertyVariables>
74+
</configuration>
75+
</plugin>
76+
<plugin>
77+
<artifactId>maven-failsafe-plugin</artifactId>
78+
<version>${failsafe-plugin.version}</version>
79+
<configuration>
80+
<systemPropertyVariables>
81+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
82+
<maven.home>${maven.home}</maven.home>
83+
<maven.repo>${settings.localRepository}</maven.repo>
84+
</systemPropertyVariables>
85+
</configuration>
86+
</plugin>
87+
<plugin>
88+
<artifactId>maven-compiler-plugin</artifactId>
89+
<version>${compiler-plugin.version}</version>
90+
<configuration>
91+
<compilerArgs>
92+
<arg>-parameters</arg>
93+
</compilerArgs>
94+
</configuration>
95+
</plugin>
96+
</plugins>
97+
</pluginManagement>
98+
<plugins>
99+
<plugin>
100+
<groupId>io.quarkus</groupId>
101+
<artifactId>quarkus-maven-plugin</artifactId>
102+
<executions>
103+
<execution>
104+
<goals>
105+
<goal>build</goal>
106+
<goal>generate-code</goal>
107+
</goals>
108+
</execution>
109+
</executions>
110+
</plugin>
111+
</plugins>
112+
</build>
113+
</project>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package io.petstore;
2+
3+
import java.io.InputStream;
4+
import java.util.HashMap;
5+
import java.util.List;
6+
import java.util.Map;
7+
8+
import io.petstore.beans.ApiResponse;
9+
import io.petstore.beans.Pet;
10+
11+
public class PetStoreImpl implements PetResource {
12+
13+
private static final Map<Long, Pet> PETS = new HashMap<>();
14+
15+
@Override
16+
public Pet updatePet(Pet data) {
17+
return PETS.put(data.getId(), data);
18+
}
19+
20+
@Override
21+
public Pet addPet(Pet data) {
22+
return PETS.put(data.getId(), data);
23+
}
24+
25+
@Override
26+
public List<Pet> findPetsByStatus(String status) {
27+
return null;
28+
}
29+
30+
@Override
31+
public List<Pet> findPetsByTags(List<String> tags) {
32+
return null;
33+
}
34+
35+
@Override
36+
public Pet getPetById(long petId) {
37+
return PETS.get(petId);
38+
}
39+
40+
@Override
41+
public void updatePetWithForm(long petId, String name, String status) {
42+
43+
}
44+
45+
@Override
46+
public void deletePet(String apiKey, long petId) {
47+
PETS.remove(petId);
48+
}
49+
50+
@Override
51+
public ApiResponse uploadFile(long petId, String additionalMetadata, InputStream data) {
52+
return null;
53+
}
54+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Codegen properties
2+
quarkus.openapi.generator.spec=petstore-openapi.json
3+
quarkus.openapi.generator.base-package=io.petstore
4+
quarkus.openapi.generator.reactive=false

0 commit comments

Comments
 (0)