Migrate generated tests for java resttemplate generator updateFeature/resttemplate junit5 (#18222)

* update(resttemplate): migrate java resttemplate templates to junit 5

* update(java defaults): migrate java defaults as well because resttemplate uses model_tests from default

* update(samples, java): update samples as described in the contribution guidelines

* fix tests: try double quotes

* fix tests: remaining double quotes

* update(samples): regenerate resttemplate

* update(samples): regenerate resttemplate-jakarta

* update(samples): regenerate resttemplate-swagger1

* update(samples): regenerate resttemplate-swagger2

* update(samples): regenerate resttemplate-withXml

* update(samples again): ./bin/generate-samples.sh ./bin/configs/*.yaml
This commit is contained in:
timo-a
2024-03-30 14:06:05 +01:00
committed by GitHub
parent 34ebc1c644
commit f73db59b0e
211 changed files with 1984 additions and 7146 deletions

View File

@@ -103,7 +103,7 @@ ext {
spring_web_version = "6.0.17"
jakarta_annotation_version = "2.1.1"
jodatime_version = "2.9.9"
junit_version = "4.13.2"
junit_version = "5.10.2"
}
dependencies {
@@ -117,5 +117,20 @@ dependencies {
implementation "org.openapitools:jackson-databind-nullable:$jackson_databind_nullable_version"
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
testImplementation "junit:junit:$junit_version"
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"
}
test {
// Enable JUnit 5 (Gradle 4.6+).
useJUnitPlatform()
// Always run tests, even when nothing changed.
dependsOn 'cleanTest'
// Show test results.
testLogging {
events "passed", "skipped", "failed"
}
}

View File

@@ -69,6 +69,14 @@
<forkMode>pertest</forkMode>
<useUnlimitedThreads>true</useUnlimitedThreads>
</configuration>
<dependencies>
<!--Custom provider and engine for Junit 5 to surefire-->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
@@ -258,11 +266,17 @@
<!-- test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>${junit-platform-runner.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -271,6 +285,7 @@
<jackson-databind-version>2.15.2</jackson-databind-version>
<jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
<jakarta-annotation-version>2.1.1</jakarta-annotation-version>
<junit-version>4.13.2</junit-version>
<junit-version>5.10.2</junit-version>
<junit-platform-runner.version>1.10.0</junit-platform-runner.version>
</properties>
</project>

View File

@@ -16,8 +16,9 @@ package org.openapitools.client.api;
import java.io.File;
import org.openapitools.client.model.ModelApiResponse;
import org.openapitools.client.model.Pet;
import org.junit.Test;
import org.junit.Ignore;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.web.client.RestClientException;
import java.time.LocalDate;
import java.time.OffsetDateTime;
@@ -29,8 +30,8 @@ import java.util.Map;
/**
* API tests for PetApi
*/
@Ignore
public class PetApiTest {
@Disabled
class PetApiTest {
private final PetApi api = new PetApi();
@@ -40,12 +41,13 @@ public class PetApiTest {
*
*
*
* @throws ApiException
* @throws RestClientException
* if the Api call fails
*/
@Test
public void addPetTest() {
void addPetTest() {
Pet pet = null;
Pet response = api.addPet(pet);
// TODO: test validations
@@ -56,13 +58,14 @@ public class PetApiTest {
*
*
*
* @throws ApiException
* @throws RestClientException
* if the Api call fails
*/
@Test
public void deletePetTest() {
void deletePetTest() {
Long petId = null;
String apiKey = null;
api.deletePet(petId, apiKey);
// TODO: test validations
@@ -73,12 +76,13 @@ public class PetApiTest {
*
* Multiple status values can be provided with comma separated strings
*
* @throws ApiException
* @throws RestClientException
* if the Api call fails
*/
@Test
public void findPetsByStatusTest() {
void findPetsByStatusTest() {
List<String> status = null;
List<Pet> response = api.findPetsByStatus(status);
// TODO: test validations
@@ -89,12 +93,13 @@ public class PetApiTest {
*
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
*
* @throws ApiException
* @throws RestClientException
* if the Api call fails
*/
@Test
public void findPetsByTagsTest() {
void findPetsByTagsTest() {
List<String> tags = null;
List<Pet> response = api.findPetsByTags(tags);
// TODO: test validations
@@ -105,12 +110,13 @@ public class PetApiTest {
*
* Returns a single pet
*
* @throws ApiException
* @throws RestClientException
* if the Api call fails
*/
@Test
public void getPetByIdTest() {
void getPetByIdTest() {
Long petId = null;
Pet response = api.getPetById(petId);
// TODO: test validations
@@ -121,12 +127,13 @@ public class PetApiTest {
*
*
*
* @throws ApiException
* @throws RestClientException
* if the Api call fails
*/
@Test
public void updatePetTest() {
void updatePetTest() {
Pet pet = null;
Pet response = api.updatePet(pet);
// TODO: test validations
@@ -137,14 +144,15 @@ public class PetApiTest {
*
*
*
* @throws ApiException
* @throws RestClientException
* if the Api call fails
*/
@Test
public void updatePetWithFormTest() {
void updatePetWithFormTest() {
Long petId = null;
String name = null;
String status = null;
api.updatePetWithForm(petId, name, status);
// TODO: test validations
@@ -155,14 +163,15 @@ public class PetApiTest {
*
*
*
* @throws ApiException
* @throws RestClientException
* if the Api call fails
*/
@Test
public void uploadFileTest() {
void uploadFileTest() {
Long petId = null;
String additionalMetadata = null;
File _file = null;
ModelApiResponse response = api.uploadFile(petId, additionalMetadata, _file);
// TODO: test validations

View File

@@ -14,8 +14,9 @@
package org.openapitools.client.api;
import org.openapitools.client.model.Order;
import org.junit.Test;
import org.junit.Ignore;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.web.client.RestClientException;
import java.time.LocalDate;
import java.time.OffsetDateTime;
@@ -27,8 +28,8 @@ import java.util.Map;
/**
* API tests for StoreApi
*/
@Ignore
public class StoreApiTest {
@Disabled
class StoreApiTest {
private final StoreApi api = new StoreApi();
@@ -38,12 +39,13 @@ public class StoreApiTest {
*
* For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
*
* @throws ApiException
* @throws RestClientException
* if the Api call fails
*/
@Test
public void deleteOrderTest() {
void deleteOrderTest() {
String orderId = null;
api.deleteOrder(orderId);
// TODO: test validations
@@ -54,11 +56,12 @@ public class StoreApiTest {
*
* Returns a map of status codes to quantities
*
* @throws ApiException
* @throws RestClientException
* if the Api call fails
*/
@Test
public void getInventoryTest() {
void getInventoryTest() {
Map<String, Integer> response = api.getInventory();
// TODO: test validations
@@ -69,12 +72,13 @@ public class StoreApiTest {
*
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generate exceptions
*
* @throws ApiException
* @throws RestClientException
* if the Api call fails
*/
@Test
public void getOrderByIdTest() {
void getOrderByIdTest() {
Long orderId = null;
Order response = api.getOrderById(orderId);
// TODO: test validations
@@ -85,12 +89,13 @@ public class StoreApiTest {
*
*
*
* @throws ApiException
* @throws RestClientException
* if the Api call fails
*/
@Test
public void placeOrderTest() {
void placeOrderTest() {
Order order = null;
Order response = api.placeOrder(order);
// TODO: test validations

View File

@@ -15,8 +15,9 @@ package org.openapitools.client.api;
import java.time.OffsetDateTime;
import org.openapitools.client.model.User;
import org.junit.Test;
import org.junit.Ignore;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.web.client.RestClientException;
import java.time.LocalDate;
import java.time.OffsetDateTime;
@@ -28,8 +29,8 @@ import java.util.Map;
/**
* API tests for UserApi
*/
@Ignore
public class UserApiTest {
@Disabled
class UserApiTest {
private final UserApi api = new UserApi();
@@ -39,12 +40,13 @@ public class UserApiTest {
*
* This can only be done by the logged in user.
*
* @throws ApiException
* @throws RestClientException
* if the Api call fails
*/
@Test
public void createUserTest() {
void createUserTest() {
User user = null;
api.createUser(user);
// TODO: test validations
@@ -55,12 +57,13 @@ public class UserApiTest {
*
*
*
* @throws ApiException
* @throws RestClientException
* if the Api call fails
*/
@Test
public void createUsersWithArrayInputTest() {
void createUsersWithArrayInputTest() {
List<User> user = null;
api.createUsersWithArrayInput(user);
// TODO: test validations
@@ -71,12 +74,13 @@ public class UserApiTest {
*
*
*
* @throws ApiException
* @throws RestClientException
* if the Api call fails
*/
@Test
public void createUsersWithListInputTest() {
void createUsersWithListInputTest() {
List<User> user = null;
api.createUsersWithListInput(user);
// TODO: test validations
@@ -87,12 +91,13 @@ public class UserApiTest {
*
* This can only be done by the logged in user.
*
* @throws ApiException
* @throws RestClientException
* if the Api call fails
*/
@Test
public void deleteUserTest() {
void deleteUserTest() {
String username = null;
api.deleteUser(username);
// TODO: test validations
@@ -103,12 +108,13 @@ public class UserApiTest {
*
*
*
* @throws ApiException
* @throws RestClientException
* if the Api call fails
*/
@Test
public void getUserByNameTest() {
void getUserByNameTest() {
String username = null;
User response = api.getUserByName(username);
// TODO: test validations
@@ -119,13 +125,14 @@ public class UserApiTest {
*
*
*
* @throws ApiException
* @throws RestClientException
* if the Api call fails
*/
@Test
public void loginUserTest() {
void loginUserTest() {
String username = null;
String password = null;
String response = api.loginUser(username, password);
// TODO: test validations
@@ -136,11 +143,12 @@ public class UserApiTest {
*
*
*
* @throws ApiException
* @throws RestClientException
* if the Api call fails
*/
@Test
public void logoutUserTest() {
void logoutUserTest() {
api.logoutUser();
// TODO: test validations
@@ -151,13 +159,14 @@ public class UserApiTest {
*
* This can only be done by the logged in user.
*
* @throws ApiException
* @throws RestClientException
* if the Api call fails
*/
@Test
public void updateUserTest() {
void updateUserTest() {
String username = null;
User user = null;
api.updateUser(username, user);
// TODO: test validations

View File

@@ -18,22 +18,21 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
* Model tests for Category
*/
public class CategoryTest {
class CategoryTest {
private final Category model = new Category();
/**
* Model tests for Category
*/
@Test
public void testCategory() {
void testCategory() {
// TODO: test Category
}
@@ -41,7 +40,7 @@ public class CategoryTest {
* Test the property 'id'
*/
@Test
public void idTest() {
void idTest() {
// TODO: test id
}
@@ -49,7 +48,7 @@ public class CategoryTest {
* Test the property 'name'
*/
@Test
public void nameTest() {
void nameTest() {
// TODO: test name
}

View File

@@ -18,22 +18,21 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
* Model tests for ModelApiResponse
*/
public class ModelApiResponseTest {
class ModelApiResponseTest {
private final ModelApiResponse model = new ModelApiResponse();
/**
* Model tests for ModelApiResponse
*/
@Test
public void testModelApiResponse() {
void testModelApiResponse() {
// TODO: test ModelApiResponse
}
@@ -41,7 +40,7 @@ public class ModelApiResponseTest {
* Test the property 'code'
*/
@Test
public void codeTest() {
void codeTest() {
// TODO: test code
}
@@ -49,7 +48,7 @@ public class ModelApiResponseTest {
* Test the property 'type'
*/
@Test
public void typeTest() {
void typeTest() {
// TODO: test type
}
@@ -57,7 +56,7 @@ public class ModelApiResponseTest {
* Test the property 'message'
*/
@Test
public void messageTest() {
void messageTest() {
// TODO: test message
}

View File

@@ -19,22 +19,21 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import java.time.OffsetDateTime;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
* Model tests for Order
*/
public class OrderTest {
class OrderTest {
private final Order model = new Order();
/**
* Model tests for Order
*/
@Test
public void testOrder() {
void testOrder() {
// TODO: test Order
}
@@ -42,7 +41,7 @@ public class OrderTest {
* Test the property 'id'
*/
@Test
public void idTest() {
void idTest() {
// TODO: test id
}
@@ -50,7 +49,7 @@ public class OrderTest {
* Test the property 'petId'
*/
@Test
public void petIdTest() {
void petIdTest() {
// TODO: test petId
}
@@ -58,7 +57,7 @@ public class OrderTest {
* Test the property 'quantity'
*/
@Test
public void quantityTest() {
void quantityTest() {
// TODO: test quantity
}
@@ -66,7 +65,7 @@ public class OrderTest {
* Test the property 'shipDate'
*/
@Test
public void shipDateTest() {
void shipDateTest() {
// TODO: test shipDate
}
@@ -74,7 +73,7 @@ public class OrderTest {
* Test the property 'status'
*/
@Test
public void statusTest() {
void statusTest() {
// TODO: test status
}
@@ -82,7 +81,7 @@ public class OrderTest {
* Test the property 'complete'
*/
@Test
public void completeTest() {
void completeTest() {
// TODO: test complete
}

View File

@@ -19,25 +19,25 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.openapitools.client.model.Category;
import org.openapitools.client.model.Tag;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
* Model tests for Pet
*/
public class PetTest {
class PetTest {
private final Pet model = new Pet();
/**
* Model tests for Pet
*/
@Test
public void testPet() {
void testPet() {
// TODO: test Pet
}
@@ -45,7 +45,7 @@ public class PetTest {
* Test the property 'id'
*/
@Test
public void idTest() {
void idTest() {
// TODO: test id
}
@@ -53,7 +53,7 @@ public class PetTest {
* Test the property 'category'
*/
@Test
public void categoryTest() {
void categoryTest() {
// TODO: test category
}
@@ -61,7 +61,7 @@ public class PetTest {
* Test the property 'name'
*/
@Test
public void nameTest() {
void nameTest() {
// TODO: test name
}
@@ -69,7 +69,7 @@ public class PetTest {
* Test the property 'photoUrls'
*/
@Test
public void photoUrlsTest() {
void photoUrlsTest() {
// TODO: test photoUrls
}
@@ -77,7 +77,7 @@ public class PetTest {
* Test the property 'tags'
*/
@Test
public void tagsTest() {
void tagsTest() {
// TODO: test tags
}
@@ -85,7 +85,7 @@ public class PetTest {
* Test the property 'status'
*/
@Test
public void statusTest() {
void statusTest() {
// TODO: test status
}

View File

@@ -18,22 +18,21 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
* Model tests for Tag
*/
public class TagTest {
class TagTest {
private final Tag model = new Tag();
/**
* Model tests for Tag
*/
@Test
public void testTag() {
void testTag() {
// TODO: test Tag
}
@@ -41,7 +40,7 @@ public class TagTest {
* Test the property 'id'
*/
@Test
public void idTest() {
void idTest() {
// TODO: test id
}
@@ -49,7 +48,7 @@ public class TagTest {
* Test the property 'name'
*/
@Test
public void nameTest() {
void nameTest() {
// TODO: test name
}

View File

@@ -18,22 +18,21 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
* Model tests for User
*/
public class UserTest {
class UserTest {
private final User model = new User();
/**
* Model tests for User
*/
@Test
public void testUser() {
void testUser() {
// TODO: test User
}
@@ -41,7 +40,7 @@ public class UserTest {
* Test the property 'id'
*/
@Test
public void idTest() {
void idTest() {
// TODO: test id
}
@@ -49,7 +48,7 @@ public class UserTest {
* Test the property 'username'
*/
@Test
public void usernameTest() {
void usernameTest() {
// TODO: test username
}
@@ -57,7 +56,7 @@ public class UserTest {
* Test the property 'firstName'
*/
@Test
public void firstNameTest() {
void firstNameTest() {
// TODO: test firstName
}
@@ -65,7 +64,7 @@ public class UserTest {
* Test the property 'lastName'
*/
@Test
public void lastNameTest() {
void lastNameTest() {
// TODO: test lastName
}
@@ -73,7 +72,7 @@ public class UserTest {
* Test the property 'email'
*/
@Test
public void emailTest() {
void emailTest() {
// TODO: test email
}
@@ -81,7 +80,7 @@ public class UserTest {
* Test the property 'password'
*/
@Test
public void passwordTest() {
void passwordTest() {
// TODO: test password
}
@@ -89,7 +88,7 @@ public class UserTest {
* Test the property 'phone'
*/
@Test
public void phoneTest() {
void phoneTest() {
// TODO: test phone
}
@@ -97,7 +96,7 @@ public class UserTest {
* Test the property 'userStatus'
*/
@Test
public void userStatusTest() {
void userStatusTest() {
// TODO: test userStatus
}