Skip to content

Commit 47f4db8

Browse files
committed
add integration tests
1 parent 201e379 commit 47f4db8

File tree

10 files changed

+400
-10
lines changed

10 files changed

+400
-10
lines changed

pom.xml

Lines changed: 69 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
<maven.compiler.release>8</maven.compiler.release>
4848
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4949
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
50+
51+
<!-- integration testing -->
52+
<maven.version>3.9.6</maven.version>
53+
<maven.home>/Users/hauner/Development/openapi/maven/apache-maven-3.9.6</maven.home>
5054
</properties>
5155

5256
<repositories>
@@ -70,7 +74,7 @@
7074
<!-- needed when injecting the Maven Project into a plugin -->
7175
<groupId>org.apache.maven</groupId>
7276
<artifactId>maven-core</artifactId>
73-
<version>3.8.1</version>
77+
<version>3.6.3</version>
7478
<scope>provided</scope>
7579
</dependency>
7680
<dependency>
@@ -90,29 +94,47 @@
9094
<artifactId>openapi-processor-api</artifactId>
9195
<version>2023.1</version>
9296
</dependency>
97+
<dependency>
98+
<groupId>org.junit.jupiter</groupId>
99+
<artifactId>junit-jupiter-engine</artifactId>
100+
<version>5.10.0</version>
101+
<scope>test</scope>
102+
</dependency>
103+
<dependency>
104+
<groupId>com.soebes.itf.jupiter.extension</groupId>
105+
<artifactId>itf-jupiter-extension</artifactId>
106+
<version>0.13.1</version>
107+
<scope>test</scope>
108+
</dependency>
109+
<dependency>
110+
<groupId>com.soebes.itf.jupiter.extension</groupId>
111+
<artifactId>itf-assertj</artifactId>
112+
<version>0.13.1</version>
113+
<scope>test</scope>
114+
</dependency>
93115
</dependencies>
94116

