Skip to content

Commit 57889b4

Browse files
committed
add one sample to CircleCI, try fix tests
1 parent e5ca6cd commit 57889b4

File tree

9 files changed

+41
-34
lines changed

9 files changed

+41
-34
lines changed

CI/circle_parallel.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ else
121121
(cd samples/client/others/java/okhttp-gson-streaming && mvn integration-test)
122122
(cd samples/client/petstore/java/okhttp-gson && mvn integration-test)
123123
(cd samples/client/petstore/java/okhttp-gson-3.1 && mvn integration-test)
124+
(cd samples/client/petstore/java/okhttp-gson-dynamicOperations && mvn integration-test)
124125
(cd samples/client/petstore/java/resteasy && mvn integration-test)
125126
(cd samples/client/petstore/java-micronaut-client && mvn integration-test)
126127
(cd samples/client/petstore/java/apache-httpclient && mvn integration-test)

bin/utils/test_file_list.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
- filename: "samples/client/echo_api/java/resteasy/src/test/java/org/openapitools/client/api/BodyApiTest.java"
2525
sha256: 04715cabbe9bd27ff98dd56e3db489ebc9ffbf98d9af104a6707b0a40ab4f8fe
2626
- filename: "samples/client/echo_api/java/resttemplate/src/test/java/org/openapitools/client/api/AuthApiTest.java"
27-
sha256: fa45f446111823f02b9c8e8d010e3c1a28fc0f00a325e674da14d0e12296ea96
27+
sha256: 38193bbad7f3eef087bc1474352e484178b14a2b8c0e0ba0cd4e4960516a14f9
2828
- filename: "samples/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/api/PetApiTest.java"
2929
sha256: 24c6a39a9d7327d397dc038c368a19c84f14ed96a69fe28d53719b3eaf0a725c
3030
- filename: "samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/api/PetApiTest.java"
@@ -36,9 +36,9 @@
3636
- filename: "samples/client/petstore/java/okhttp-gson-3.1/src/test/java/org/openapitools/client/api/PetApiTest.java"
3737
sha256: d8f7fff724f81e666daf115cc25f8347e1fda4e861aa30df0dae3fa50c91404c
3838
- filename: "samples/client/petstore/java/okhttp-gson-dynamicOperations/src/test/java/org/openapitools/client/api/PetApiTest.java"
39-
sha256: 711a242b6257b87363c59b20dcaed45f9b146e2be246339a039a5d0338ad280c
39+
sha256: 5fc397856b79562bb49082658dbc44a62f342834b1e510fe75545a7566e363af
4040
- filename: "samples/client/petstore/java/okhttp-gson-dynamicOperations/src/test/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnlyTest.java"
41-
sha256: 3a1add6f05f057c45b2ea489f619c3b455bf75e8e748fabd5487972b330ae2e6
41+
sha256: 3c41eb12d126f90392d97e3250b53ea9dce1663fb714a19339445b9da734d634
4242
- filename: "samples/client/petstore/java/resteasy/src/test/java/org/openapitools/client/api/PetApiTest.java"
4343
sha256: 68ed9228c99ecf2ff3842074242d3be7565da3b702b7f46008a5e119ef15c167
4444
- filename: "samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/test/java/org/openapitools/client/model/MySchemaNameCharactersTest.java"

samples/client/echo_api/java/resttemplate/src/test/java/org/openapitools/client/api/AuthApiTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
package org.openapitools.client.api;
1515

16+
import org.junit.jupiter.api.Assertions;
1617
import org.junit.jupiter.api.Disabled;
1718
import org.junit.jupiter.api.Test;
1819
import org.springframework.web.client.RestClientException;
@@ -61,11 +62,11 @@ void testAuthHttpBearerTest() {
6162
String response;
6263
api.getApiClient().setBearerToken("fixed token");
6364
response = api.testAuthHttpBearer();
64-
Assert.assertTrue(response.contains("Authorization: Bearer fixed token"));
65+
Assertions.assertTrue(response.contains("Authorization: Bearer fixed token"));
6566

6667
api.getApiClient().setBearerToken(() -> "dynamic token");
6768
response = api.testAuthHttpBearer();
68-
Assert.assertTrue(response.contains("Authorization: Bearer dynamic token"));
69+
Assertions.assertTrue(response.contains("Authorization: Bearer dynamic token"));
6970
}
7071

7172
}

