Skip to content

Commit

Permalink
[java] update rest-assured, retrofit2, vertx to use junit 5 (OpenAPIT…
Browse files Browse the repository at this point in the history
…ools#19185)

* update rest assured to use junit 5

* regenerate samples

* update junit from 4 to 5 for retrofit2, vertx

* update vertx test template
  • Loading branch information
wing328 authored Jul 18, 2024
1 parent 75cbebd commit 47abf82
Show file tree
Hide file tree
Showing 447 changed files with 4,512 additions and 4,633 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import {{invokerPackage}}.ApiClient;
import {{apiPackage}}.{{classname}};
import io.restassured.builder.RequestSpecBuilder;
import io.restassured.filter.log.ErrorLoggingFilter;
import org.junit.Before;
import org.junit.Test;
import org.junit.Ignore;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import java.time.LocalDate;
import java.time.OffsetDateTime;
Expand All @@ -31,12 +31,12 @@ import static {{invokerPackage}}.{{#gson}}GsonObjectMapper.gson{{/gson}}{{#jacks
/**
* API tests for {{classname}}
*/
@Ignore
@Disabled
public class {{classname}}Test {
private {{classname}} api;

@Before
@BeforeEach
public void createApi() {
api = ApiClient.api(ApiClient.Config.apiConfig().reqSpecSupplier(
() -> new RequestSpecBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,13 @@ ext {
swagger_annotations_version = "2.2.15"
{{/swagger2AnnotationLibrary}}
rest_assured_version = "5.3.2"
junit_version = "4.13.2"
junit_version = "5.10.3"
{{#jackson}}
jackson_version = "2.17.1"
jackson_databind_version = "2.17.1"
{{#openApiNullable}}
jackson_databind_nullable_version = "0.2.6"
{{/openApiNullable}}
jakarta_annotation_version = "1.3.5"
{{/jackson}}
{{#gson}}
gson_version = "2.10.1"
Expand All @@ -121,6 +120,7 @@ ext {
jodatime_version = "2.10.5"
{{/joda}}
okio_version = "3.6.0"
jakarta_annotation_version = "1.3.5"
}

dependencies {
Expand Down Expand Up @@ -163,5 +163,5 @@ dependencies {
implementation "org.hibernate:hibernate-validator:6.0.19.Final"
{{/performBeanValidation}}
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
testImplementation "junit:junit:$junit_version"
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ lazy val root = (project in file(".")).
"org.hibernate" % "hibernate-validator" % "6.0.19.Final" % "compile",
{{/performBeanValidation}}
"jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile",
"junit" % "junit" % "4.13.2" % "test",
"org.junit.jupiter" % "junit-jupiter-api" % "5.10.3" % "test",
"com.novocode" % "junit-interface" % "0.10" % "test"
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@
{{/performBeanValidation}}
<!-- test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
Expand Down Expand Up @@ -366,6 +366,6 @@
<beanvalidation-version>3.0.2</beanvalidation-version>
{{/useBeanValidation}}
<okio-version>3.6.0</okio-version>
<junit-version>4.13.2</junit-version>
<junit-version>5.10.3</junit-version>
</properties>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package {{package}};
import {{invokerPackage}}.ApiClient;
{{#imports}}import {{import}};
{{/imports}}
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import java.time.LocalDate;
import java.time.OffsetDateTime;
Expand All @@ -25,7 +26,7 @@ public class {{classname}}Test {
private {{classname}} api;

@Before
@BeforeEach
public void setup() {
api = new ApiClient().createService({{classname}}.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ ext {
{{/usePlayWS}}
jakarta_annotation_version = "1.3.5"
swagger_annotations_version = "1.5.22"
junit_version = "4.13.2"
junit_version = "5.10.3"
{{#useRxJava2}}
rx_java_version = "2.1.1"
{{/useRxJava2}}
Expand Down Expand Up @@ -162,5 +162,5 @@ dependencies {
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
{{/jackson}}
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
testImplementation "junit:junit:$junit_version"
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ lazy val root = (project in file(".")).
{{/joda}}
"io.gsonfire" % "gson-fire" % "1.9.0" % "compile",
"jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile",
"junit" % "junit" % "4.13.2" % "test",
"org.junit.jupiter" % "junit-jupiter-api" % "5.10.3" % "test",
"com.novocode" % "junit-interface" % "0.11" % "test"
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
Expand Down Expand Up @@ -413,6 +413,6 @@
<beanvalidation-version>3.0.2</beanvalidation-version>
{{/useBeanValidation}}
<oltu-version>1.0.1</oltu-version>
<junit-version>4.13.2</junit-version>
<junit-version>5.10.3</junit-version>
</properties>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ package {{package}};

import {{invokerPackage}}.Configuration;

import org.junit.Test;
import org.junit.Ignore;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;
Expand All @@ -31,24 +30,18 @@ import java.util.Map;
/**
* API tests for {{classname}}
*/
@RunWith(VertxUnitRunner.class)
@Ignore
@Disabled
public class {{classname}}Test {
private {{classname}} api;

@Rule
public RunTestOnContext rule = new RunTestOnContext();

@BeforeClass
@BeforeAll
public void setupApiClient() {
JsonObject config = new JsonObject();
Vertx vertx = rule.vertx();
Configuration.setupDefaultApiClient(vertx, config);
api = new {{classname}}Impl();
}
{{#operations}}{{#operation}}

{{#operations}}
{{#operation}}
/**
* {{summary}}
* {{notes}}
Expand All @@ -66,5 +59,6 @@ public class {{classname}}Test {
async.complete();
});
}
{{/operation}}{{/operations}}
{{/operation}}
{{/operations}}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ext {
jackson_version = "2.17.1"
jackson_databind_version = "2.17.1"
vertx_version = "3.5.2"
junit_version = "4.13.2"
junit_version = "5.10.3"
{{#openApiNullable}}
jackson_databind_nullable_version = "0.2.6"
{{/openApiNullable}}
Expand All @@ -56,6 +56,6 @@ dependencies {
implementation "org.openapitools:jackson-databind-nullable:$jackson_databind_nullable_version"
{{/openApiNullable}}
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
testImplementation "junit:junit:$junit_version"
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
testImplementation "io.vertx:vertx-unit:$vertx_version"
}
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@

<!-- test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
Expand Down Expand Up @@ -315,6 +315,6 @@
{{^useJakartaEe}}
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
{{/useJakartaEe}}
<junit-version>4.13.2</junit-version>
<junit-version>5.10.3</junit-version>
</properties>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ if(hasProperty('target') && target == 'android') {

ext {
rest_assured_version = "5.3.2"
junit_version = "4.13.2"
junit_version = "5.10.3"
jackson_version = "2.17.1"
jackson_databind_version = "2.17.1"
jackson_databind_nullable_version = "0.2.6"
jakarta_annotation_version = "1.3.5"
okio_version = "3.6.0"
jakarta_annotation_version = "1.3.5"
}

dependencies {
Expand All @@ -119,5 +119,5 @@ dependencies {
implementation "jakarta.validation:jakarta.validation-api:3.0.2"
implementation "org.hibernate:hibernate-validator:6.0.19.Final"
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
testImplementation "junit:junit:$junit_version"
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ lazy val root = (project in file(".")).
"jakarta.validation" % "jakarta.validation-api" % "3.0.2" % "compile",
"org.hibernate" % "hibernate-validator" % "6.0.19.Final" % "compile",
"jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile",
"junit" % "junit" % "4.13.2" % "test",
"org.junit.jupiter" % "junit-jupiter-api" % "5.10.3" % "test",
"com.novocode" % "junit-interface" % "0.10" % "test"
)
)
6 changes: 3 additions & 3 deletions samples/client/petstore/java/rest-assured-jackson/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
Expand All @@ -286,6 +286,6 @@
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
<beanvalidation-version>3.0.2</beanvalidation-version>
<okio-version>3.6.0</okio-version>
<junit-version>4.13.2</junit-version>
<junit-version>5.10.3</junit-version>
</properties>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,38 @@
package org.openapitools.client.api;

import org.openapitools.client.model.Client;
import java.util.UUID;
import org.openapitools.client.ApiClient;
import org.openapitools.client.api.AnotherFakeApi;
import io.restassured.builder.RequestSpecBuilder;
import io.restassured.filter.log.ErrorLoggingFilter;
import org.junit.Before;
import org.junit.Test;
import org.junit.Ignore;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import jakarta.validation.constraints.*;
import jakarta.validation.Valid;

import static io.restassured.config.ObjectMapperConfig.objectMapperConfig;
import static io.restassured.config.RestAssuredConfig.config;
import static org.openapitools.client.JacksonObjectMapper.jackson;

/**
* API tests for AnotherFakeApi
*/
@Ignore
@Disabled
public class AnotherFakeApiTest {

private AnotherFakeApi api;

@Before
@BeforeEach
public void createApi() {
api = ApiClient.api(ApiClient.Config.apiConfig().reqSpecSupplier(
() -> new RequestSpecBuilder()
Expand All @@ -52,10 +59,12 @@ public void createApi() {
*/
@Test
public void shouldSee200AfterCall123testSpecialTags() {
String uuidTest = null;
Client body = null;
api.call123testSpecialTags()
.uuidTestHeader(uuidTest)
.body(body).execute(r -> r.prettyPeek());
// TODO: test validations
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,33 @@
import org.openapitools.client.api.FakeApi;
import io.restassured.builder.RequestSpecBuilder;
import io.restassured.filter.log.ErrorLoggingFilter;
import org.junit.Before;
import org.junit.Test;
import org.junit.Ignore;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import jakarta.validation.constraints.*;
import jakarta.validation.Valid;

import static io.restassured.config.ObjectMapperConfig.objectMapperConfig;
import static io.restassured.config.RestAssuredConfig.config;
import static org.openapitools.client.JacksonObjectMapper.jackson;

/**
* API tests for FakeApi
*/
@Ignore
@Disabled
public class FakeApiTest {

private FakeApi api;

@Before
@BeforeEach
public void createApi() {
api = ApiClient.api(ApiClient.Config.apiConfig().reqSpecSupplier(
() -> new RequestSpecBuilder()
Expand Down Expand Up @@ -303,4 +309,4 @@ public void shouldSee200AfterTestQueryParameterCollectionFormat() {
// TODO: test validations
}

}
}
Loading

0 comments on commit 47abf82

Please sign in to comment.