95117
<build>
96118
<plugins>
97119
<plugin>
98-
<groupId>org.apache.maven.plugins</groupId>
99-
<artifactId>maven-compiler-plugin</artifactId>
100-
<version>3.11.0</version>
120+
<groupId>org.apache.maven.plugins</groupId>
121+
<artifactId>maven-compiler-plugin</artifactId>
122+
<version>3.11.0</version>
101123
</plugin>
102124
<plugin>
103-
<groupId>org.apache.maven.plugins</groupId>
104-
<artifactId>maven-resources-plugin</artifactId>
105-
<version>3.3.1</version>
125+
<groupId>org.apache.maven.plugins</groupId>
126+
<artifactId>maven-resources-plugin</artifactId>
127+
<version>3.3.1</version>
106128
</plugin>
107129
<plugin>
108130
<groupId>org.apache.maven.plugins</groupId>
109131
<artifactId>maven-plugin-plugin</artifactId>
110132
<version>3.10.2</version>
111133
</plugin>
112134
<plugin>
113-
<groupId>org.apache.maven.plugins</groupId>
114-
<artifactId>maven-deploy-plugin</artifactId>
115-
<version>3.1.1</version>
135+
<groupId>org.apache.maven.plugins</groupId>
136+
<artifactId>maven-deploy-plugin</artifactId>
137+
<version>3.1.1</version>
116138
</plugin>
117139
<plugin>
118140
<groupId>org.apache.maven.plugins</groupId>
@@ -155,6 +177,43 @@
155177
</execution>
156178
</executions>
157179
</plugin>
180+
<plugin>
181+
<groupId>com.soebes.itf.jupiter.extension</groupId>
182+
<artifactId>itf-maven-plugin</artifactId>
183+
<version>0.13.1</version>
184+
<executions>
185+
<execution>
186+
<id>installing</id>
187+
<phase>pre-integration-test</phase>
188+
<goals>
189+
<goal>install</goal>
190+
<goal>resources-its</goal>
191+
</goals>
192+
</execution>
193+
</executions>
194+
</plugin>
195+
<plugin>
196+
<groupId>org.apache.maven.plugins</groupId>
197+
<artifactId>maven-failsafe-plugin</artifactId>
198+
<version>3.1.2</version>
199+
<configuration>
200+
<!--
201+
! currently needed to run integration tests.
202+
-->
203+
<systemPropertyVariables>
204+
<maven.version>${maven.version}</maven.version>
205+
<maven.home>${maven.home}</maven.home>
206+
</systemPropertyVariables>
207+
</configuration>
208+
<executions>
209+
<execution>
210+
<goals>
211+
<goal>integration-test</goal>
212+
<goal>verify</goal>
213+
</goals>
214+
</execution>
215+
</executions>
216+
</plugin>
158217
</plugins>
159218
</build>
160219

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright 2020 https://github.com/openapi-processor/openapi-processor-maven
3+
* PDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.openapiprocessor.maven;
7+
8+
import com.soebes.itf.jupiter.extension.MavenGoal;
9+
import com.soebes.itf.jupiter.extension.MavenJupiterExtension;
10+
import com.soebes.itf.jupiter.extension.MavenTest;
11+
import com.soebes.itf.jupiter.maven.MavenExecutionResult;
12+
13+
import java.io.File;
14+
15+
import static com.soebes.itf.extension.assertj.MavenITAssertions.assertThat;
16+
17+
@MavenJupiterExtension
18+
public class MojoIT {
19+
20+
@MavenTest
21+
@MavenGoal("openapi-processor:process")
22+
void writesOutputToExplicitTargetDir(MavenExecutionResult result) {
23+
String targetDir = String.join(File.separator, "target", "generated-sources", "expected-target-dir");
24+
String packageDir = String.join(File.separator, targetDir, "io", "openapiprocessor", "openapi");
25+
String apiPackage = String.join(File.separator, packageDir, "api");
26+
String modelPackage = String.join(File.separator, packageDir, "model");
27+
String supportPackage = String.join(File.separator, packageDir, "support");
28+
29+
assertThat(result)
30+
.isSuccessful()
31+
.project()
32+
.has(targetDir)
33+
.has(packageDir)
34+
.has(apiPackage)
35+
.has(modelPackage)
36+
.has(supportPackage);
37+
38+
assertThat(result)
39+
.out()
40+
.info()
41+
.contains(" apiPath - " + joinDirs("${project.basedir}", "src", "api", "openapi.yaml"))
42+
.contains(" targetDir - " + joinDirs("${project.basedir}", "target", "generated-sources", "expected-target-dir"));
43+
}
44+
45+
@MavenTest
46+
@MavenGoal("openapi-processor:process")
47+
void writesOutputToAutomaticTargetDir(MavenExecutionResult result) {
48+
String targetDir = String.join(File.separator, "target", "generated-sources", "spring");
49+
String packageDir = String.join(File.separator, targetDir, "io", "openapiprocessor", "openapi");
50+
String apiPackage = String.join(File.separator, packageDir, "api");
51+
String modelPackage = String.join(File.separator, packageDir, "model");
52+
String supportPackage = String.join(File.separator, packageDir, "support");
53+
54+
assertThat(result)
55+
.isSuccessful()
56+
.project()
57+
.has(targetDir)
58+
.has(packageDir)
59+
.has(apiPackage)
60+
.has(modelPackage)
61+
.has(supportPackage);
62+
63+
assertThat(result)
64+
.out()
65+
.info()
66+
.contains(" apiPath - " + joinDirs("${project.basedir}", "src", "api", "openapi.yaml"))
67+
.contains(" targetDir - " + joinDirs("${project.basedir}", "target", "generated-sources", "spring"));
68+
}
69+
70+
private String joinDirs (CharSequence... directories) {
71+
return String.join(File.separator, directories);
72+
}
73+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
2+
--add-exports jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
3+
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
4+
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
5+
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
6+
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>io.openapiprocessor.maven</groupId>
7+
<artifactId>test-1</artifactId>
8+
<version>1</version>
9+
<name>test-1</name>
10+
<description>test-1</description>
11+
12+
<pluginRepositories>
13+
<pluginRepository>
14+
<id>openapi-processor-snapshots</id>
15+
<name>openapi-processor-snapshots</name>
16+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
17+
</pluginRepository>
18+
</pluginRepositories>
19+
20+
<properties>
21+
<java.version>11</java.version>
22+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
23+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
24+
</properties>
25+
26+
<dependencies>
27+
</dependencies>
28+
29+
<build>
30+
<plugins>
31+
<plugin>
32+
<groupId>io.openapiprocessor</groupId>
33+
<artifactId>openapi-processor-maven-plugin</artifactId>
34+
<version>@project.version@</version>
35+
36+
<dependencies>
37+
<dependency>
38+
<groupId>io.openapiprocessor</groupId>
39+
<artifactId>openapi-processor-spring</artifactId>
40+
<version>2024.1-SNAPSHOT</version>
41+
</dependency>
42+
</dependencies>
43+
44+
<configuration>
45+
<id>processor-api</id>
46+
<apiPath>${project.basedir}/src/api/openapi.yaml</apiPath>
47+
</configuration>
48+
49+
<executions>
50+
<execution>
51+
<id>default-cli</id>
52+
<phase>generate-sources</phase>
53+
54+
<configuration>
55+
<id>spring</id>
56+
57+
<options>
58+
<values>
59+
<!--
60+
no targetDir => use default
61+
62+
<targetDir>${project.basedir}/target/generated-sources/spring</targetDir>
63+
-->
64+
<mapping>${project.basedir}/src/api/mapping.yaml</mapping>
65+
</values>
66+
</options>
67+
</configuration>
68+
69+
<goals>
70+
<goal>process</goal>
71+
</goals>
72+
</execution>
73+
</executions>
74+
75+
</plugin>
76+
</plugins>
77+
</build>
78+
</project>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
openapi-processor-mapping: v6
2+
3+
options:
4+
package-name: io.openapiprocessor.openapi
5+
javadoc: true
6+
format-code: true
7+
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
openapi: 3.0.3
2+
info:
3+
title: openapi-processor-spring sample api
4+
version: 1.0.0
5+
6+
paths:
7+
/ping:
8+
get:
9+
tags:
10+
- ping
11+
summary: returns a single "pong" string.
12+
description: very simple sample endpoint
13+
responses:
14+
'200':
15+
description: pong
16+
content:
17+
text/plain:
18+
schema:
19+
type: string
20+
21+
/echo:
22+
get:
23+
tags:
24+
- echo
25+
summary: echos the given parameter string.
26+
description: sample endpoint with parameter
27+
parameters:
28+
- name: source
29+
description: query, required, string
30+
in: query
31+
required: true
32+
schema:
33+
type: string
34+
responses:
35+
'200':
36+
description: echo of the source parameter
37+
content:
38+
text/plain:
39+
schema:
40+
type: string
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
2+
--add-exports jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
3+
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
4+
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
5+
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
6+
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED

0 commit comments

Comments
 (0)