samples/client/petstore/java/okhttp-gson-dynamicOperations/src/test/java/org/openapitools/client/ApiClientTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class ApiClientTest {
1717
ApiClient apiClient;
1818
JSON json;
1919

20-
@Before
20+
@BeforeEach
2121
public void setup() {
2222
apiClient = new ApiClient();
2323
json = apiClient.getJSON();
@@ -82,7 +82,7 @@ public void testSelectHeaderContentType() {
8282
assertEquals("text/plain", apiClient.selectHeaderContentType(contentTypes));
8383

8484
contentTypes = new String[]{};
85-
assertEquals("application/json", apiClient.selectHeaderContentType(contentTypes));
85+
assertNull(apiClient.selectHeaderContentType(contentTypes));
8686
}
8787

8888
@Test
@@ -342,8 +342,10 @@ public void testNewHttpClient() {
342342
/**
343343
* Tests the invariant that the HttpClient for the ApiClient must never be null
344344
*/
345-
@Test(expected = NullPointerException.class)
345+
@Test
346346
public void testNullHttpClient() {
347-
apiClient.setHttpClient(null);
347+
assertThrows(NullPointerException.class, () -> {
348+
apiClient.setHttpClient(null);
349+
});
348350
}
349351
}

samples/client/petstore/java/okhttp-gson-dynamicOperations/src/test/java/org/openapitools/client/JSONTest.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
import java.nio.charset.StandardCharsets;
1010
import java.text.DateFormat;
1111
import java.text.SimpleDateFormat;
12+
import java.time.ZoneId;
13+
import java.time.ZoneOffset;
14+
import java.time.format.DateTimeFormatter;
1215
import java.util.Calendar;
1316
import java.util.Date;
1417
import java.util.GregorianCalendar;
@@ -27,7 +30,7 @@ public class JSONTest {
2730
private JSON json = null;
2831
private Order order = null;
2932

30-
@Before
33+
@BeforeEach
3134
public void setup() {
3235
apiClient = new ApiClient();
3336
json = apiClient.getJSON();
@@ -127,7 +130,7 @@ public void testLocalDateTypeAdapter() {
127130
public void testDefaultDate() throws Exception {
128131
final DateTimeFormatter datetimeFormat = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
129132
final String dateStr = "2015-11-07T14:11:05.267Z";
130-
order.setShipDate(datetimeFormat.parse(dateStr, OffsetDateTime.FROM));
133+
order.setShipDate(datetimeFormat.parse(dateStr, OffsetDateTime::from));
131134

132135
String str = json.serialize(order);
133136
Type type = new TypeToken<Order>() { }.getType();
@@ -139,7 +142,7 @@ public void testDefaultDate() throws Exception {
139142
public void testCustomDate() throws Exception {
140143
final DateTimeFormatter datetimeFormat = DateTimeFormatter.ISO_OFFSET_DATE_TIME.withZone(ZoneId.of("Etc/GMT+2"));
141144
final String dateStr = "2015-11-07T14:11:05-02:00";
142-
order.setShipDate(datetimeFormat.parse(dateStr, OffsetDateTime.FROM));
145+
order.setShipDate(datetimeFormat.parse(dateStr, OffsetDateTime::from));
143146

144147
String str = json.serialize(order);
145148
Type type = new TypeToken<Order>() { }.getType();

samples/client/petstore/java/okhttp-gson-dynamicOperations/src/test/java/org/openapitools/client/api/PetApiTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class PetApiTest {
5050
// In the circle.yml file, /etc/host is configured with an entry to resolve petstore.swagger.io to 127.0.0.1
5151
private static String basePath = "http://petstore.swagger.io:80/v2";
5252

53-
@Before
53+
@BeforeEach
5454
public void setup() {
5555
// setup authentication
5656
ApiKeyAuth apiKeyAuth = (ApiKeyAuth) api.getApiClient().getAuthentication("api_key");

samples/client/petstore/java/okhttp-gson-dynamicOperations/src/test/java/org/openapitools/client/auth/ApiKeyAuthTest.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@
55
import java.util.Map;
66
import java.util.List;
77

8+
import org.openapitools.client.ApiException;
89
import org.openapitools.client.Pair;
910
import org.junit.jupiter.api.*;
10-
import static org.junit.Assert.*;
1111
import static org.junit.jupiter.api.Assertions.*;
1212

1313
public class ApiKeyAuthTest {
1414
@Test
15-
public void testApplyToParamsInQuery() {
15+
public void testApplyToParamsInQuery() throws ApiException {
1616
List<Pair> queryParams = new ArrayList<Pair>();
1717
Map<String, String> headerParams = new HashMap<String, String>();
1818
Map<String, String> cookieParams = new HashMap<String, String>();
1919

2020
ApiKeyAuth auth = new ApiKeyAuth("query", "api_key");
2121
auth.setApiKey("my-api-key");
22-
auth.applyToParams(queryParams, headerParams, cookieParams);
22+
auth.applyToParams(queryParams, headerParams, cookieParams, null, null, null);
2323

2424
assertEquals(1, queryParams.size());
2525
for (Pair queryParam : queryParams) {
@@ -32,14 +32,14 @@ public void testApplyToParamsInQuery() {
3232
}
3333

3434
@Test
35-
public void testApplyToParamsInQueryWithNullValue() {
35+
public void testApplyToParamsInQueryWithNullValue() throws ApiException {
3636
List<Pair> queryParams = new ArrayList<Pair>();
3737
Map<String, String> headerParams = new HashMap<String, String>();
3838
Map<String, String> cookieParams = new HashMap<String, String>();
3939

4040
ApiKeyAuth auth = new ApiKeyAuth("query", "api_key");
4141
auth.setApiKey(null);
42-
auth.applyToParams(queryParams, headerParams, cookieParams);
42+
auth.applyToParams(queryParams, headerParams, cookieParams, null, null, null);
4343

4444
// no changes to parameters
4545
assertEquals(0, queryParams.size());
@@ -48,15 +48,15 @@ public void testApplyToParamsInQueryWithNullValue() {
4848
}
4949

5050
@Test
51-
public void testApplyToParamsInHeaderWithPrefix() {
51+
public void testApplyToParamsInHeaderWithPrefix() throws ApiException {
5252
List<Pair> queryParams = new ArrayList<Pair>();
5353
Map<String, String> headerParams = new HashMap<String, String>();
5454
Map<String, String> cookieParams = new HashMap<String, String>();
5555

5656
ApiKeyAuth auth = new ApiKeyAuth("header", "X-API-TOKEN");
5757
auth.setApiKey("my-api-token");
5858
auth.setApiKeyPrefix("Token");
59-
auth.applyToParams(queryParams, headerParams, cookieParams);
59+
auth.applyToParams(queryParams, headerParams, cookieParams, null, null, null);
6060

6161
// no changes to query or cookie parameters
6262
assertEquals(0, queryParams.size());
@@ -66,15 +66,15 @@ public void testApplyToParamsInHeaderWithPrefix() {
6666
}
6767

6868
@Test
69-
public void testApplyToParamsInHeaderWithNullValue() {
69+
public void testApplyToParamsInHeaderWithNullValue() throws ApiException {
7070
List<Pair> queryParams = new ArrayList<Pair>();
7171
Map<String, String> headerParams = new HashMap<String, String>();
7272
Map<String, String> cookieParams = new HashMap<String, String>();
7373

7474
ApiKeyAuth auth = new ApiKeyAuth("header", "X-API-TOKEN");
7575
auth.setApiKey(null);
7676
auth.setApiKeyPrefix("Token");
77-
auth.applyToParams(queryParams, headerParams, cookieParams);
77+
auth.applyToParams(queryParams, headerParams, cookieParams, null, null, null);
7878

7979
// no changes to parameters
8080
assertEquals(0, queryParams.size());
@@ -83,15 +83,15 @@ public void testApplyToParamsInHeaderWithNullValue() {
8383
}
8484

8585
@Test
86-
public void testApplyToParamsInCookieWithPrefix() {
86+
public void testApplyToParamsInCookieWithPrefix() throws ApiException {
8787
List<Pair> queryParams = new ArrayList<Pair>();
8888
Map<String, String> headerParams = new HashMap<String, String>();
8989
Map<String, String> cookieParams = new HashMap<String, String>();
9090

9191
ApiKeyAuth auth = new ApiKeyAuth("cookie", "X-API-TOKEN");
9292
auth.setApiKey("my-api-token");
9393
auth.setApiKeyPrefix("Token");
94-
auth.applyToParams(queryParams, headerParams, cookieParams);
94+
auth.applyToParams(queryParams, headerParams, cookieParams, null, null, null);
9595

9696
// no changes to query or header parameters
9797
assertEquals(0, queryParams.size());
@@ -101,15 +101,15 @@ public void testApplyToParamsInCookieWithPrefix() {
101101
}
102102

103103
@Test
104-
public void testApplyToParamsInCookieWithNullValue() {
104+
public void testApplyToParamsInCookieWithNullValue() throws ApiException {
105105
List<Pair> queryParams = new ArrayList<Pair>();
106106
Map<String, String> headerParams = new HashMap<String, String>();
107107
Map<String, String> cookieParams = new HashMap<String, String>();
108108

109109
ApiKeyAuth auth = new ApiKeyAuth("cookie", "X-API-TOKEN");
110110
auth.setApiKey(null);
111111
auth.setApiKeyPrefix("Token");
112-
auth.applyToParams(queryParams, headerParams, cookieParams);
112+
auth.applyToParams(queryParams, headerParams, cookieParams, null, null, null);
113113

114114
// no changes to parameters
115115
assertEquals(0, queryParams.size());

samples/client/petstore/java/okhttp-gson-dynamicOperations/src/test/java/org/openapitools/client/auth/HttpBasicAuthTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.Map;
66
import java.util.List;
77

8+
import org.openapitools.client.ApiException;
89
import org.openapitools.client.Pair;
910

1011
import org.junit.jupiter.api.*;
@@ -19,14 +20,14 @@ public void setup() {
1920
}
2021

2122
@Test
22-
public void testApplyToParams() {
23+
public void testApplyToParams() throws ApiException {
2324
List<Pair> queryParams = new ArrayList<Pair>();
2425
Map<String, String> headerParams = new HashMap<String, String>();
2526
Map<String, String> cookieParams = new HashMap<String, String>();
2627

2728
auth.setUsername("my-username");
2829
auth.setPassword("my-password");
29-
auth.applyToParams(queryParams, headerParams, cookieParams);
30+
auth.applyToParams(queryParams, headerParams, cookieParams, null, null, null);
3031

3132
// no changes to query or cookie parameters
3233
assertEquals(0, queryParams.size());
@@ -38,15 +39,15 @@ public void testApplyToParams() {
3839

3940
// null username should be treated as empty string
4041
auth.setUsername(null);
41-
auth.applyToParams(queryParams, headerParams, cookieParams);
42+
auth.applyToParams(queryParams, headerParams, cookieParams, null, null, null);
4243
// the string below is base64-encoded result of ":my-password" with the "Basic " prefix
4344
expected = "Basic Om15LXBhc3N3b3Jk";
4445
assertEquals(expected, headerParams.get("Authorization"));
4546

4647
// null password should be treated as empty string
4748
auth.setUsername("my-username");
4849
auth.setPassword(null);
49-
auth.applyToParams(queryParams, headerParams, cookieParams);
50+
auth.applyToParams(queryParams, headerParams, cookieParams, null, null, null);
5051
// the string below is base64-encoded result of "my-username:" with the "Basic " prefix
5152
expected = "Basic bXktdXNlcm5hbWU6";
5253
assertEquals(expected, headerParams.get("Authorization"));
@@ -56,7 +57,7 @@ public void testApplyToParams() {
5657
headerParams = new HashMap<String, String>();
5758
auth.setUsername(null);
5859
auth.setPassword(null);
59-
auth.applyToParams(queryParams, headerParams, cookieParams);
60+
auth.applyToParams(queryParams, headerParams, cookieParams, null, null, null);
6061
// no changes to parameters
6162
assertEquals(0, queryParams.size());
6263
assertEquals(0, headerParams.size());

samples/client/petstore/java/okhttp-gson-dynamicOperations/src/test/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnlyTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@
1919
import com.google.gson.annotations.SerializedName;
2020
import com.google.gson.stream.JsonReader;
2121
import com.google.gson.stream.JsonWriter;
22-
import io.swagger.annotations.ApiModel;
23-
import io.swagger.annotations.ApiModelProperty;
2422
import java.io.IOException;
2523
import java.math.BigDecimal;
2624
import java.util.ArrayList;
2725
import java.util.List;
2826

27+
import org.junit.jupiter.api.Assertions;
2928
import org.junit.jupiter.api.Assertions.*;
3029
import org.junit.jupiter.api.Disabled;
3130
import org.junit.jupiter.api.Test;
@@ -67,7 +66,7 @@ public void arrayArrayNumberTest() {
6766
model2.setArrayArrayNumber(new ArrayList<List<BigDecimal>>());
6867
model2.getArrayArrayNumber().add(arrayArrayNumber2);
6968

70-
Assert.assertTrue(model2.equals(model));
69+
Assertions.assertTrue(model2.equals(model));
7170
}
7271

7372
}

0 commit comments

Comments
 (0)