mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-10-13 16:03:43 +00:00
[java-okhttp] Restore integration tests (#16985)
* restore java okhttp tests * update PR template, update sha
This commit is contained in:
parent
482c759a10
commit
5d03c4ac82
3
.github/PULL_REQUEST_TEMPLATE.md
vendored
3
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -16,5 +16,8 @@
|
||||
These must match the expectations made by your contribution.
|
||||
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example `./bin/generate-samples.sh bin/configs/java*`.
|
||||
For Windows users, please run the script in [Git BASH](https://gitforwindows.org/).
|
||||
|
||||
Do **NOT** purge any folders (e.g. tests) when regenerating the samples.
|
||||
|
||||
- [ ] File the PR against the [correct branch](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master` (upcoming 7.1.0 minor release - breaking changes with fallbacks), `8.0.x` (breaking changes without fallbacks)
|
||||
- [ ] If your PR is targeting a particular programming language, @mention the [technical committee](https://github.com/openapitools/openapi-generator/#62---openapi-generator-technical-committee) members, so they are more likely to review the pull request.
|
||||
|
@ -9,3 +9,9 @@
|
||||
# java okhttp gson test files
|
||||
- filename: "samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/ClientTest.java"
|
||||
sha256: db505f7801fef62c13a08a8e9ca1fc4c5c947ab46b46f12943139d353feacf17
|
||||
- filename: "samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/JSONTest.java"
|
||||
sha256: 3371236d615e7fb79ed87d00c9fc486c31c379195a658781ac9440f0e3228d62
|
||||
- filename: "samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/PetApiTest.java"
|
||||
sha256: 0d64cdc11809a7b5b952ccdad2bd91bd0045b3894d6fabf3e368fa0be12b8217
|
||||
- filename: "samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/model/PetTest.java"
|
||||
sha256: a1f8a70bf7b0c382a8def5bacf7b1fb189e687fabb40235aa799001e0597f545
|
||||
|
@ -11,4 +11,4 @@ src/test/java/org/openapitools/client/model/PetTest.java
|
||||
src/test/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnlyTest.java
|
||||
src/test/java/org/openapitools/client/JSONTest.java
|
||||
src/test/java/org/openapitools/client/api/PetApiTest.java
|
||||
|
||||
pom.xml
|
||||
|
@ -105,7 +105,6 @@ gradle/wrapper/gradle-wrapper.jar
|
||||
gradle/wrapper/gradle-wrapper.properties
|
||||
gradlew
|
||||
gradlew.bat
|
||||
pom.xml
|
||||
settings.gradle
|
||||
src/main/AndroidManifest.xml
|
||||
src/main/java/org/openapitools/client/ApiCallback.java
|
||||
|
@ -328,6 +328,13 @@
|
||||
<version>${junit-platform-runner.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>5.7.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
|
@ -0,0 +1,350 @@
|
||||
package org.openapitools.client;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.openapitools.client.auth.*;
|
||||
|
||||
public class ApiClientTest {
|
||||
ApiClient apiClient;
|
||||
JSON json;
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
apiClient = new ApiClient();
|
||||
json = apiClient.getJSON();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsJsonMime() {
|
||||
assertFalse(apiClient.isJsonMime(null));
|
||||
assertFalse(apiClient.isJsonMime(""));
|
||||
assertFalse(apiClient.isJsonMime("text/plain"));
|
||||
assertFalse(apiClient.isJsonMime("application/xml"));
|
||||
assertFalse(apiClient.isJsonMime("application/jsonp"));
|
||||
assertFalse(apiClient.isJsonMime("example/json"));
|
||||
assertFalse(apiClient.isJsonMime("example/foo+bar+jsonx"));
|
||||
assertFalse(apiClient.isJsonMime("example/foo+bar+xjson"));
|
||||
|
||||
assertTrue(apiClient.isJsonMime("application/json"));
|
||||
assertTrue(apiClient.isJsonMime("application/json; charset=UTF8"));
|
||||
assertTrue(apiClient.isJsonMime("APPLICATION/JSON"));
|
||||
|
||||
assertTrue(apiClient.isJsonMime("application/problem+json"));
|
||||
assertTrue(apiClient.isJsonMime("APPLICATION/PROBLEM+JSON"));
|
||||
assertTrue(apiClient.isJsonMime("application/json\t"));
|
||||
assertTrue(apiClient.isJsonMime("example/foo+bar+json"));
|
||||
assertTrue(apiClient.isJsonMime("example/foo+json;x;y"));
|
||||
assertTrue(apiClient.isJsonMime("example/foo+json\t;"));
|
||||
assertTrue(apiClient.isJsonMime("Example/fOO+JSON"));
|
||||
|
||||
assertTrue(apiClient.isJsonMime("application/json-patch+json"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSelectHeaderAccept() {
|
||||
String[] accepts = {"application/json", "application/xml"};
|
||||
assertEquals("application/json", apiClient.selectHeaderAccept(accepts));
|
||||
|
||||
accepts = new String[]{"APPLICATION/XML", "APPLICATION/JSON"};
|
||||
assertEquals("APPLICATION/JSON", apiClient.selectHeaderAccept(accepts));
|
||||
|
||||
accepts = new String[]{"application/xml", "application/json; charset=UTF8"};
|
||||
assertEquals("application/json; charset=UTF8", apiClient.selectHeaderAccept(accepts));
|
||||
|
||||
accepts = new String[]{"text/plain", "application/xml"};
|
||||
assertEquals("text/plain,application/xml", apiClient.selectHeaderAccept(accepts));
|
||||
|
||||
accepts = new String[]{};
|
||||
assertNull(apiClient.selectHeaderAccept(accepts));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSelectHeaderContentType() {
|
||||
String[] contentTypes = {"application/json", "application/xml"};
|
||||
assertEquals("application/json", apiClient.selectHeaderContentType(contentTypes));
|
||||
|
||||
contentTypes = new String[]{"APPLICATION/JSON", "APPLICATION/XML"};
|
||||
assertEquals("APPLICATION/JSON", apiClient.selectHeaderContentType(contentTypes));
|
||||
|
||||
contentTypes = new String[]{"application/xml", "application/json; charset=UTF8"};
|
||||
assertEquals(
|
||||
"application/json; charset=UTF8", apiClient.selectHeaderContentType(contentTypes));
|
||||
|
||||
contentTypes = new String[]{"text/plain", "application/xml"};
|
||||
assertEquals("text/plain", apiClient.selectHeaderContentType(contentTypes));
|
||||
|
||||
contentTypes = new String[]{};
|
||||
assertNull(apiClient.selectHeaderContentType(contentTypes));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAuthentications() {
|
||||
Map<String, Authentication> auths = apiClient.getAuthentications();
|
||||
|
||||
Authentication auth = auths.get("api_key");
|
||||
assertNotNull(auth);
|
||||
assertTrue(auth instanceof ApiKeyAuth);
|
||||
ApiKeyAuth apiKeyAuth = (ApiKeyAuth) auth;
|
||||
assertEquals("header", apiKeyAuth.getLocation());
|
||||
assertEquals("api_key", apiKeyAuth.getParamName());
|
||||
|
||||
auth = auths.get("petstore_auth");
|
||||
assertTrue(auth instanceof OAuth);
|
||||
assertSame(auth, apiClient.getAuthentication("petstore_auth"));
|
||||
|
||||
assertNull(auths.get("unknown"));
|
||||
|
||||
try {
|
||||
auths.put("my_auth", new HttpBasicAuth());
|
||||
fail("the authentications returned should not be modifiable");
|
||||
} catch (UnsupportedOperationException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void testSetUsernameAndPassword() {
|
||||
HttpBasicAuth auth = null;
|
||||
for (Authentication _auth : apiClient.getAuthentications().values()) {
|
||||
if (_auth instanceof HttpBasicAuth) {
|
||||
auth = (HttpBasicAuth) _auth;
|
||||
break;
|
||||
}
|
||||
}
|
||||
auth.setUsername(null);
|
||||
auth.setPassword(null);
|
||||
|
||||
apiClient.setUsername("my-username");
|
||||
apiClient.setPassword("my-password");
|
||||
assertEquals("my-username", auth.getUsername());
|
||||
assertEquals("my-password", auth.getPassword());
|
||||
|
||||
// reset values
|
||||
auth.setUsername(null);
|
||||
auth.setPassword(null);
|
||||
}
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void testSetApiKeyAndPrefix() {
|
||||
ApiKeyAuth auth = null;
|
||||
for (Authentication _auth : apiClient.getAuthentications().values()) {
|
||||
if (_auth instanceof ApiKeyAuth) {
|
||||
auth = (ApiKeyAuth) _auth;
|
||||
break;
|
||||
}
|
||||
}
|
||||
auth.setApiKey(null);
|
||||
auth.setApiKeyPrefix(null);
|
||||
|
||||
apiClient.setApiKey("my-api-key");
|
||||
apiClient.setApiKeyPrefix("Token");
|
||||
assertEquals("my-api-key", auth.getApiKey());
|
||||
assertEquals("Token", auth.getApiKeyPrefix());
|
||||
|
||||
// reset values
|
||||
auth.setApiKey(null);
|
||||
auth.setApiKeyPrefix(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAndSetConnectTimeout() {
|
||||
// connect timeout defaults to 10 seconds
|
||||
assertEquals(10000, apiClient.getConnectTimeout());
|
||||
assertEquals(10000, apiClient.getHttpClient().connectTimeoutMillis());
|
||||
|
||||
apiClient.setConnectTimeout(0);
|
||||
assertEquals(0, apiClient.getConnectTimeout());
|
||||
assertEquals(0, apiClient.getHttpClient().connectTimeoutMillis());
|
||||
|
||||
apiClient.setConnectTimeout(10000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAndSetReadTimeout() {
|
||||
// read timeout defaults to 10 seconds
|
||||
assertEquals(10000, apiClient.getReadTimeout());
|
||||
assertEquals(10000, apiClient.getHttpClient().readTimeoutMillis());
|
||||
|
||||
apiClient.setReadTimeout(0);
|
||||
assertEquals(0, apiClient.getReadTimeout());
|
||||
assertEquals(0, apiClient.getHttpClient().readTimeoutMillis());
|
||||
|
||||
apiClient.setReadTimeout(10000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAndSetWriteTimeout() {
|
||||
// write timeout defaults to 10 seconds
|
||||
assertEquals(10000, apiClient.getWriteTimeout());
|
||||
assertEquals(10000, apiClient.getHttpClient().writeTimeoutMillis());
|
||||
|
||||
apiClient.setWriteTimeout(0);
|
||||
assertEquals(0, apiClient.getWriteTimeout());
|
||||
assertEquals(0, apiClient.getHttpClient().writeTimeoutMillis());
|
||||
|
||||
apiClient.setWriteTimeout(10000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParameterToPairWhenNameIsInvalid() throws Exception {
|
||||
List<Pair> pairs_a = apiClient.parameterToPair(null, new Integer(1));
|
||||
List<Pair> pairs_b = apiClient.parameterToPair("", new Integer(1));
|
||||
|
||||
assertTrue(pairs_a.isEmpty());
|
||||
assertTrue(pairs_b.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParameterToPairWhenValueIsNull() throws Exception {
|
||||
List<Pair> pairs = apiClient.parameterToPair("param-a", null);
|
||||
|
||||
assertTrue(pairs.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParameterToPairWhenValueIsEmptyString() throws Exception {
|
||||
// single empty string
|
||||
List<Pair> pairs = apiClient.parameterToPair("param-a", " ");
|
||||
assertEquals(1, pairs.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParameterToPairWhenValueIsNotCollection() throws Exception {
|
||||
String name = "param-a";
|
||||
Integer value = 1;
|
||||
|
||||
List<Pair> pairs = apiClient.parameterToPair(name, value);
|
||||
|
||||
assertEquals(1, pairs.size());
|
||||
assertEquals(value, Integer.valueOf(pairs.get(0).getValue()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParameterToPairWhenValueIsCollection() throws Exception {
|
||||
List<Object> values = new ArrayList<Object>();
|
||||
values.add("value-a");
|
||||
values.add(123);
|
||||
values.add(new Date());
|
||||
|
||||
List<Pair> pairs = apiClient.parameterToPair("param-a", values);
|
||||
assertEquals(0, pairs.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParameterToPairsWhenNameIsInvalid() throws Exception {
|
||||
List<Integer> objects = new ArrayList<Integer>();
|
||||
objects.add(new Integer(1));
|
||||
|
||||
List<Pair> pairs_a = apiClient.parameterToPairs("csv", null, objects);
|
||||
List<Pair> pairs_b = apiClient.parameterToPairs("csv", "", objects);
|
||||
|
||||
assertTrue(pairs_a.isEmpty());
|
||||
assertTrue(pairs_b.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParameterToPairsWhenValueIsNull() throws Exception {
|
||||
List<Pair> pairs = apiClient.parameterToPairs("csv", "param-a", null);
|
||||
|
||||
assertTrue(pairs.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParameterToPairsWhenValueIsEmptyStrings() throws Exception {
|
||||
// list of empty strings
|
||||
List<String> strs = new ArrayList<String>();
|
||||
strs.add(" ");
|
||||
strs.add(" ");
|
||||
strs.add(" ");
|
||||
|
||||
List<Pair> concatStrings = apiClient.parameterToPairs("csv", "param-a", strs);
|
||||
|
||||
assertEquals(1, concatStrings.size());
|
||||
assertFalse(concatStrings.get(0).getValue().isEmpty()); // should contain some delimiters
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParameterToPairsWhenValueIsCollection() throws Exception {
|
||||
Map<String, String> collectionFormatMap = new HashMap<String, String>();
|
||||
collectionFormatMap.put("csv", ",");
|
||||
collectionFormatMap.put("tsv", "\t");
|
||||
collectionFormatMap.put("ssv", " ");
|
||||
collectionFormatMap.put("pipes", "|");
|
||||
collectionFormatMap.put("", ","); // no format, must default to csv
|
||||
collectionFormatMap.put("unknown", ","); // all other formats, must default to csv
|
||||
|
||||
String name = "param-a";
|
||||
|
||||
List<Object> values = new ArrayList<Object>();
|
||||
values.add("value-a");
|
||||
values.add(123);
|
||||
values.add(new Date());
|
||||
|
||||
// check for multi separately
|
||||
List<Pair> multiPairs = apiClient.parameterToPairs("multi", name, values);
|
||||
assertEquals(values.size(), multiPairs.size());
|
||||
for (int i = 0; i < values.size(); i++) {
|
||||
assertEquals(
|
||||
apiClient.escapeString(apiClient.parameterToString(values.get(i))),
|
||||
multiPairs.get(i).getValue());
|
||||
}
|
||||
|
||||
// all other formats
|
||||
for (String collectionFormat : collectionFormatMap.keySet()) {
|
||||
List<Pair> pairs = apiClient.parameterToPairs(collectionFormat, name, values);
|
||||
|
||||
assertEquals(1, pairs.size());
|
||||
|
||||
String delimiter = collectionFormatMap.get(collectionFormat);
|
||||
if (!delimiter.equals(",")) {
|
||||
// commas are not escaped because they are reserved characters in URIs
|
||||
delimiter = apiClient.escapeString(delimiter);
|
||||
}
|
||||
String[] pairValueSplit = pairs.get(0).getValue().split(delimiter);
|
||||
|
||||
// must equal input values
|
||||
assertEquals(values.size(), pairValueSplit.length);
|
||||
for (int i = 0; i < values.size(); i++) {
|
||||
assertEquals(
|
||||
apiClient.escapeString(apiClient.parameterToString(values.get(i))),
|
||||
pairValueSplit[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSanitizeFilename() {
|
||||
assertEquals("sun", apiClient.sanitizeFilename("sun"));
|
||||
assertEquals("sun.gif", apiClient.sanitizeFilename("sun.gif"));
|
||||
assertEquals("sun.gif", apiClient.sanitizeFilename("../sun.gif"));
|
||||
assertEquals("sun.gif", apiClient.sanitizeFilename("/var/tmp/sun.gif"));
|
||||
assertEquals("sun.gif", apiClient.sanitizeFilename("./sun.gif"));
|
||||
assertEquals("sun.gif", apiClient.sanitizeFilename("..\\sun.gif"));
|
||||
assertEquals("sun.gif", apiClient.sanitizeFilename("\\var\\tmp\\sun.gif"));
|
||||
assertEquals("sun.gif", apiClient.sanitizeFilename("c:\\var\\tmp\\sun.gif"));
|
||||
assertEquals("sun.gif", apiClient.sanitizeFilename(".\\sun.gif"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewHttpClient() {
|
||||
OkHttpClient oldClient = apiClient.getHttpClient();
|
||||
apiClient.setHttpClient(oldClient.newBuilder().build());
|
||||
assertNotSame(apiClient.getHttpClient(), oldClient);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the invariant that the HttpClient for the ApiClient must never be null
|
||||
*/
|
||||
@Test
|
||||
public void testNullHttpClient() {
|
||||
NullPointerException thrown = Assertions.assertThrows(NullPointerException.class, () -> {
|
||||
apiClient.setHttpClient(null);
|
||||
});
|
||||
Assertions.assertEquals("HttpClient must not be null!", thrown.getMessage());
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package org.openapitools.client;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.*;
|
||||
|
||||
public class ConfigurationTest {
|
||||
@Test
|
||||
public void testDefaultApiClient() {
|
||||
ApiClient apiClient = Configuration.getDefaultApiClient();
|
||||
assertNotNull(apiClient);
|
||||
assertEquals("http://petstore.swagger.io:80/v2", apiClient.getBasePath());
|
||||
assertFalse(apiClient.isDebugging());
|
||||
}
|
||||
}
|
@ -0,0 +1,579 @@
|
||||
package org.openapitools.client;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.LocalDate;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import okio.ByteString;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.openapitools.client.model.Order;
|
||||
|
||||
import org.openapitools.client.model.*;
|
||||
|
||||
public class JSONTest {
|
||||
private ApiClient apiClient = null;
|
||||
private JSON json = null;
|
||||
private Order order = null;
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
apiClient = new ApiClient();
|
||||
json = apiClient.getJSON();
|
||||
order = new Order();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSqlDateTypeAdapter() {
|
||||
final String str = "\"2015-11-07\"";
|
||||
final java.sql.Date date = java.sql.Date.valueOf("2015-11-07");
|
||||
|
||||
assertEquals(str, json.serialize(date));
|
||||
assertEquals(json.deserialize(str, java.sql.Date.class), date);
|
||||
assertEquals(
|
||||
json.deserialize(
|
||||
"\"2015-11-07T03:49:09.356" + getCurrentTimezoneOffset() + "\"",
|
||||
java.sql.Date.class)
|
||||
.toString(),
|
||||
date.toString());
|
||||
|
||||
// custom date format: without day
|
||||
DateFormat format = new SimpleDateFormat("yyyy-MM", Locale.ROOT);
|
||||
apiClient.setSqlDateFormat(format);
|
||||
String dateStr = "\"2015-11\"";
|
||||
assertEquals(
|
||||
dateStr,
|
||||
json.serialize(json.deserialize("\"2015-11-07T03:49:09Z\"", java.sql.Date.class)));
|
||||
assertEquals(dateStr, json.serialize(json.deserialize("\"2015-11\"", java.sql.Date.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDateTypeAdapter() {
|
||||
Calendar cal = new GregorianCalendar(2015, 10, 7, 3, 49, 9);
|
||||
cal.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
|
||||
assertEquals(json.deserialize("\"2015-11-07T05:49:09+02\"", Date.class), cal.getTime());
|
||||
|
||||
cal.set(Calendar.MILLISECOND, 300);
|
||||
assertEquals(json.deserialize("\"2015-11-07T03:49:09.3Z\"", Date.class), cal.getTime());
|
||||
|
||||
cal.set(Calendar.MILLISECOND, 356);
|
||||
Date date = cal.getTime();
|
||||
|
||||
final String utcDate = "\"2015-11-07T03:49:09.356Z\"";
|
||||
assertEquals(json.deserialize(utcDate, Date.class), date);
|
||||
assertEquals(json.deserialize("\"2015-11-07T03:49:09.356+00:00\"", Date.class), date);
|
||||
assertEquals(json.deserialize("\"2015-11-07T05:49:09.356+02:00\"", Date.class), date);
|
||||
assertEquals(json.deserialize("\"2015-11-07T02:49:09.356-01:00\"", Date.class), date);
|
||||
assertEquals(json.deserialize("\"2015-11-07T03:49:09.356Z\"", Date.class), date);
|
||||
assertEquals(json.deserialize("\"2015-11-07T03:49:09.356+00\"", Date.class), date);
|
||||
assertEquals(json.deserialize("\"2015-11-07T02:49:09.356-0100\"", Date.class), date);
|
||||
assertEquals(json.deserialize("\"2015-11-07T03:49:09.356456789Z\"", Date.class), date);
|
||||
|
||||
assertEquals(utcDate, json.serialize(date));
|
||||
|
||||
// custom datetime format: without milli-seconds, custom time zone
|
||||
DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX", Locale.ROOT);
|
||||
format.setTimeZone(TimeZone.getTimeZone("GMT+10"));
|
||||
apiClient.setDateFormat(format);
|
||||
|
||||
String dateStr = "\"2015-11-07T13:49:09+10:00\"";
|
||||
assertEquals(
|
||||
dateStr,
|
||||
json.serialize(json.deserialize("\"2015-11-07T03:49:09+00:00\"", Date.class)));
|
||||
assertEquals(
|
||||
dateStr, json.serialize(json.deserialize("\"2015-11-07T03:49:09Z\"", Date.class)));
|
||||
assertEquals(
|
||||
dateStr,
|
||||
json.serialize(json.deserialize("\"2015-11-07T00:49:09-03:00\"", Date.class)));
|
||||
|
||||
try {
|
||||
// invalid time zone format
|
||||
json.deserialize("\"2015-11-07T03:49:09+00\"", Date.class);
|
||||
fail("json parsing should fail");
|
||||
} catch (RuntimeException e) {
|
||||
// OK
|
||||
}
|
||||
try {
|
||||
// unexpected milliseconds
|
||||
json.deserialize("\"2015-11-07T03:49:09.000Z\"", Date.class);
|
||||
fail("json parsing should fail");
|
||||
} catch (RuntimeException e) {
|
||||
// OK
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOffsetDateTimeTypeAdapter() {
|
||||
final String str = "\"2016-09-09T08:02:03.123-03:00\"";
|
||||
OffsetDateTime date =
|
||||
OffsetDateTime.of(2016, 9, 9, 8, 2, 3, 123000000, ZoneOffset.of("-3"));
|
||||
|
||||
assertEquals(str, json.serialize(date));
|
||||
// Use toString() instead of isEqual to verify that the offset is preserved
|
||||
assertEquals(json.deserialize(str, OffsetDateTime.class).toString(), date.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLocalDateTypeAdapter() {
|
||||
final String str = "\"2016-09-09\"";
|
||||
final LocalDate date = LocalDate.of(2016, 9, 9);
|
||||
|
||||
assertEquals(str, json.serialize(date));
|
||||
assertEquals(json.deserialize(str, LocalDate.class), date);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultDate() throws Exception {
|
||||
final DateTimeFormatter datetimeFormat = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
||||
final String dateStr = "2015-11-07T14:11:05.267Z";
|
||||
order.setShipDate(OffsetDateTime.from(datetimeFormat.parse(dateStr)));
|
||||
|
||||
String str = json.serialize(order);
|
||||
Type type = new TypeToken<Order>() {
|
||||
}.getType();
|
||||
Order o = json.deserialize(str, type);
|
||||
assertEquals(dateStr, datetimeFormat.format(o.getShipDate()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomDate() throws Exception {
|
||||
final DateTimeFormatter datetimeFormat =
|
||||
DateTimeFormatter.ISO_OFFSET_DATE_TIME.withZone(ZoneId.of("Etc/GMT+2"));
|
||||
final String dateStr = "2015-11-07T14:11:05-02:00";
|
||||
order.setShipDate(OffsetDateTime.from(datetimeFormat.parse(dateStr)));
|
||||
|
||||
String str = json.serialize(order);
|
||||
Type type = new TypeToken<Order>() {
|
||||
}.getType();
|
||||
Order o = json.deserialize(str, type);
|
||||
assertEquals(dateStr, datetimeFormat.format(o.getShipDate()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testByteArrayTypeAdapterSerialization() {
|
||||
// Arrange
|
||||
final String expectedBytesAsString = "Let's pretend this a jpg or something";
|
||||
final byte[] expectedBytes = expectedBytesAsString.getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
// Act
|
||||
String serializedBytesWithQuotes = json.serialize(expectedBytes);
|
||||
|
||||
// Assert
|
||||
String serializedBytes =
|
||||
serializedBytesWithQuotes.substring(1, serializedBytesWithQuotes.length() - 1);
|
||||
if (json.getGson().htmlSafe()) {
|
||||
serializedBytes = serializedBytes.replaceAll("\\\\u003d", "=");
|
||||
}
|
||||
ByteString actualAsByteString = ByteString.decodeBase64(serializedBytes);
|
||||
byte[] actualBytes = actualAsByteString.toByteArray();
|
||||
assertEquals(expectedBytesAsString, new String(actualBytes, StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testByteArrayTypeAdapterDeserialization() {
|
||||
// Arrange
|
||||
final String expectedBytesAsString = "Let's pretend this a jpg or something";
|
||||
final byte[] expectedBytes = expectedBytesAsString.getBytes(StandardCharsets.UTF_8);
|
||||
final ByteString expectedByteString = ByteString.of(expectedBytes);
|
||||
final String serializedBytes = expectedByteString.base64();
|
||||
final String serializedBytesWithQuotes = "\"" + serializedBytes + "\"";
|
||||
Type type = new TypeToken<byte[]>() {
|
||||
}.getType();
|
||||
|
||||
// Act
|
||||
byte[] actualDeserializedBytes = json.deserialize(serializedBytesWithQuotes, type);
|
||||
|
||||
// Assert
|
||||
assertEquals(
|
||||
expectedBytesAsString, new String(actualDeserializedBytes, StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRequiredFieldException() {
|
||||
IllegalArgumentException thrown = Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||
// test json string missing required field(s) to ensure exception is thrown
|
||||
Gson gson = json.getGson();
|
||||
//Gson gson = new GsonBuilder()
|
||||
// .registerTypeAdapter(Pet.class, new Pet.CustomDeserializer())
|
||||
// .create();
|
||||
String json = "{\"id\": 5847, \"name\":\"tag test 1\"}"; // missing photoUrls (required field)
|
||||
//String json = "{\"id2\": 5847, \"name\":\"tag test 1\"}";
|
||||
//String json = "{\"id\": 5847}";
|
||||
Pet p = gson.fromJson(json, Pet.class);
|
||||
});
|
||||
|
||||
Assertions.assertEquals("The required field `photoUrls` is not found in the JSON string: {\"id\":5847,\"name\":\"tag test 1\"}", thrown.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled("No longer need the following test as additional field(s) should be stored in `additionalProperties`")
|
||||
public void testAdditionalFieldException() {
|
||||
IllegalArgumentException thrown = Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||
// test json string with additional field(s) to ensure exception is thrown
|
||||
Gson gson = json.getGson();
|
||||
String json = "{\"id\": 5847, \"name\":\"tag test 1\", \"new-field\": true}";
|
||||
org.openapitools.client.model.Tag t = gson.fromJson(json, org.openapitools.client.model.Tag.class);
|
||||
});
|
||||
|
||||
Assertions.assertEquals("The field `new-field` in the JSON string is not defined in the `Tag` properties. JSON: {\"id\":5847,\"name\":\"tag test 1\",\"new-field\":true}", thrown.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomDeserializer() {
|
||||
// test the custom deserializer to ensure it can deserialize json payload into objects
|
||||
Gson gson = json.getGson();
|
||||
//Gson gson = new GsonBuilder()
|
||||
// .registerTypeAdapter(Tag.class, new Tag.CustomDeserializer())
|
||||
// .create();
|
||||
// id and name
|
||||
String json = "{\"id\": 5847, \"name\":\"tag test 1\"}";
|
||||
org.openapitools.client.model.Tag t = gson.fromJson(json, org.openapitools.client.model.Tag.class);
|
||||
assertEquals(t.getName(), "tag test 1");
|
||||
assertEquals(t.getId(), Long.valueOf(5847L));
|
||||
|
||||
// name only
|
||||
String json2 = "{\"name\":\"tag test 1\"}";
|
||||
org.openapitools.client.model.Tag t2 = gson.fromJson(json2, org.openapitools.client.model.Tag.class);
|
||||
assertEquals(t2.getName(), "tag test 1");
|
||||
assertEquals(t2.getId(), null);
|
||||
|
||||
// with all required fields
|
||||
String json3 = "{\"id\": 5847, \"name\":\"pet test 1\", \"photoUrls\": [\"https://a.com\", \"https://b.com\"]}";
|
||||
Pet t3 = gson.fromJson(json3, Pet.class);
|
||||
assertEquals(t3.getName(), "pet test 1");
|
||||
assertEquals(t3.getId(), Long.valueOf(5847));
|
||||
|
||||
// with all required fields and tags (optional)
|
||||
String json4 = "{\"id\": 5847, \"name\":\"pet test 1\", \"photoUrls\": [\"https://a.com\", \"https://b.com\"],\"tags\":[{\"id\":\"tag 123\"}]}";
|
||||
Pet t4 = gson.fromJson(json3, Pet.class);
|
||||
assertEquals(t4.getName(), "pet test 1");
|
||||
assertEquals(t4.getId(), Long.valueOf(5847));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled("Unknown fields are now correctly deserialized into `additionalProperties`")
|
||||
public void testUnknownFields() {
|
||||
// test unknown fields in the payload
|
||||
Gson gson = json.getGson();
|
||||
// test Tag
|
||||
String json5 = "{\"unknown_field\": 543, \"id\":\"tag 123\"}";
|
||||
Exception exception5 = assertThrows(java.lang.IllegalArgumentException.class, () -> {
|
||||
org.openapitools.client.model.Tag t5 = gson.fromJson(json5, org.openapitools.client.model.Tag.class);
|
||||
});
|
||||
assertTrue(exception5.getMessage().contains("The field `unknown_field` in the JSON string is not defined in the `Tag` properties. JSON: {\"unknown_field\":543,\"id\":\"tag 123\"}"));
|
||||
|
||||
// test Pet with invalid tags
|
||||
String json6 = "{\"id\": 5847, \"name\":\"pet test 1\", \"photoUrls\": [\"https://a.com\", \"https://b.com\"],\"tags\":[{\"unknown_field\": 543, \"id\":\"tag 123\"}]}";
|
||||
Exception exception6 = assertThrows(java.lang.IllegalArgumentException.class, () -> {
|
||||
Pet t6 = gson.fromJson(json6, Pet.class);
|
||||
});
|
||||
assertTrue(exception6.getMessage().contains("The field `unknown_field` in the JSON string is not defined in the `Tag` properties. JSON: {\"unknown_field\":543,\"id\":\"tag 123\"}"));
|
||||
|
||||
// test Pet with invalid tags (required)
|
||||
String json7 = "{\"id\": 5847, \"name\":\"pet test 1\", \"photoUrls\": [\"https://a.com\", \"https://b.com\"],\"tags\":[{\"unknown_field\": 543, \"id\":\"tag 123\"}]}";
|
||||
Exception exception7 = assertThrows(java.lang.IllegalArgumentException.class, () -> {
|
||||
PetWithRequiredTags t7 = gson.fromJson(json7, PetWithRequiredTags.class);
|
||||
});
|
||||
assertTrue(exception7.getMessage().contains("The field `unknown_field` in the JSON string is not defined in the `Tag` properties. JSON: {\"unknown_field\":543,\"id\":\"tag 123\"}"));
|
||||
|
||||
// test Pet with invalid tags (missing reqired)
|
||||
String json8 = "{\"id\": 5847, \"name\":\"pet test 1\", \"photoUrls\": [\"https://a.com\", \"https://b.com\"]}";
|
||||
Exception exception8 = assertThrows(java.lang.IllegalArgumentException.class, () -> {
|
||||
PetWithRequiredTags t8 = gson.fromJson(json8, PetWithRequiredTags.class);
|
||||
});
|
||||
assertTrue(exception8.getMessage().contains("The required field `tags` is not found in the JSON string: {\"id\":5847,\"name\":\"pet test 1\",\"photoUrls\":[\"https://a.com\",\"https://b.com\"]}"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Model tests for Pet
|
||||
*/
|
||||
@Test
|
||||
public void testPet() {
|
||||
// test Pet
|
||||
Pet model = new Pet();
|
||||
model.setId(1029L);
|
||||
model.setName("Dog");
|
||||
|
||||
Pet model2 = new Pet();
|
||||
model2.setId(1029L);
|
||||
model2.setName("Dog");
|
||||
|
||||
assertTrue(model.equals(model2));
|
||||
}
|
||||
|
||||
// Obtained 22JAN2018 from stackoverflow answer by PuguaSoft
|
||||
// https://stackoverflow.com/questions/11399491/java-timezone-offset
|
||||
// Direct link https://stackoverflow.com/a/16680815/3166133
|
||||
public static String getCurrentTimezoneOffset() {
|
||||
|
||||
TimeZone tz = TimeZone.getDefault();
|
||||
Calendar cal = GregorianCalendar.getInstance(tz, Locale.ROOT);
|
||||
int offsetInMillis = tz.getOffset(cal.getTimeInMillis());
|
||||
|
||||
String offset =
|
||||
String.format(
|
||||
Locale.ROOT,
|
||||
"%02d:%02d",
|
||||
Math.abs(offsetInMillis / 3600000),
|
||||
Math.abs((offsetInMillis / 60000) % 60));
|
||||
offset = (offsetInMillis >= 0 ? "+" : "-") + offset;
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate an anyOf schema can be deserialized into the expected class.
|
||||
* The anyOf schema does not have a discriminator.
|
||||
*/
|
||||
@Test
|
||||
public void testAnyOfSchemaWithoutDiscriminator() throws Exception {
|
||||
{
|
||||
String str = "{ \"cultivar\": \"golden delicious\", \"origin\": \"japan\" }";
|
||||
|
||||
// make sure deserialization works for pojo object
|
||||
Apple a = json.getGson().fromJson(str, Apple.class);
|
||||
assertEquals(a.getCultivar(), "golden delicious");
|
||||
assertEquals(a.getOrigin(), "japan");
|
||||
|
||||
GmFruit o = json.getGson().fromJson(str, GmFruit.class);
|
||||
assertTrue(o.getActualInstance() instanceof Apple);
|
||||
Apple inst = (Apple) o.getActualInstance();
|
||||
assertEquals(inst.getCultivar(), "golden delicious");
|
||||
assertEquals(inst.getOrigin(), "japan");
|
||||
assertEquals(json.getGson().toJson(inst), "{\"cultivar\":\"golden delicious\",\"origin\":\"japan\"}");
|
||||
assertEquals(inst.toJson(), "{\"cultivar\":\"golden delicious\",\"origin\":\"japan\"}");
|
||||
assertEquals(json.getGson().toJson(o), "{\"cultivar\":\"golden delicious\",\"origin\":\"japan\"}");
|
||||
assertEquals(o.toJson(), "{\"cultivar\":\"golden delicious\",\"origin\":\"japan\"}");
|
||||
|
||||
/* comment out the following as we've added "additionalProperties" support
|
||||
String str2 = "{ \"origin_typo\": \"japan\" }";
|
||||
// no match
|
||||
Exception exception = assertThrows(java.lang.IllegalArgumentException.class, () -> {
|
||||
Apple o3 = json.getGson().fromJson(str2, Apple.class);
|
||||
});
|
||||
|
||||
// no match
|
||||
Exception exception3 = assertThrows(java.lang.IllegalArgumentException.class, () -> {
|
||||
Banana o2 = json.getGson().fromJson(str2, Banana.class);
|
||||
});
|
||||
|
||||
// no match
|
||||
Exception exception4 = assertThrows(com.google.gson.JsonSyntaxException.class, () -> {
|
||||
GmFruit o2 = json.getGson().fromJson(str2, GmFruit.class);
|
||||
});
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a oneOf schema can be deserialized into the expected class.
|
||||
* The oneOf schema has a discriminator.
|
||||
*/
|
||||
@Test
|
||||
public void testOneOfSchemaWithDiscriminator() throws Exception {
|
||||
{
|
||||
String str = "{ \"className\": \"whale\", \"hasBaleen\": false, \"hasTeeth\": false }";
|
||||
|
||||
// make sure deserialization works for pojo object
|
||||
Whale w = json.getGson().fromJson(str, Whale.class);
|
||||
assertEquals(w.getClassName(), "whale");
|
||||
assertEquals(w.getHasBaleen(), false);
|
||||
assertEquals(w.getHasTeeth(), false);
|
||||
|
||||
Mammal o = json.getGson().fromJson(str, Mammal.class);
|
||||
assertTrue(o.getActualInstance() instanceof Whale);
|
||||
Whale inst = (Whale) o.getActualInstance();
|
||||
assertEquals(inst.getClassName(), "whale");
|
||||
assertEquals(inst.getHasBaleen(), false);
|
||||
assertEquals(inst.getHasTeeth(), false);
|
||||
assertEquals(json.getGson().toJson(inst), "{\"hasBaleen\":false,\"hasTeeth\":false,\"className\":\"whale\"}");
|
||||
assertEquals(inst.toJson(), "{\"hasBaleen\":false,\"hasTeeth\":false,\"className\":\"whale\"}");
|
||||
assertEquals(json.getGson().toJson(o), "{\"hasBaleen\":false,\"hasTeeth\":false,\"className\":\"whale\"}");
|
||||
assertEquals(o.toJson(), "{\"hasBaleen\":false,\"hasTeeth\":false,\"className\":\"whale\"}");
|
||||
|
||||
String str2 = "{ \"className\": \"zebra\", \"type\": \"plains\" }";
|
||||
|
||||
// make sure deserialization works for pojo object
|
||||
Zebra z = Zebra.fromJson(str2);
|
||||
assertEquals(z.toJson(), "{\"type\":\"plains\",\"className\":\"zebra\"}");
|
||||
|
||||
Mammal o2 = json.getGson().fromJson(str2, Mammal.class);
|
||||
assertTrue(o2.getActualInstance() instanceof Zebra);
|
||||
Zebra inst2 = (Zebra) o2.getActualInstance();
|
||||
assertEquals(json.getGson().toJson(inst2), "{\"type\":\"plains\",\"className\":\"zebra\"}");
|
||||
assertEquals(inst2.toJson(), "{\"type\":\"plains\",\"className\":\"zebra\"}");
|
||||
assertEquals(json.getGson().toJson(o2), "{\"type\":\"plains\",\"className\":\"zebra\"}");
|
||||
assertEquals(o2.toJson(), "{\"type\":\"plains\",\"className\":\"zebra\"}");
|
||||
}
|
||||
{
|
||||
// incorrect payload results in exception
|
||||
String str = "{ \"cultivar\": \"golden delicious\", \"mealy\": false, \"garbage_prop\": \"abc\" }";
|
||||
Exception exception = assertThrows(com.google.gson.JsonSyntaxException.class, () -> {
|
||||
Mammal o = json.getGson().fromJson(str, Mammal.class);
|
||||
});
|
||||
//assertEquals("java.io.IOException: Failed deserialization for Mammal: 0 classes match result, expected 1. Detailed failure message for oneOf schemas: [Deserialization for Pig failed with `The JSON string is invalid for Pig with oneOf schemas: BasquePig, DanishPig. 0 class(es) match the result, expected 1. Detailed failure message for oneOf schemas: [Deserialization for BasquePig failed with `The required field `className` is not found in the JSON string: {\"cultivar\":\"golden delicious\",\"mealy\":false,\"garbage_prop\":\"abc\"}`., Deserialization for DanishPig failed with `The required field `className` is not found in the JSON string: {\"cultivar\":\"golden delicious\",\"mealy\":false,\"garbage_prop\":\"abc\"}`.]. JSON: {\"cultivar\":\"golden delicious\",\"mealy\":false,\"garbage_prop\":\"abc\"}`., Deserialization for Whale failed with `The required field `className` is not found in the JSON string: {\"cultivar\":\"golden delicious\",\"mealy\":false,\"garbage_prop\":\"abc\"}`., Deserialization for Zebra failed with `The required field `className` is not found in the JSON string: {\"cultivar\":\"golden delicious\",\"mealy\":false,\"garbage_prop\":\"abc\"}`.]. JSON: {\"cultivar\":\"golden delicious\",\"mealy\":false,\"garbage_prop\":\"abc\"}", exception.getMessage());
|
||||
assertTrue(exception.getMessage().contains("java.io.IOException: Failed deserialization for Mammal"));
|
||||
}
|
||||
{
|
||||
// Try to deserialize empty object. This should fail 'oneOf' because none will match
|
||||
// whale or zebra.
|
||||
String str = "{ }";
|
||||
Exception exception = assertThrows(com.google.gson.JsonSyntaxException.class, () -> {
|
||||
json.getGson().fromJson(str, Mammal.class);
|
||||
});
|
||||
//assertEquals("java.io.IOException: Failed deserialization for Mammal: 0 classes match result, expected 1. Detailed failure message for oneOf schemas: [Deserialization for Pig failed with `The JSON string is invalid for Pig with oneOf schemas: BasquePig, DanishPig. 0 class(es) match the result, expected 1. Detailed failure message for oneOf schemas: [Deserialization for BasquePig failed with `The required field `className` is not found in the JSON string: {}`., Deserialization for DanishPig failed with `The required field `className` is not found in the JSON string: {}`.]. JSON: {}`., Deserialization for Whale failed with `The required field `className` is not found in the JSON string: {}`., Deserialization for Zebra failed with `The required field `className` is not found in the JSON string: {}`.]. JSON: {}", exception.getMessage());
|
||||
assertTrue(exception.getMessage().contains("java.io.IOException: Failed deserialization for Mammal"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test JSON validation method
|
||||
*/
|
||||
@Test
|
||||
public void testJsonValidation() throws Exception {
|
||||
String str = "{ \"cultivar\": [\"golden delicious\"], \"mealy\": false }";
|
||||
Exception exception = assertThrows(java.lang.IllegalArgumentException.class, () -> {
|
||||
AppleReq a = json.getGson().fromJson(str, AppleReq.class);
|
||||
});
|
||||
assertTrue(exception.getMessage().contains("Expected the field `cultivar` to be a primitive type in the JSON string but got `[\"golden delicious\"]`"));
|
||||
|
||||
String str2 = "{ \"id\": 5847, \"name\":\"pet test 1\", \"photoUrls\": 123 }";
|
||||
Exception exception2 = assertThrows(java.lang.IllegalArgumentException.class, () -> {
|
||||
Pet p1 = json.getGson().fromJson(str2, Pet.class);
|
||||
});
|
||||
assertTrue(exception2.getMessage().contains("Expected the field `photoUrls` to be an array in the JSON string but got `123`"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a oneOf schema can be deserialized into the expected class.
|
||||
* The oneOf schema does not have a discriminator.
|
||||
*/
|
||||
@Test
|
||||
public void testOneOfSchemaWithoutDiscriminator() throws Exception {
|
||||
// BananaReq and AppleReq have explicitly defined properties that are different by name.
|
||||
// There is no discriminator property.
|
||||
{
|
||||
String str = "{ \"cultivar\": \"golden delicious\", \"mealy\": false }";
|
||||
|
||||
// make sure deserialization works for pojo object
|
||||
AppleReq a = json.getGson().fromJson(str, AppleReq.class);
|
||||
assertEquals(a.getCultivar(), "golden delicious");
|
||||
assertEquals(a.getMealy(), false);
|
||||
|
||||
FruitReq o = json.getGson().fromJson(str, FruitReq.class);
|
||||
assertTrue(o.getActualInstance() instanceof AppleReq);
|
||||
AppleReq inst = (AppleReq) o.getActualInstance();
|
||||
assertEquals(inst.getCultivar(), "golden delicious");
|
||||
assertEquals(inst.getMealy(), false);
|
||||
assertEquals(json.getGson().toJson(inst), "{\"cultivar\":\"golden delicious\",\"mealy\":false}");
|
||||
assertEquals(inst.toJson(), "{\"cultivar\":\"golden delicious\",\"mealy\":false}");
|
||||
assertEquals(json.getGson().toJson(o), "{\"cultivar\":\"golden delicious\",\"mealy\":false}");
|
||||
assertEquals(o.toJson(), "{\"cultivar\":\"golden delicious\",\"mealy\":false}");
|
||||
|
||||
AppleReq inst2 = o.getAppleReq();
|
||||
assertEquals(inst2.getCultivar(), "golden delicious");
|
||||
assertEquals(inst2.getMealy(), false);
|
||||
assertEquals(json.getGson().toJson(inst2), "{\"cultivar\":\"golden delicious\",\"mealy\":false}");
|
||||
assertEquals(inst2.toJson(), "{\"cultivar\":\"golden delicious\",\"mealy\":false}");
|
||||
|
||||
// test fromJson
|
||||
FruitReq o3 = FruitReq.fromJson(str);
|
||||
assertTrue(o3.getActualInstance() instanceof AppleReq);
|
||||
AppleReq inst3 = (AppleReq) o3.getActualInstance();
|
||||
assertEquals(inst3.getCultivar(), "golden delicious");
|
||||
assertEquals(inst3.getMealy(), false);
|
||||
assertEquals(json.getGson().toJson(inst3), "{\"cultivar\":\"golden delicious\",\"mealy\":false}");
|
||||
assertEquals(inst3.toJson(), "{\"cultivar\":\"golden delicious\",\"mealy\":false}");
|
||||
assertEquals(o3.toJson(), "{\"cultivar\":\"golden delicious\",\"mealy\":false}");
|
||||
}
|
||||
{
|
||||
// test to ensure the oneOf object can be serialized to "null" correctly
|
||||
FruitReq o = new FruitReq();
|
||||
assertEquals(o.getActualInstance(), null);
|
||||
assertEquals(json.getGson().toJson(o), "null");
|
||||
assertEquals(o.toJson(), "null");
|
||||
assertEquals(json.getGson().toJson(null), "null");
|
||||
}
|
||||
{
|
||||
// Same test, but this time with additional (undeclared) properties.
|
||||
// Since FruitReq has additionalProperties: false, deserialization should fail.
|
||||
String str = "{ \"cultivar\": \"golden delicious\", \"mealy\": false, \"garbage_prop\": \"abc\" }";
|
||||
Exception exception = assertThrows(com.google.gson.JsonSyntaxException.class, () -> {
|
||||
FruitReq o = json.getGson().fromJson(str, FruitReq.class);
|
||||
});
|
||||
assertEquals("java.io.IOException: Failed deserialization for FruitReq: 0 classes match result, expected 1. Detailed failure message for oneOf schemas: [Deserialization for AppleReq failed with `The field `garbage_prop` in the JSON string is not defined in the `AppleReq` properties. JSON: {\"cultivar\":\"golden delicious\",\"mealy\":false,\"garbage_prop\":\"abc\"}`., Deserialization for BananaReq failed with `The field `cultivar` in the JSON string is not defined in the `BananaReq` properties. JSON: {\"cultivar\":\"golden delicious\",\"mealy\":false,\"garbage_prop\":\"abc\"}`.]. JSON: {\"cultivar\":\"golden delicious\",\"mealy\":false,\"garbage_prop\":\"abc\"}", exception.getMessage());
|
||||
}
|
||||
{
|
||||
String str = "{ \"lengthCm\": 17 }";
|
||||
|
||||
// make sure deserialization works for pojo object
|
||||
BananaReq b = json.getGson().fromJson(str, BananaReq.class);
|
||||
assertEquals(b.getLengthCm(), new java.math.BigDecimal(17));
|
||||
|
||||
FruitReq o = json.getGson().fromJson(str, FruitReq.class);
|
||||
assertTrue(o.getActualInstance() instanceof BananaReq);
|
||||
BananaReq inst = (BananaReq) o.getActualInstance();
|
||||
assertEquals(inst.getLengthCm(), new java.math.BigDecimal(17));
|
||||
assertEquals(json.getGson().toJson(o), "{\"lengthCm\":17}");
|
||||
assertEquals(json.getGson().toJson(inst), "{\"lengthCm\":17}");
|
||||
}
|
||||
{
|
||||
// Try to deserialize empty object. This should fail 'oneOf' because none will match
|
||||
// AppleReq or BananaReq.
|
||||
String str = "{ }";
|
||||
Exception exception = assertThrows(com.google.gson.JsonSyntaxException.class, () -> {
|
||||
json.getGson().fromJson(str, FruitReq.class);
|
||||
});
|
||||
assertTrue(exception.getMessage().contains("Failed deserialization for FruitReq: 0 classes match result, expected 1"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test validateJsonObject with null object
|
||||
*/
|
||||
@Test
|
||||
public void testValidateJsonObject() throws Exception {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
Exception exception = assertThrows(java.lang.IllegalArgumentException.class, () -> {
|
||||
Pet.validateJsonElement(jsonObject);
|
||||
});
|
||||
assertEquals(exception.getMessage(), "The required field `photoUrls` is not found in the JSON string: {}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test additional properties.
|
||||
*/
|
||||
@Test
|
||||
public void testAdditionalProperties() throws Exception {
|
||||
String str = "{ \"className\": \"zebra\", \"type\": \"plains\", \"from_json\": 4567, \"from_json_map\": {\"nested_string\": \"nested_value\"} }";
|
||||
Zebra z = Zebra.fromJson(str);
|
||||
z.putAdditionalProperty("new_key", "new_value");
|
||||
z.putAdditionalProperty("new_number", 1.23);
|
||||
z.putAdditionalProperty("new_boolean", true);
|
||||
org.openapitools.client.model.Tag t = new org.openapitools.client.model.Tag();
|
||||
t.setId(34L);
|
||||
t.setName("just a tag");
|
||||
z.putAdditionalProperty("new_object", t);
|
||||
assertEquals(z.toJson(), "{\"type\":\"plains\",\"className\":\"zebra\",\"new_key\":\"new_value\",\"new_boolean\":true,\"new_object\":{\"id\":34,\"name\":\"just a tag\"},\"from_json\":4567,\"from_json_map\":{\"nested_string\":\"nested_value\"},\"new_number\":1.23}");
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package org.openapitools.client;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.*;
|
||||
|
||||
public class StringUtilTest {
|
||||
@Test
|
||||
public void testContainsIgnoreCase() {
|
||||
assertTrue(StringUtil.containsIgnoreCase(new String[]{"abc"}, "abc"));
|
||||
assertTrue(StringUtil.containsIgnoreCase(new String[]{"abc"}, "ABC"));
|
||||
assertTrue(StringUtil.containsIgnoreCase(new String[]{"ABC"}, "abc"));
|
||||
assertTrue(StringUtil.containsIgnoreCase(new String[]{null, "abc"}, "ABC"));
|
||||
assertTrue(StringUtil.containsIgnoreCase(new String[]{null, "abc"}, null));
|
||||
|
||||
assertFalse(StringUtil.containsIgnoreCase(new String[]{"abc"}, "def"));
|
||||
assertFalse(StringUtil.containsIgnoreCase(new String[]{}, "ABC"));
|
||||
assertFalse(StringUtil.containsIgnoreCase(new String[]{}, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJoin() {
|
||||
String[] array = {"aa", "bb", "cc"};
|
||||
assertEquals("aa,bb,cc", StringUtil.join(array, ","));
|
||||
assertEquals("aa, bb, cc", StringUtil.join(array, ", "));
|
||||
assertEquals("aabbcc", StringUtil.join(array, ""));
|
||||
assertEquals("aa bb cc", StringUtil.join(array, " "));
|
||||
assertEquals("aa\nbb\ncc", StringUtil.join(array, "\n"));
|
||||
|
||||
assertEquals("", StringUtil.join(new String[]{}, ","));
|
||||
assertEquals("abc", StringUtil.join(new String[]{"abc"}, ","));
|
||||
}
|
||||
}
|
@ -2,31 +2,23 @@
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package org.openapitools.client.api;
|
||||
|
||||
import org.openapitools.client.ApiException;
|
||||
import java.math.BigDecimal;
|
||||
import org.openapitools.client.model.Client;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.model.Client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* API tests for AnotherFakeApi
|
||||
*/
|
||||
/** API tests for AnotherFakeApi */
|
||||
@Disabled
|
||||
public class AnotherFakeApiTest {
|
||||
|
||||
@ -35,39 +27,15 @@ public class AnotherFakeApiTest {
|
||||
/**
|
||||
* To test special tags
|
||||
*
|
||||
* To test special tags and operation ID starting with number
|
||||
* <p>To test special tags and operation ID starting with number
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void call123testSpecialTagsTest() throws ApiException {
|
||||
Client client = null;
|
||||
Client response = api.call123testSpecialTags(client);
|
||||
Client body = null;
|
||||
Client response = api.call123testSpecialTags(body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* parameter array number default value
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void getParameterArrayNumberTest() throws ApiException {
|
||||
List<Integer> array = null;
|
||||
api.getParameterArrayNumber(array);
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* parameter string number
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void getParameterStringNumberTest() throws ApiException {
|
||||
BigDecimal stringNumber = null;
|
||||
api.getParameterStringNumber(stringNumber);
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,8 +24,8 @@ import java.time.OffsetDateTime;
|
||||
import org.openapitools.client.model.OuterComposite;
|
||||
import org.openapitools.client.model.OuterEnum;
|
||||
import org.openapitools.client.model.User;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -40,133 +40,148 @@ public class FakeApiTest {
|
||||
|
||||
private final FakeApi api = new FakeApi();
|
||||
|
||||
|
||||
/**
|
||||
* Health check endpoint
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void fakeHealthGetTest() throws ApiException {
|
||||
HealthCheckResult response = api.fakeHealthGet();
|
||||
HealthCheckResult response = api.fakeHealthGet();
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Test serialization of outer boolean types
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void fakeOuterBooleanSerializeTest() throws ApiException {
|
||||
Boolean body = null;
|
||||
Boolean response = api.fakeOuterBooleanSerialize(body);
|
||||
Boolean response = api.fakeOuterBooleanSerialize(body);
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Test serialization of object with outer number type
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void fakeOuterCompositeSerializeTest() throws ApiException {
|
||||
OuterComposite outerComposite = null;
|
||||
OuterComposite response = api.fakeOuterCompositeSerialize(outerComposite);
|
||||
OuterComposite response = api.fakeOuterCompositeSerialize(outerComposite);
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Test serialization of outer number types
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void fakeOuterNumberSerializeTest() throws ApiException {
|
||||
BigDecimal body = null;
|
||||
BigDecimal response = api.fakeOuterNumberSerialize(body);
|
||||
BigDecimal response = api.fakeOuterNumberSerialize(body);
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Test serialization of outer string types
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void fakeOuterStringSerializeTest() throws ApiException {
|
||||
String body = null;
|
||||
String response = api.fakeOuterStringSerialize(body);
|
||||
String response = api.fakeOuterStringSerialize(body);
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Array of Enums
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void getArrayOfEnumsTest() throws ApiException {
|
||||
List<OuterEnum> response = api.getArrayOfEnums();
|
||||
List<OuterEnum> response = api.getArrayOfEnums();
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* parameter name mapping test
|
||||
*
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void getParameterNameMappingTest() throws ApiException {
|
||||
Long underscoreType = null;
|
||||
String type = null;
|
||||
String typeWithUnderscore = null;
|
||||
api.getParameterNameMapping(underscoreType, type, typeWithUnderscore);
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* For this test, the body for this request much reference a schema named `File`.
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void testBodyWithFileSchemaTest() throws ApiException {
|
||||
FileSchemaTestClass fileSchemaTestClass = null;
|
||||
api.testBodyWithFileSchema(fileSchemaTestClass);
|
||||
api.testBodyWithFileSchema(fileSchemaTestClass);
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @throws ApiException if the Api call fails
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void testBodyWithQueryParamsTest() throws ApiException {
|
||||
String query = null;
|
||||
User user = null;
|
||||
api.testBodyWithQueryParams(query, user);
|
||||
api.testBodyWithQueryParams(query, user);
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To test \"client\" model
|
||||
*
|
||||
* To test \"client\" model
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void testClientModelTest() throws ApiException {
|
||||
Client client = null;
|
||||
Client response = api.testClientModel(client);
|
||||
Client response = api.testClientModel(client);
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
*
|
||||
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void testEndpointParametersTest() throws ApiException {
|
||||
@ -184,16 +199,17 @@ public class FakeApiTest {
|
||||
OffsetDateTime dateTime = null;
|
||||
String password = null;
|
||||
String paramCallback = null;
|
||||
api.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback);
|
||||
api.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback);
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To test enum parameters
|
||||
*
|
||||
* To test enum parameters
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void testEnumParametersTest() throws ApiException {
|
||||
@ -205,16 +221,17 @@ public class FakeApiTest {
|
||||
Double enumQueryDouble = null;
|
||||
List<String> enumFormStringArray = null;
|
||||
String enumFormString = null;
|
||||
api.testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString);
|
||||
api.testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString);
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fake endpoint to test group parameters (optional)
|
||||
*
|
||||
* Fake endpoint to test group parameters (optional)
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void testGroupParametersTest() throws ApiException {
|
||||
@ -224,47 +241,52 @@ public class FakeApiTest {
|
||||
Integer stringGroup = null;
|
||||
Boolean booleanGroup = null;
|
||||
Long int64Group = null;
|
||||
api.testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group)
|
||||
api.testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group)
|
||||
.stringGroup(stringGroup)
|
||||
.booleanGroup(booleanGroup)
|
||||
.int64Group(int64Group)
|
||||
.execute();
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* test inline additionalProperties
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void testInlineAdditionalPropertiesTest() throws ApiException {
|
||||
Map<String, String> requestBody = null;
|
||||
api.testInlineAdditionalProperties(requestBody);
|
||||
api.testInlineAdditionalProperties(requestBody);
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* test json serialization of form data
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void testJsonFormDataTest() throws ApiException {
|
||||
String param = null;
|
||||
String param2 = null;
|
||||
api.testJsonFormData(param, param2);
|
||||
api.testJsonFormData(param, param2);
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* To test the collection format in query parameters
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void testQueryParameterCollectionFormatTest() throws ApiException {
|
||||
@ -273,8 +295,8 @@ public class FakeApiTest {
|
||||
List<String> http = null;
|
||||
List<String> url = null;
|
||||
List<String> context = null;
|
||||
api.testQueryParameterCollectionFormat(pipe, ioutil, http, url, context);
|
||||
api.testQueryParameterCollectionFormat(pipe, ioutil, http, url, context);
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -2,30 +2,23 @@
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package org.openapitools.client.api;
|
||||
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.model.Client;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.model.Client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* API tests for FakeClassnameTags123Api
|
||||
*/
|
||||
/** API tests for FakeClassnameTags123Api */
|
||||
@Disabled
|
||||
public class FakeClassnameTags123ApiTest {
|
||||
|
||||
@ -34,15 +27,15 @@ public class FakeClassnameTags123ApiTest {
|
||||
/**
|
||||
* To test class name in snake case
|
||||
*
|
||||
* To test class name in snake case
|
||||
* <p>To test class name in snake case
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void testClassnameTest() throws ApiException {
|
||||
Client client = null;
|
||||
Client response = api.testClassname(client);
|
||||
Client body = null;
|
||||
Client response = api.testClassname(body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,579 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
package org.openapitools.client.api;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.openapitools.client.*;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.auth.*;
|
||||
import org.openapitools.client.model.*;
|
||||
import org.openapitools.client.model.Pet;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* API tests for PetApi
|
||||
*/
|
||||
public class PetApiTest {
|
||||
|
||||
private PetApi api = new PetApi();
|
||||
private final Logger LOG = LoggerFactory.getLogger(PetApiTest.class);
|
||||
// In the circle.yml file, /etc/host is configured with an entry to resolve petstore.swagger.io
|
||||
// to 127.0.0.1
|
||||
private static String basePath = "http://petstore.swagger.io:80/v2";
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
// setup authentication
|
||||
ApiKeyAuth apiKeyAuth = (ApiKeyAuth) api.getApiClient().getAuthentication("api_key");
|
||||
apiKeyAuth.setApiKey("special-key");
|
||||
api.getApiClient().setBasePath(basePath);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testApiClient() {
|
||||
// the default api client is used
|
||||
assertEquals(Configuration.getDefaultApiClient(), api.getApiClient());
|
||||
assertNotNull(api.getApiClient());
|
||||
assertEquals(basePath, api.getApiClient().getBasePath());
|
||||
assertFalse(api.getApiClient().isDebugging());
|
||||
|
||||
ApiClient oldClient = api.getApiClient();
|
||||
|
||||
ApiClient newClient = new ApiClient();
|
||||
newClient.setVerifyingSsl(true);
|
||||
newClient.setBasePath("http://example.com");
|
||||
newClient.setDebugging(true);
|
||||
|
||||
// set api client via constructor
|
||||
api = new PetApi(newClient);
|
||||
assertNotNull(api.getApiClient());
|
||||
assertEquals("http://example.com", api.getApiClient().getBasePath());
|
||||
assertTrue(api.getApiClient().isDebugging());
|
||||
|
||||
// set api client via setter method
|
||||
api.setApiClient(oldClient);
|
||||
assertNotNull(api.getApiClient());
|
||||
assertEquals(basePath, api.getApiClient().getBasePath());
|
||||
assertFalse(api.getApiClient().isDebugging());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateAndGetPet() throws Exception {
|
||||
Pet pet = createPet();
|
||||
api.addPet(pet);
|
||||
|
||||
Pet fetched = api.getPetById(pet.getId());
|
||||
assertPetMatches(pet, fetched);
|
||||
api.deletePet(pet.getId(), null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateAndGetPetWithHttpInfo() throws Exception {
|
||||
Pet pet = createPet();
|
||||
api.addPetWithHttpInfo(pet);
|
||||
|
||||
ApiResponse<Pet> resp = api.getPetByIdWithHttpInfo(pet.getId());
|
||||
assertEquals(200, resp.getStatusCode());
|
||||
assertEquals("application/json", resp.getHeaders().get("Content-Type").get(0));
|
||||
Pet fetched = resp.getData();
|
||||
|
||||
assertPetMatches(pet, fetched);
|
||||
api.deletePet(pet.getId(), null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateAndGetPetAsync() throws Exception {
|
||||
Pet pet = createPet();
|
||||
api.addPet(pet);
|
||||
// to store returned Pet or error message/exception
|
||||
final Map<String, Object> result = new HashMap<String, Object>();
|
||||
|
||||
api.getPetByIdAsync(
|
||||
pet.getId(),
|
||||
new ApiCallback<Pet>() {
|
||||
@Override
|
||||
public void onFailure(
|
||||
ApiException e,
|
||||
int statusCode,
|
||||
Map<String, List<String>> responseHeaders) {
|
||||
result.put("error", e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(
|
||||
Pet pet, int statusCode, Map<String, List<String>> responseHeaders) {
|
||||
result.put("pet", pet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUploadProgress(
|
||||
long bytesWritten, long contentLength, boolean done) {
|
||||
// empty
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadProgress(
|
||||
long bytesRead, long contentLength, boolean done) {
|
||||
// empty
|
||||
}
|
||||
});
|
||||
|
||||
// wait for the asynchronous call to finish (at most 10 seconds)
|
||||
final int maxTry = 10;
|
||||
int tryCount = 1;
|
||||
Pet fetched = null;
|
||||
do {
|
||||
if (tryCount > maxTry) fail("have not got result of getPetByIdAsync after 10 seconds");
|
||||
Thread.sleep(1000);
|
||||
tryCount += 1;
|
||||
if (result.get("error") != null) fail((String) result.get("error"));
|
||||
if (result.get("pet") != null) {
|
||||
fetched = (Pet) result.get("pet");
|
||||
break;
|
||||
}
|
||||
} while (result.isEmpty());
|
||||
assertPetMatches(pet, fetched);
|
||||
api.deletePet(pet.getId(), null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateAndGetPetAsyncInvalidID() throws Exception {
|
||||
Pet pet = createPet();
|
||||
api.addPet(pet);
|
||||
// to store returned Pet or error message/exception
|
||||
final Map<String, Object> result = new HashMap<String, Object>();
|
||||
|
||||
// test getting a nonexistent pet
|
||||
result.clear();
|
||||
api.getPetByIdAsync(
|
||||
-10000L,
|
||||
new ApiCallback<Pet>() {
|
||||
@Override
|
||||
public void onFailure(
|
||||
ApiException e,
|
||||
int statusCode,
|
||||
Map<String, List<String>> responseHeaders) {
|
||||
result.put("exception", e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(
|
||||
Pet pet, int statusCode, Map<String, List<String>> responseHeaders) {
|
||||
result.put("pet", pet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUploadProgress(
|
||||
long bytesWritten, long contentLength, boolean done) {
|
||||
// empty
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadProgress(
|
||||
long bytesRead, long contentLength, boolean done) {
|
||||
// empty
|
||||
}
|
||||
});
|
||||
|
||||
// wait for the asynchronous call to finish (at most 10 seconds)
|
||||
final int maxTry = 10;
|
||||
int tryCount = 1;
|
||||
Pet fetched = null;
|
||||
ApiException exception = null;
|
||||
|
||||
do {
|
||||
if (tryCount > maxTry) fail("have not got result of getPetByIdAsync after 10 seconds");
|
||||
Thread.sleep(1000);
|
||||
tryCount += 1;
|
||||
if (result.get("pet") != null) fail("expected an error");
|
||||
if (result.get("exception") != null) {
|
||||
exception = (ApiException) result.get("exception");
|
||||
break;
|
||||
}
|
||||
} while (result.isEmpty());
|
||||
assertNotNull(exception);
|
||||
assertEquals(404, exception.getCode());
|
||||
String pattern = "^Message: Not Found\\RHTTP response code: 404\\RHTTP response body: .*\\RHTTP response headers: .*$";
|
||||
assertTrue(exception.getMessage().matches(pattern));
|
||||
assertEquals("application/json", exception.getResponseHeaders().get("Content-Type").get(0));
|
||||
api.deletePet(pet.getId(), null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateAndGetMultiplePetsAsync() throws Exception {
|
||||
Pet pet1 = createPet();
|
||||
Pet pet2 = createPet();
|
||||
|
||||
final CountDownLatch addLatch = new CountDownLatch(2);
|
||||
final TestApiCallback<Void> addCallback1 = new TestApiCallback<Void>(addLatch);
|
||||
final TestApiCallback<Void> addCallback2 = new TestApiCallback<Void>(addLatch);
|
||||
|
||||
// Make 2 simultaneous calls
|
||||
api.addPetAsync(pet1, addCallback1);
|
||||
api.addPetAsync(pet2, addCallback2);
|
||||
|
||||
// wait for both asynchronous calls to finish (at most 10 seconds)
|
||||
assertTrue(addLatch.await(10, TimeUnit.SECONDS));
|
||||
|
||||
assertTrue(addCallback1.isDone());
|
||||
assertTrue(addCallback2.isDone());
|
||||
|
||||
if (!addCallback1.isSuccess()) throw addCallback1.getException();
|
||||
if (!addCallback2.isSuccess()) throw addCallback2.getException();
|
||||
|
||||
assertValidProgress(addCallback1.getUploadProgress());
|
||||
assertValidProgress(addCallback2.getUploadProgress());
|
||||
|
||||
final CountDownLatch getLatch = new CountDownLatch(3);
|
||||
final TestApiCallback<Pet> getCallback1 = new TestApiCallback<Pet>(getLatch);
|
||||
final TestApiCallback<Pet> getCallback2 = new TestApiCallback<Pet>(getLatch);
|
||||
final TestApiCallback<Pet> getCallback3 = new TestApiCallback<Pet>(getLatch);
|
||||
|
||||
api.getPetByIdAsync(pet1.getId(), getCallback1);
|
||||
api.getPetByIdAsync(pet2.getId(), getCallback2);
|
||||
// Get nonexistent pet
|
||||
api.getPetByIdAsync(-10000L, getCallback3);
|
||||
|
||||
// wait for all asynchronous calls to finish (at most 10 seconds)
|
||||
assertTrue(getLatch.await(10, TimeUnit.SECONDS));
|
||||
|
||||
assertTrue(getCallback1.isDone());
|
||||
assertTrue(getCallback2.isDone());
|
||||
assertTrue(getCallback3.isDone());
|
||||
|
||||
if (!getCallback1.isSuccess()) throw getCallback1.getException();
|
||||
if (!getCallback2.isSuccess()) throw getCallback2.getException();
|
||||
|
||||
assertPetMatches(pet1, getCallback1.getResult());
|
||||
assertPetMatches(pet2, getCallback2.getResult());
|
||||
|
||||
assertValidProgress(getCallback1.getDownloadProgress());
|
||||
assertValidProgress(getCallback2.getDownloadProgress());
|
||||
|
||||
// Last callback should fail with ApiException
|
||||
assertFalse(getCallback3.isSuccess());
|
||||
final ApiException exception = getCallback3.getException();
|
||||
assertNotNull(exception);
|
||||
assertEquals(404, exception.getCode());
|
||||
api.deletePet(pet1.getId(), null);
|
||||
api.deletePet(pet2.getId(), null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdatePet() throws Exception {
|
||||
Pet pet = createPet();
|
||||
api.addPet(pet);
|
||||
pet.setName("programmer");
|
||||
|
||||
api.updatePet(pet);
|
||||
|
||||
Pet fetched = api.getPetById(pet.getId());
|
||||
assertPetMatches(pet, fetched);
|
||||
api.deletePet(pet.getId(), null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindPetsByStatus() throws Exception {
|
||||
assertEquals(basePath, api.getApiClient().getBasePath());
|
||||
Pet pet = createPet();
|
||||
api.addPet(pet);
|
||||
pet.setName("programmer");
|
||||
pet.setStatus(Pet.StatusEnum.PENDING);
|
||||
api.updatePet(pet);
|
||||
|
||||
List<Pet> pets = api.findPetsByStatus(Arrays.asList("pending"));
|
||||
assertNotNull(pets);
|
||||
|
||||
boolean found = false;
|
||||
for (Pet fetched : pets) {
|
||||
if (fetched.getId().equals(pet.getId())) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
assertTrue(found);
|
||||
|
||||
api.deletePet(pet.getId(), null);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void testFindPetsByTags() throws Exception {
|
||||
Pet pet = createPet();
|
||||
pet.setName("monster");
|
||||
pet.setStatus(Pet.StatusEnum.AVAILABLE);
|
||||
|
||||
List<org.openapitools.client.model.Tag> tags = new ArrayList<org.openapitools.client.model.Tag>();
|
||||
org.openapitools.client.model.Tag tag1 = new org.openapitools.client.model.Tag();
|
||||
tag1.setName("friendly");
|
||||
tags.add(tag1);
|
||||
pet.setTags(tags);
|
||||
|
||||
api.updatePet(pet);
|
||||
|
||||
List<Pet> pets = api.findPetsByTags((Arrays.asList("friendly")));
|
||||
assertNotNull(pets);
|
||||
|
||||
boolean found = false;
|
||||
for (Pet fetched : pets) {
|
||||
if (fetched.getId().equals(pet.getId())) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertTrue(found);
|
||||
|
||||
api.deletePet(pet.getId(), null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdatePetWithForm() throws Exception {
|
||||
Pet pet = createPet();
|
||||
pet.setName("frank");
|
||||
api.addPet(pet);
|
||||
|
||||
Pet fetched = api.getPetById(pet.getId());
|
||||
|
||||
api.updatePetWithForm(fetched.getId(), "furt", null);
|
||||
Pet updated = api.getPetById(fetched.getId());
|
||||
|
||||
assertEquals(updated.getName(), "furt");
|
||||
api.deletePet(pet.getId(), null);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void testDeletePet() throws Exception {
|
||||
Pet pet = createPet();
|
||||
api.addPet(pet);
|
||||
|
||||
Pet fetched = api.getPetById(pet.getId());
|
||||
api.deletePet(pet.getId(), null);
|
||||
|
||||
try {
|
||||
fetched = api.getPetById(fetched.getId());
|
||||
fail("expected an error");
|
||||
} catch (ApiException e) {
|
||||
LOG.info("Code: {}. Message: {}", e.getCode(), e.getMessage());
|
||||
assertEquals(404, e.getCode());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploadFile() throws Exception {
|
||||
Pet pet = createPet();
|
||||
api.addPet(pet);
|
||||
|
||||
File file = new File("hello.txt");
|
||||
BufferedWriter writer = new BufferedWriter(new FileWriter(file));
|
||||
writer.write("Hello world!");
|
||||
writer.close();
|
||||
|
||||
api.uploadFile(pet.getId(), "a test file", new File(file.getAbsolutePath()));
|
||||
api.deletePet(pet.getId(), null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsAndHashCode() {
|
||||
Pet pet1 = new Pet();
|
||||
Pet pet2 = new Pet();
|
||||
assertTrue(pet1.equals(pet2));
|
||||
assertTrue(pet2.equals(pet1));
|
||||
assertTrue(pet1.hashCode() == pet2.hashCode());
|
||||
assertTrue(pet1.equals(pet1));
|
||||
assertTrue(pet1.hashCode() == pet1.hashCode());
|
||||
|
||||
pet2.setName("really-happy");
|
||||
pet2.setPhotoUrls(
|
||||
(Arrays.asList("http://foo.bar.com/1", "http://foo.bar.com/2")));
|
||||
assertFalse(pet1.equals(pet2));
|
||||
assertFalse(pet2.equals(pet1));
|
||||
assertFalse(pet1.hashCode() == (pet2.hashCode()));
|
||||
assertTrue(pet2.equals(pet2));
|
||||
assertTrue(pet2.hashCode() == pet2.hashCode());
|
||||
|
||||
pet1.setName("really-happy");
|
||||
pet1.setPhotoUrls(
|
||||
(Arrays.asList("http://foo.bar.com/1", "http://foo.bar.com/2")));
|
||||
assertTrue(pet1.equals(pet2));
|
||||
assertTrue(pet2.equals(pet1));
|
||||
assertTrue(pet1.hashCode() == pet2.hashCode());
|
||||
assertTrue(pet1.equals(pet1));
|
||||
assertTrue(pet1.hashCode() == pet1.hashCode());
|
||||
}
|
||||
|
||||
private Pet createPet() {
|
||||
Pet pet = new Pet();
|
||||
pet.setId(ThreadLocalRandom.current().nextLong(Long.MAX_VALUE));
|
||||
pet.setName("gorilla");
|
||||
|
||||
Category category = new Category();
|
||||
category.setName("really-happy");
|
||||
|
||||
pet.setCategory(category);
|
||||
pet.setStatus(Pet.StatusEnum.AVAILABLE);
|
||||
List<String> photos =
|
||||
(Arrays.asList("http://foo.bar.com/1", "http://foo.bar.com/2"));
|
||||
pet.setPhotoUrls(photos);
|
||||
|
||||
return pet;
|
||||
}
|
||||
|
||||
private String serializeJson(Object o, ApiClient apiClient) {
|
||||
return apiClient.getJSON().serialize(o);
|
||||
}
|
||||
|
||||
private <T> T deserializeJson(String json, Type type, ApiClient apiClient) {
|
||||
return (T) apiClient.getJSON().deserialize(json, type);
|
||||
}
|
||||
|
||||
private void assertPetMatches(Pet expected, Pet actual) {
|
||||
assertNotNull(actual);
|
||||
assertEquals(expected.getId(), actual.getId());
|
||||
assertNotNull(actual.getCategory());
|
||||
assertEquals(expected.getCategory().getName(), actual.getCategory().getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the given upload/download progress list satisfies the following constraints:
|
||||
*
|
||||
* <p>- List is not empty - Byte count should be nondecreasing - The last element, and only the
|
||||
* last element, should have done=true
|
||||
*/
|
||||
private void assertValidProgress(List<Progress> progressList) {
|
||||
assertFalse(progressList.isEmpty());
|
||||
|
||||
Progress prev = null;
|
||||
int index = 0;
|
||||
for (Progress progress : progressList) {
|
||||
if (prev != null) {
|
||||
if (prev.done || prev.bytes > progress.bytes) {
|
||||
fail("Progress list out of order at index " + index + ": " + progressList);
|
||||
}
|
||||
}
|
||||
prev = progress;
|
||||
index += 1;
|
||||
}
|
||||
|
||||
if (!prev.done) {
|
||||
fail("Last progress item should have done=true: " + progressList);
|
||||
}
|
||||
}
|
||||
|
||||
private static class TestApiCallback<T> implements ApiCallback<T> {
|
||||
|
||||
private final CountDownLatch latch;
|
||||
private final ConcurrentLinkedQueue<Progress> uploadProgress =
|
||||
new ConcurrentLinkedQueue<Progress>();
|
||||
private final ConcurrentLinkedQueue<Progress> downloadProgress =
|
||||
new ConcurrentLinkedQueue<Progress>();
|
||||
|
||||
private boolean done;
|
||||
private boolean success;
|
||||
private ApiException exception;
|
||||
private T result;
|
||||
|
||||
public TestApiCallback(CountDownLatch latch) {
|
||||
this.latch = latch;
|
||||
this.done = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(
|
||||
ApiException e, int statusCode, Map<String, List<String>> responseHeaders) {
|
||||
exception = e;
|
||||
this.done = true;
|
||||
this.success = false;
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(T result, int statusCode, Map<String, List<String>> responseHeaders) {
|
||||
this.result = result;
|
||||
this.done = true;
|
||||
this.success = true;
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUploadProgress(long bytesWritten, long contentLength, boolean done) {
|
||||
uploadProgress.add(new Progress(bytesWritten, contentLength, done));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadProgress(long bytesRead, long contentLength, boolean done) {
|
||||
downloadProgress.add(new Progress(bytesRead, contentLength, done));
|
||||
}
|
||||
|
||||
public boolean isDone() {
|
||||
return done;
|
||||
}
|
||||
|
||||
public boolean isSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
public ApiException getException() {
|
||||
return exception;
|
||||
}
|
||||
|
||||
public T getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<Progress> getUploadProgress() {
|
||||
return new ArrayList<Progress>(uploadProgress);
|
||||
}
|
||||
|
||||
public List<Progress> getDownloadProgress() {
|
||||
return new ArrayList<Progress>(downloadProgress);
|
||||
}
|
||||
}
|
||||
|
||||
private static class Progress {
|
||||
public final long bytes;
|
||||
public final long contentLength;
|
||||
public final boolean done;
|
||||
|
||||
public Progress(long bytes, long contentLength, boolean done) {
|
||||
this.bytes = bytes;
|
||||
this.contentLength = contentLength;
|
||||
this.done = done;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "<Progress " + bytes + " " + contentLength + " " + done + ">";
|
||||
}
|
||||
}
|
||||
}
|
@ -2,30 +2,24 @@
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package org.openapitools.client.api;
|
||||
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.model.Order;
|
||||
|
||||
import java.util.Map;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.model.Order;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* API tests for StoreApi
|
||||
*/
|
||||
/** API tests for StoreApi */
|
||||
@Disabled
|
||||
public class StoreApiTest {
|
||||
|
||||
@ -34,7 +28,8 @@ public class StoreApiTest {
|
||||
/**
|
||||
* Delete purchase order by ID
|
||||
*
|
||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
* <p>For valid response try integer IDs with value < 1000. Anything above 1000 or
|
||||
* nonintegers will generate API errors
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
*/
|
||||
@ -42,26 +37,29 @@ public class StoreApiTest {
|
||||
public void deleteOrderTest() throws ApiException {
|
||||
String orderId = null;
|
||||
api.deleteOrder(orderId);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns pet inventories by status
|
||||
*
|
||||
* Returns a map of status codes to quantities
|
||||
* <p>Returns a map of status codes to quantities
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void getInventoryTest() throws ApiException {
|
||||
Map<String, Integer> response = api.getInventory();
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Find purchase order by ID
|
||||
*
|
||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions
|
||||
* <p>For valid response try integer IDs with value <= 5 or > 10. Other values will
|
||||
* generated exceptions
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
*/
|
||||
@ -69,21 +67,20 @@ public class StoreApiTest {
|
||||
public void getOrderByIdTest() throws ApiException {
|
||||
Long orderId = null;
|
||||
Order response = api.getOrderById(orderId);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Place an order for a pet
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void placeOrderTest() throws ApiException {
|
||||
Order order = null;
|
||||
Order response = api.placeOrder(order);
|
||||
Order body = null;
|
||||
Order response = api.placeOrder(body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,31 +2,24 @@
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package org.openapitools.client.api;
|
||||
|
||||
import org.openapitools.client.ApiException;
|
||||
import java.time.OffsetDateTime;
|
||||
import org.openapitools.client.model.User;
|
||||
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.model.User;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* API tests for UserApi
|
||||
*/
|
||||
/** API tests for UserApi */
|
||||
@Disabled
|
||||
public class UserApiTest {
|
||||
|
||||
@ -35,49 +28,48 @@ public class UserApiTest {
|
||||
/**
|
||||
* Create user
|
||||
*
|
||||
* This can only be done by the logged in user.
|
||||
* <p>This can only be done by the logged in user.
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void createUserTest() throws ApiException {
|
||||
User user = null;
|
||||
api.createUser(user);
|
||||
User body = null;
|
||||
api.createUser(body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void createUsersWithArrayInputTest() throws ApiException {
|
||||
List<User> user = null;
|
||||
api.createUsersWithArrayInput(user);
|
||||
List<User> body = null;
|
||||
api.createUsersWithArrayInput(body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void createUsersWithListInputTest() throws ApiException {
|
||||
List<User> user = null;
|
||||
api.createUsersWithListInput(user);
|
||||
List<User> body = null;
|
||||
api.createUsersWithListInput(body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete user
|
||||
*
|
||||
* This can only be done by the logged in user.
|
||||
* <p>This can only be done by the logged in user.
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
*/
|
||||
@ -85,28 +77,26 @@ public class UserApiTest {
|
||||
public void deleteUserTest() throws ApiException {
|
||||
String username = null;
|
||||
api.deleteUser(username);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user by user name
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void getUserByNameTest() throws ApiException {
|
||||
String username = null;
|
||||
User response = api.getUserByName(username);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs user into the system
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
@ -114,35 +104,35 @@ public class UserApiTest {
|
||||
String username = null;
|
||||
String password = null;
|
||||
String response = api.loginUser(username, password);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs out current logged in user session
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void logoutUserTest() throws ApiException {
|
||||
api.logoutUser();
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Updated user
|
||||
*
|
||||
* This can only be done by the logged in user.
|
||||
* <p>This can only be done by the logged in user.
|
||||
*
|
||||
* @throws ApiException if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void updateUserTest() throws ApiException {
|
||||
String username = null;
|
||||
User user = null;
|
||||
api.updateUser(username, user);
|
||||
User body = null;
|
||||
api.updateUser(username, body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,119 @@
|
||||
package org.openapitools.client.auth;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.Pair;
|
||||
|
||||
public class ApiKeyAuthTest {
|
||||
@Test
|
||||
public void testApplyToParamsInQuery() throws ApiException {
|
||||
List<Pair> queryParams = new ArrayList<Pair>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
Map<String, String> cookieParams = new HashMap<String, String>();
|
||||
|
||||
ApiKeyAuth auth = new ApiKeyAuth("query", "api_key");
|
||||
auth.setApiKey("my-api-key");
|
||||
auth.applyToParams(queryParams, headerParams, cookieParams, null, null, null);
|
||||
|
||||
assertEquals(1, queryParams.size());
|
||||
for (Pair queryParam : queryParams) {
|
||||
assertEquals("my-api-key", queryParam.getValue());
|
||||
}
|
||||
|
||||
// no changes to header or cookie parameters
|
||||
assertEquals(0, headerParams.size());
|
||||
assertEquals(0, cookieParams.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testApplyToParamsInQueryWithNullValue() throws ApiException {
|
||||
List<Pair> queryParams = new ArrayList<Pair>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
Map<String, String> cookieParams = new HashMap<String, String>();
|
||||
|
||||
ApiKeyAuth auth = new ApiKeyAuth("query", "api_key");
|
||||
auth.setApiKey(null);
|
||||
auth.applyToParams(queryParams, headerParams, cookieParams, null, null, null);
|
||||
|
||||
// no changes to parameters
|
||||
assertEquals(0, queryParams.size());
|
||||
assertEquals(0, headerParams.size());
|
||||
assertEquals(0, cookieParams.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testApplyToParamsInHeaderWithPrefix() throws ApiException {
|
||||
List<Pair> queryParams = new ArrayList<Pair>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
Map<String, String> cookieParams = new HashMap<String, String>();
|
||||
|
||||
ApiKeyAuth auth = new ApiKeyAuth("header", "X-API-TOKEN");
|
||||
auth.setApiKey("my-api-token");
|
||||
auth.setApiKeyPrefix("Token");
|
||||
auth.applyToParams(queryParams, headerParams, cookieParams, null, null, null);
|
||||
|
||||
// no changes to query or cookie parameters
|
||||
assertEquals(0, queryParams.size());
|
||||
assertEquals(0, cookieParams.size());
|
||||
assertEquals(1, headerParams.size());
|
||||
assertEquals("Token my-api-token", headerParams.get("X-API-TOKEN"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testApplyToParamsInHeaderWithNullValue() throws ApiException {
|
||||
List<Pair> queryParams = new ArrayList<Pair>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
Map<String, String> cookieParams = new HashMap<String, String>();
|
||||
|
||||
ApiKeyAuth auth = new ApiKeyAuth("header", "X-API-TOKEN");
|
||||
auth.setApiKey(null);
|
||||
auth.setApiKeyPrefix("Token");
|
||||
auth.applyToParams(queryParams, headerParams, cookieParams, null, null, null);
|
||||
|
||||
// no changes to parameters
|
||||
assertEquals(0, queryParams.size());
|
||||
assertEquals(0, cookieParams.size());
|
||||
assertEquals(0, headerParams.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testApplyToParamsInCookieWithPrefix() throws ApiException {
|
||||
List<Pair> queryParams = new ArrayList<Pair>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
Map<String, String> cookieParams = new HashMap<String, String>();
|
||||
|
||||
ApiKeyAuth auth = new ApiKeyAuth("cookie", "X-API-TOKEN");
|
||||
auth.setApiKey("my-api-token");
|
||||
auth.setApiKeyPrefix("Token");
|
||||
auth.applyToParams(queryParams, headerParams, cookieParams, null, null, null);
|
||||
|
||||
// no changes to query or header parameters
|
||||
assertEquals(0, queryParams.size());
|
||||
assertEquals(0, headerParams.size());
|
||||
assertEquals(1, cookieParams.size());
|
||||
assertEquals("Token my-api-token", cookieParams.get("X-API-TOKEN"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testApplyToParamsInCookieWithNullValue() throws ApiException {
|
||||
List<Pair> queryParams = new ArrayList<Pair>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
Map<String, String> cookieParams = new HashMap<String, String>();
|
||||
|
||||
ApiKeyAuth auth = new ApiKeyAuth("cookie", "X-API-TOKEN");
|
||||
auth.setApiKey(null);
|
||||
auth.setApiKeyPrefix("Token");
|
||||
auth.applyToParams(queryParams, headerParams, cookieParams, null, null, null);
|
||||
|
||||
// no changes to parameters
|
||||
assertEquals(0, queryParams.size());
|
||||
assertEquals(0, cookieParams.size());
|
||||
assertEquals(0, headerParams.size());
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package org.openapitools.client.auth;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.Pair;
|
||||
|
||||
public class HttpBasicAuthTest {
|
||||
HttpBasicAuth auth = null;
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
auth = new HttpBasicAuth();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testApplyToParams() throws ApiException {
|
||||
List<Pair> queryParams = new ArrayList<Pair>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
Map<String, String> cookieParams = new HashMap<String, String>();
|
||||
|
||||
auth.setUsername("my-username");
|
||||
auth.setPassword("my-password");
|
||||
auth.applyToParams(queryParams, headerParams, cookieParams, null, null, null);
|
||||
|
||||
// no changes to query or cookie parameters
|
||||
assertEquals(0, queryParams.size());
|
||||
assertEquals(0, cookieParams.size());
|
||||
assertEquals(1, headerParams.size());
|
||||
// the string below is base64-encoded result of "my-username:my-password" with the "Basic "
|
||||
// prefix
|
||||
String expected = "Basic bXktdXNlcm5hbWU6bXktcGFzc3dvcmQ=";
|
||||
assertEquals(expected, headerParams.get("Authorization"));
|
||||
|
||||
// null username should be treated as empty string
|
||||
auth.setUsername(null);
|
||||
auth.applyToParams(queryParams, headerParams, cookieParams, null, null, null);
|
||||
// the string below is base64-encoded result of ":my-password" with the "Basic " prefix
|
||||
expected = "Basic Om15LXBhc3N3b3Jk";
|
||||
assertEquals(expected, headerParams.get("Authorization"));
|
||||
|
||||
// null password should be treated as empty string
|
||||
auth.setUsername("my-username");
|
||||
auth.setPassword(null);
|
||||
auth.applyToParams(queryParams, headerParams, cookieParams, null, null, null);
|
||||
// the string below is base64-encoded result of "my-username:" with the "Basic " prefix
|
||||
expected = "Basic bXktdXNlcm5hbWU6";
|
||||
assertEquals(expected, headerParams.get("Authorization"));
|
||||
|
||||
// null username and password should be ignored
|
||||
queryParams = new ArrayList<Pair>();
|
||||
headerParams = new HashMap<String, String>();
|
||||
auth.setUsername(null);
|
||||
auth.setPassword(null);
|
||||
auth.applyToParams(queryParams, headerParams, cookieParams, null, null, null);
|
||||
// no changes to parameters
|
||||
assertEquals(0, queryParams.size());
|
||||
assertEquals(0, headerParams.size());
|
||||
}
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
package org.openapitools.client.auth;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import okhttp3.*;
|
||||
import okhttp3.Interceptor.Chain;
|
||||
import okhttp3.Response.Builder;
|
||||
import org.apache.commons.lang3.reflect.FieldUtils;
|
||||
import org.apache.oltu.oauth2.client.OAuthClient;
|
||||
import org.apache.oltu.oauth2.client.request.OAuthClientRequest;
|
||||
import org.apache.oltu.oauth2.client.response.OAuthJSONAccessTokenResponse;
|
||||
import org.apache.oltu.oauth2.common.exception.OAuthProblemException;
|
||||
import org.apache.oltu.oauth2.common.exception.OAuthSystemException;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
public class RetryingOAuthTest {
|
||||
|
||||
private RetryingOAuth oauth;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
oauth =
|
||||
new RetryingOAuth(
|
||||
"_clientId",
|
||||
"_clientSecret",
|
||||
OAuthFlow.ACCESS_CODE,
|
||||
"https://token.example.com",
|
||||
Collections.<String, String>emptyMap());
|
||||
oauth.setAccessToken("expired-access-token");
|
||||
FieldUtils.writeField(oauth, "oAuthClient", mockOAuthClient(), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSingleRequestUnauthorized() throws Exception {
|
||||
Response response = oauth.intercept(mockChain());
|
||||
assertEquals(HttpURLConnection.HTTP_OK, response.code());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTwoConcurrentRequestsUnauthorized() throws Exception {
|
||||
|
||||
Callable<Response> callable =
|
||||
new Callable<Response>() {
|
||||
@Override
|
||||
public Response call() throws Exception {
|
||||
return oauth.intercept(mockChain());
|
||||
}
|
||||
};
|
||||
ExecutorService executor = Executors.newFixedThreadPool(2);
|
||||
try {
|
||||
Future<Response> response1 = executor.submit(callable);
|
||||
Future<Response> response2 = executor.submit(callable);
|
||||
|
||||
assertEquals(HttpURLConnection.HTTP_OK, response1.get().code());
|
||||
assertEquals(HttpURLConnection.HTTP_OK, response2.get().code());
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
private OAuthClient mockOAuthClient() throws OAuthProblemException, OAuthSystemException {
|
||||
OAuthJSONAccessTokenResponse response = mock(OAuthJSONAccessTokenResponse.class);
|
||||
when(response.getAccessToken())
|
||||
.thenAnswer(
|
||||
new Answer<String>() {
|
||||
@Override
|
||||
public String answer(InvocationOnMock invocation) throws Throwable {
|
||||
// sleep ensures that the bug is triggered.
|
||||
Thread.sleep(1000);
|
||||
return "new-access-token";
|
||||
}
|
||||
});
|
||||
|
||||
OAuthClient client = mock(OAuthClient.class);
|
||||
when(client.accessToken(any(OAuthClientRequest.class))).thenReturn(response);
|
||||
return client;
|
||||
}
|
||||
|
||||
private Chain mockChain() throws IOException {
|
||||
Chain chain = mock(Chain.class);
|
||||
|
||||
final Request request = new Request.Builder().url("https://api.example.com").build();
|
||||
when(chain.request()).thenReturn(request);
|
||||
|
||||
when(chain.proceed(any(Request.class)))
|
||||
.thenAnswer(
|
||||
new Answer<Response>() {
|
||||
@Override
|
||||
public Response answer(InvocationOnMock inv) {
|
||||
Request r = inv.getArgument(0);
|
||||
int responseCode =
|
||||
"Bearer new-access-token".equals(r.header("Authorization"))
|
||||
? HttpURLConnection.HTTP_OK
|
||||
: HttpURLConnection.HTTP_UNAUTHORIZED;
|
||||
return new Builder()
|
||||
.protocol(Protocol.HTTP_1_0)
|
||||
.message("sup")
|
||||
.request(request)
|
||||
.body(
|
||||
ResponseBody.create(
|
||||
new byte[0],
|
||||
MediaType.get("application/test")))
|
||||
.code(responseCode)
|
||||
.build();
|
||||
}
|
||||
});
|
||||
|
||||
return chain;
|
||||
}
|
||||
}
|
@ -19,13 +19,13 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for AdditionalPropertiesClass
|
||||
*/
|
||||
|
@ -19,10 +19,12 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.openapitools.client.model.Cat;
|
||||
import org.openapitools.client.model.Dog;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for Animal
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for AppleReq
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for Apple
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for ArrayOfInlineAllOfArrayAllofDogPropertyInner
|
||||
*/
|
||||
|
@ -20,12 +20,12 @@ import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.openapitools.client.model.ArrayOfInlineAllOfArrayAllofDogPropertyInner;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for ArrayOfInlineAllOf
|
||||
*/
|
||||
|
@ -21,11 +21,11 @@ import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for ArrayOfNumberOnly
|
||||
*/
|
||||
|
@ -20,12 +20,12 @@ import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.openapitools.client.model.ReadOnlyFirst;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for ArrayTest
|
||||
*/
|
||||
|
@ -20,10 +20,10 @@ import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for BananaReq
|
||||
*/
|
||||
|
@ -20,10 +20,10 @@ import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for Banana
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for BasquePig
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for Capitalization
|
||||
*/
|
||||
|
@ -19,11 +19,11 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.openapitools.client.model.Animal;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for Cat
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for Category
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for ClassModel
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for Client
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for ComplexQuadrilateral
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for DanishPig
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for DeprecatedObject
|
||||
*/
|
||||
|
@ -19,11 +19,11 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.openapitools.client.model.Animal;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for Dog
|
||||
*/
|
||||
|
@ -20,7 +20,6 @@ import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.openapitools.client.model.Fruit;
|
||||
import org.openapitools.client.model.NullableShape;
|
||||
@ -30,6 +29,7 @@ import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for Drawing
|
||||
*/
|
||||
|
@ -20,11 +20,11 @@ import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for EnumArrays
|
||||
*/
|
||||
|
@ -17,6 +17,7 @@ import com.google.gson.annotations.SerializedName;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for EnumClass
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for EnumStringDiscriminator
|
||||
*/
|
||||
|
@ -19,7 +19,6 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.openapitools.client.model.OuterEnum;
|
||||
import org.openapitools.client.model.OuterEnumDefaultValue;
|
||||
import org.openapitools.client.model.OuterEnumInteger;
|
||||
@ -28,6 +27,7 @@ import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for EnumTest
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for EquilateralTriangle
|
||||
*/
|
||||
|
@ -20,12 +20,12 @@ import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.openapitools.client.model.ModelFile;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for FileSchemaTestClass
|
||||
*/
|
||||
|
@ -19,11 +19,11 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.openapitools.client.model.Foo;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for FooGetDefaultResponse
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for Foo
|
||||
*/
|
||||
|
@ -23,11 +23,11 @@ import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for FormatTest
|
||||
*/
|
||||
|
@ -20,12 +20,12 @@ import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import org.openapitools.client.model.AppleReq;
|
||||
import org.openapitools.client.model.BananaReq;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for FruitReq
|
||||
*/
|
||||
|
@ -20,12 +20,12 @@ import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import org.openapitools.client.model.Apple;
|
||||
import org.openapitools.client.model.Banana;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for Fruit
|
||||
*/
|
||||
|
@ -20,12 +20,12 @@ import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import org.openapitools.client.model.Apple;
|
||||
import org.openapitools.client.model.Banana;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for GmFruit
|
||||
*/
|
||||
|
@ -19,10 +19,11 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.openapitools.client.model.ParentPet;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for GrandparentAnimal
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for HasOnlyReadOnly
|
||||
*/
|
||||
|
@ -19,11 +19,11 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for HealthCheckResult
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for IsoscelesTriangle
|
||||
*/
|
||||
|
@ -19,13 +19,13 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.openapitools.client.model.Pig;
|
||||
import org.openapitools.client.model.Whale;
|
||||
import org.openapitools.client.model.Zebra;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for Mammal
|
||||
*/
|
||||
|
@ -19,12 +19,12 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for MapTest
|
||||
*/
|
||||
|
@ -20,7 +20,6 @@ import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@ -28,6 +27,7 @@ import org.openapitools.client.model.Animal;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for MixedPropertiesAndAdditionalPropertiesClass
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for Model200Response
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for ModelApiResponse
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for ModelFile
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for ModelList
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for ModelReturn
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for Name
|
||||
*/
|
||||
|
@ -23,7 +23,6 @@ import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -31,6 +30,7 @@ import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for NullableClass
|
||||
*/
|
||||
|
@ -19,12 +19,12 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.openapitools.client.model.Quadrilateral;
|
||||
import org.openapitools.client.model.Triangle;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for NullableShape
|
||||
*/
|
||||
|
@ -20,10 +20,10 @@ import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for NumberOnly
|
||||
*/
|
||||
|
@ -21,12 +21,12 @@ import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.openapitools.client.model.DeprecatedObject;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for ObjectWithDeprecatedFields
|
||||
*/
|
||||
|
@ -20,10 +20,10 @@ import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for Order
|
||||
*/
|
||||
|
@ -20,10 +20,10 @@ import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for OuterComposite
|
||||
*/
|
||||
|
@ -17,6 +17,7 @@ import com.google.gson.annotations.SerializedName;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for OuterEnumDefaultValue
|
||||
*/
|
||||
|
@ -17,6 +17,7 @@ import com.google.gson.annotations.SerializedName;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for OuterEnumIntegerDefaultValue
|
||||
*/
|
||||
|
@ -17,6 +17,7 @@ import com.google.gson.annotations.SerializedName;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for OuterEnumInteger
|
||||
*/
|
||||
|
@ -17,6 +17,7 @@ import com.google.gson.annotations.SerializedName;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for OuterEnum
|
||||
*/
|
||||
|
@ -19,11 +19,11 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.openapitools.client.model.GrandparentAnimal;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for ParentPet
|
||||
*/
|
||||
|
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package org.openapitools.client.model;
|
||||
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.openapitools.client.model.Category;
|
||||
import org.openapitools.client.model.Tag;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for Pet
|
||||
*/
|
||||
public class PetTest {
|
||||
private final Pet model = new Pet();
|
||||
|
||||
/**
|
||||
* Model tests for Pet
|
||||
*/
|
||||
@Test
|
||||
public void testPet() {
|
||||
// TODO: test Pet
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'id'
|
||||
*/
|
||||
@Test
|
||||
public void idTest() {
|
||||
// TODO: test id
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'category'
|
||||
*/
|
||||
@Test
|
||||
public void categoryTest() {
|
||||
// TODO: test category
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'name'
|
||||
*/
|
||||
@Test
|
||||
public void nameTest() {
|
||||
// TODO: test name
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'photoUrls'
|
||||
*/
|
||||
@Test
|
||||
public void photoUrlsTest() {
|
||||
// TODO: test photoUrls
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'tags'
|
||||
*/
|
||||
@Test
|
||||
public void tagsTest() {
|
||||
// TODO: test tags
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'status'
|
||||
*/
|
||||
@Test
|
||||
public void statusTest() {
|
||||
// TODO: test status
|
||||
}
|
||||
|
||||
}
|
@ -20,13 +20,13 @@ import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
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.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for PetWithRequiredTags
|
||||
*/
|
||||
|
@ -19,12 +19,12 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.openapitools.client.model.BasquePig;
|
||||
import org.openapitools.client.model.DanishPig;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for Pig
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for QuadrilateralInterface
|
||||
*/
|
||||
|
@ -19,12 +19,12 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.openapitools.client.model.ComplexQuadrilateral;
|
||||
import org.openapitools.client.model.SimpleQuadrilateral;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for Quadrilateral
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for ReadOnlyFirst
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for ScaleneTriangle
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for ShapeInterface
|
||||
*/
|
||||
|
@ -19,12 +19,12 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.openapitools.client.model.Quadrilateral;
|
||||
import org.openapitools.client.model.Triangle;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for ShapeOrNull
|
||||
*/
|
||||
|
@ -19,12 +19,12 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.openapitools.client.model.Quadrilateral;
|
||||
import org.openapitools.client.model.Triangle;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for Shape
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for SimpleQuadrilateral
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for SpecialModelName
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for Tag
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for TriangleInterface
|
||||
*/
|
||||
|
@ -19,13 +19,13 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.openapitools.client.model.EquilateralTriangle;
|
||||
import org.openapitools.client.model.IsoscelesTriangle;
|
||||
import org.openapitools.client.model.ScaleneTriangle;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for Triangle
|
||||
*/
|
||||
|
@ -19,11 +19,11 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for User
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for Whale
|
||||
*/
|
||||
|
@ -19,10 +19,10 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for Zebra
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user