-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Tests to check basic Java Record processing result (#4749)
Implement series of tests in separate module for Java Record support
- Loading branch information
Showing
17 changed files
with
1,079 additions
and
1 deletion.
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
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
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,91 @@ | ||
<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/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>io.swagger.core.v3</groupId> | ||
<artifactId>swagger-project</artifactId> | ||
<version>2.2.26-SNAPSHOT</version> | ||
<relativePath>../../pom.xml</relativePath> | ||
</parent> | ||
<artifactId>swagger-java17-support</artifactId> | ||
<packaging>jar</packaging> | ||
<name>swagger-java17-support</name> | ||
<description>Module for Java 17 specific tests</description> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.swagger.core.v3</groupId> | ||
<artifactId>swagger-jaxrs2</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.swagger.core.v3</groupId> | ||
<artifactId>swagger-core</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.swagger.core.v3</groupId> | ||
<artifactId>swagger-annotations</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.swagger.core.v3</groupId> | ||
<artifactId>swagger-models</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.glassfish.jersey.media</groupId> | ||
<artifactId>jersey-media-multipart</artifactId> | ||
<version>${jersey2-version}</version> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>javax.annotation</groupId> | ||
<artifactId>javax.annotation-api</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>org.javassist</groupId> | ||
<artifactId>javassist</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.glassfish.jersey.inject</groupId> | ||
<artifactId>jersey-hk2</artifactId> | ||
<version>${jersey2-version}</version> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>javax.annotation</groupId> | ||
<artifactId>javax.annotation-api</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>org.javassist</groupId> | ||
<artifactId>javassist</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.11.0</version> | ||
<configuration> | ||
<release>17</release> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<properties> | ||
<maven.compiler.release>17</maven.compiler.release> | ||
</properties> | ||
|
||
</project> |
108 changes: 108 additions & 0 deletions
108
modules/swagger-java17-support/src/test/java/io/swagger/v3/java17/Reader/ReaderTest.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,108 @@ | ||
package io.swagger.v3.java17.Reader; | ||
|
||
import io.swagger.v3.java17.matchers.SerializationMatchers; | ||
import io.swagger.v3.java17.resources.JavaRecordWithPathResource; | ||
import io.swagger.v3.java17.resources.OtherJavaRecordWithPathsResource; | ||
import io.swagger.v3.java17.resources.TestControllerWithRecordResource; | ||
import io.swagger.v3.jaxrs2.Reader; | ||
import io.swagger.v3.oas.integration.SwaggerConfiguration; | ||
import io.swagger.v3.oas.models.OpenAPI; | ||
import org.testng.annotations.Test; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class ReaderTest { | ||
|
||
@Test | ||
public void TestJavaRecordRef(){ | ||
Reader reader = new Reader(new SwaggerConfiguration().openAPI(new OpenAPI()).openAPI31(true)); | ||
|
||
OpenAPI openAPI = reader.read(TestControllerWithRecordResource.class); | ||
String yaml = "openapi: 3.1.0\n" + | ||
"paths:\n" + | ||
" /v17:\n" + | ||
" post:\n" + | ||
" operationId: opsRecordID\n" + | ||
" responses:\n" + | ||
" default:\n" + | ||
" description: Successful operation\n" + | ||
" content:\n" + | ||
" application/json:\n" + | ||
" schema:\n" + | ||
" $ref: '#/components/schemas/JavaRecordResource'\n" + | ||
"components:\n" + | ||
" schemas:\n" + | ||
" JavaRecordResource:\n" + | ||
" type: object\n" + | ||
" properties:\n" + | ||
" test:\n" + | ||
" type: string\n" + | ||
" description: Testing of Java Record Processing\n" + | ||
" isLatest:\n" + | ||
" type: boolean\n" + | ||
" id:\n" + | ||
" type: string\n" + | ||
" age:\n" + | ||
" type: integer\n" + | ||
" format: int32"; | ||
SerializationMatchers.assertEqualsToYaml31(openAPI, yaml); | ||
} | ||
|
||
@Test | ||
public void TestSetOfRecords(){ | ||
Set<Class<?>> classes = new HashSet<>(); | ||
classes.add(JavaRecordWithPathResource.class); | ||
classes.add(OtherJavaRecordWithPathsResource.class); | ||
|
||
Reader reader = new Reader(new OpenAPI()); | ||
OpenAPI openAPI = reader.read(classes); | ||
String yaml = "openapi: 3.0.1\n" + | ||
"paths:\n" + | ||
" /sample/1:\n" + | ||
" post:\n" + | ||
" description: description 1\n" + | ||
" operationId: id 1\n" + | ||
" responses:\n" + | ||
" default:\n" + | ||
" description: default response\n" + | ||
" content:\n" + | ||
" '*/*': {}\n" + | ||
" /sample/2:\n" + | ||
" post:\n" + | ||
" description: description 2\n" + | ||
" operationId: id 2\n" + | ||
" responses:\n" + | ||
" default:\n" + | ||
" description: default response\n" + | ||
" content:\n" + | ||
" '*/*': {}\n" + | ||
" /sample2:\n" + | ||
" get:\n" + | ||
" description: description\n" + | ||
" operationId: Operation Id\n" + | ||
" responses:\n" + | ||
" default:\n" + | ||
" description: default response\n" + | ||
" content:\n" + | ||
" '*/*': {}\n" + | ||
" security:\n" + | ||
" - security_key:\n" + | ||
" - write:pets\n" + | ||
" - read:pets\n" + | ||
" /sample2/2:\n" + | ||
" get:\n" + | ||
" description: description 2\n" + | ||
" operationId: Operation Id 2\n" + | ||
" responses:\n" + | ||
" default:\n" + | ||
" description: default response\n" + | ||
" content:\n" + | ||
" '*/*': {}\n" + | ||
" security:\n" + | ||
" - security_key2:\n" + | ||
" - write:pets\n" + | ||
" - read:pets"; | ||
SerializationMatchers.assertEqualsToYaml(openAPI, yaml); | ||
} | ||
} |
Oops, something went wrong.