Skip to content

Commit 37f2cd1

Browse files
authored
Bump java format in CI (#1712)
We still used version 16 in the workflow.
1 parent 8ebb0e2 commit 37f2cd1

File tree

3 files changed

+111
-56
lines changed

3 files changed

+111
-56
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
name: Run pre-commit
5757
if: github.event.action != 'closed' && github.event.pull_request.merged != true
5858
run: |
59-
wget https://github.com/google/google-java-format/releases/download/v1.15.0/google-java-format-1.15.0-all-deps.jar -O google-java-format.jar
59+
wget https://github.com/google/google-java-format/releases/download/v1.16.0/google-java-format-1.16.0-all-deps.jar -O google-java-format.jar
6060
pre-commit run --verbose --from-ref "${FROM_REF}" --to-ref "${TO_REF}" --show-diff-on-failure --color=always
6161
env:
6262
FROM_REF: ${{ github.event.pull_request.base.sha }}

src/test/java/com/datadog/api/ClientSteps.java

Lines changed: 78 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,12 @@ public void setupVersion(Scenario scenario) {
5555

5656
@Before(order = 10)
5757
public void setupClient()
58-
throws java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException,
59-
java.lang.InstantiationException, java.lang.NoSuchMethodException,
60-
java.lang.ClassNotFoundException, java.lang.NoSuchFieldException {
58+
throws java.lang.reflect.InvocationTargetException,
59+
java.lang.IllegalAccessException,
60+
java.lang.InstantiationException,
61+
java.lang.NoSuchMethodException,
62+
java.lang.ClassNotFoundException,
63+
java.lang.NoSuchFieldException {
6164
world.setupClient(apiVersion);
6265
}
6366

@@ -97,24 +100,31 @@ public void undo() {
97100

98101
@Given("an instance of {string} API")
99102
public void anInstanceOfAPI(String apiName)
100-
throws java.lang.ClassNotFoundException, java.lang.NoSuchFieldException,
101-
java.lang.InstantiationException, java.lang.IllegalAccessException,
102-
java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException {
103+
throws java.lang.ClassNotFoundException,
104+
java.lang.NoSuchFieldException,
105+
java.lang.InstantiationException,
106+
java.lang.IllegalAccessException,
107+
java.lang.NoSuchMethodException,
108+
java.lang.reflect.InvocationTargetException {
103109
world.setupAPI(apiVersion, World.toClassName(apiName));
104110
}
105111

106112
@Given("operation {string} enabled")
107113
public void operationEnabled(String operationId)
108-
throws java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException,
109-
java.lang.InstantiationException, java.lang.NoSuchMethodException,
114+
throws java.lang.reflect.InvocationTargetException,
115+
java.lang.IllegalAccessException,
116+
java.lang.InstantiationException,
117+
java.lang.NoSuchMethodException,
110118
java.lang.ClassNotFoundException {
111119
world.setUnstableOperationEnabled(apiVersion + "." + World.toMethodName(operationId));
112120
}
113121

114122
@Given("a valid \"apiKeyAuth\" key in the system")
115123
public void aValidApiKeyInTheSystem()
116-
throws java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException,
117-
java.lang.InstantiationException, java.lang.NoSuchMethodException,
124+
throws java.lang.reflect.InvocationTargetException,
125+
java.lang.IllegalAccessException,
126+
java.lang.InstantiationException,
127+
java.lang.NoSuchMethodException,
118128
java.lang.ClassNotFoundException {
119129
HashMap<String, String> secrets = new HashMap<String, String>();
120130
secrets.put("apiKeyAuth", System.getenv(TEST_API_KEY_NAME));
@@ -123,8 +133,10 @@ public void aValidApiKeyInTheSystem()
123133

124134
@Given("a valid \"appKeyAuth\" key in the system")
125135
public void aValidAppKeyInTheSystem()
126-
throws java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException,
127-
java.lang.InstantiationException, java.lang.NoSuchMethodException,
136+
throws java.lang.reflect.InvocationTargetException,
137+
java.lang.IllegalAccessException,
138+
java.lang.InstantiationException,
139+
java.lang.NoSuchMethodException,
128140
java.lang.ClassNotFoundException {
129141
HashMap<String, String> secrets = new HashMap<String, String>();
130142
secrets.put("appKeyAuth", System.getenv(TEST_APP_KEY_NAME));
@@ -133,42 +145,53 @@ public void aValidAppKeyInTheSystem()
133145

134146
@Given("new {string} request")
135147
public void newRequest(String methodName)
136-
throws java.lang.IllegalAccessException, java.lang.IllegalAccessException,
137-
java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException {
148+
throws java.lang.IllegalAccessException,
149+
java.lang.IllegalAccessException,
150+
java.lang.NoSuchMethodException,
151+
java.lang.reflect.InvocationTargetException {
138152
world.newRequest(methodName);
139153
}
140154

141155
@Given("request contains {string} parameter from {string}")
142156
public void requestContainsParameterFrom(String parameterName, String fixturePath)
143-
throws java.lang.IllegalAccessException, java.lang.NoSuchFieldException,
144-
java.lang.ClassNotFoundException, java.lang.NoSuchMethodException,
157+
throws java.lang.IllegalAccessException,
158+
java.lang.NoSuchFieldException,
159+
java.lang.ClassNotFoundException,
160+
java.lang.NoSuchMethodException,
145161
java.lang.reflect.InvocationTargetException {
146162
world.addRequestParameterFixture(parameterName, fixturePath);
147163
}
148164

149165
@Given("request contains {string} parameter with value {}")
150166
public void requestContainsParameterWithValue(String parameterName, String value)
151-
throws java.lang.IllegalAccessException, java.lang.NoSuchFieldException,
152-
java.lang.ClassNotFoundException, java.lang.NoSuchMethodException,
167+
throws java.lang.IllegalAccessException,
168+
java.lang.NoSuchFieldException,
169+
java.lang.ClassNotFoundException,
170+
java.lang.NoSuchMethodException,
153171
java.lang.reflect.InvocationTargetException,
154172
com.fasterxml.jackson.core.JsonProcessingException {
155173
world.addRequestParameter(parameterName, value);
156174
}
157175

158176
@Given("body with value {}")
159177
public void setBody(String data)
160-
throws java.lang.IllegalAccessException, java.lang.NoSuchFieldException,
161-
java.lang.ClassNotFoundException, java.lang.NoSuchMethodException,
178+
throws java.lang.IllegalAccessException,
179+
java.lang.NoSuchFieldException,
180+
java.lang.ClassNotFoundException,
181+
java.lang.NoSuchMethodException,
162182
java.lang.reflect.InvocationTargetException,
163183
com.fasterxml.jackson.core.JsonProcessingException {
164184
world.addRequestParameter("body", data);
165185
}
166186

167187
@Given("body from file {string}")
168188
public void setBodyFromFile(String filename)
169-
throws java.lang.IllegalAccessException, java.lang.NoSuchFieldException,
170-
java.lang.ClassNotFoundException, java.lang.NoSuchMethodException,
171-
java.lang.reflect.InvocationTargetException, IOException {
189+
throws java.lang.IllegalAccessException,
190+
java.lang.NoSuchFieldException,
191+
java.lang.ClassNotFoundException,
192+
java.lang.NoSuchMethodException,
193+
java.lang.reflect.InvocationTargetException,
194+
IOException {
172195
Path bodyPath =
173196
Paths.get("src/test/resources/com/datadog/api/client/" + apiVersion + "/api/" + filename);
174197
String data = new String(Files.readAllBytes(bodyPath));
@@ -177,8 +200,10 @@ public void setBodyFromFile(String filename)
177200

178201
@Then("the response status is {int} {}")
179202
public void theResponseStatusIs(Integer statusCode, String unused)
180-
throws java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException,
181-
java.lang.InstantiationException, java.lang.NoSuchMethodException,
203+
throws java.lang.reflect.InvocationTargetException,
204+
java.lang.IllegalAccessException,
205+
java.lang.InstantiationException,
206+
java.lang.NoSuchMethodException,
182207
java.lang.ClassNotFoundException {
183208
Integer responseStatusCode = (Integer) 0;
184209

@@ -195,10 +220,14 @@ public void theResponseStatusIs(Integer statusCode, String unused)
195220

196221
@Then("the response {string} is equal to {}")
197222
public void theResponseIsEqualTo(String responsePath, String value)
198-
throws java.lang.IllegalAccessException, java.lang.NoSuchFieldException,
199-
java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException,
200-
java.lang.InstantiationException, java.lang.NoSuchMethodException,
201-
java.lang.ClassNotFoundException, com.fasterxml.jackson.core.JsonProcessingException {
223+
throws java.lang.IllegalAccessException,
224+
java.lang.NoSuchFieldException,
225+
java.lang.reflect.InvocationTargetException,
226+
java.lang.IllegalAccessException,
227+
java.lang.InstantiationException,
228+
java.lang.NoSuchMethodException,
229+
java.lang.ClassNotFoundException,
230+
com.fasterxml.jackson.core.JsonProcessingException {
202231
Object responseData = world.responseClass.getMethod("getData").invoke(world.response);
203232
Object responseValue = World.lookup(responseData, responsePath);
204233
if (responseValue != null) {
@@ -215,36 +244,46 @@ public void theResponseIsEqualTo(String responsePath, String value)
215244

216245
@Then("the response {string} is false")
217246
public void theResponseIsFalse(String responsePath)
218-
throws java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException,
219-
java.lang.InstantiationException, java.lang.NoSuchMethodException,
220-
java.lang.ClassNotFoundException, java.lang.NoSuchFieldException {
247+
throws java.lang.reflect.InvocationTargetException,
248+
java.lang.IllegalAccessException,
249+
java.lang.InstantiationException,
250+
java.lang.NoSuchMethodException,
251+
java.lang.ClassNotFoundException,
252+
java.lang.NoSuchFieldException {
221253
Object responseData = world.responseClass.getMethod("getData").invoke(world.response);
222254
assertFalse((Boolean) World.lookup(responseData, responsePath));
223255
}
224256

225257
@Then("the response {string} has the same value as {string}")
226258
public void theResponseHasTheSameValueAs(String responsePath, String fixturePath)
227-
throws java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException,
228-
java.lang.InstantiationException, java.lang.NoSuchMethodException,
229-
java.lang.ClassNotFoundException, java.lang.NoSuchFieldException {
259+
throws java.lang.reflect.InvocationTargetException,
260+
java.lang.IllegalAccessException,
261+
java.lang.InstantiationException,
262+
java.lang.NoSuchMethodException,
263+
java.lang.ClassNotFoundException,
264+
java.lang.NoSuchFieldException {
230265
Object responseData = world.responseClass.getMethod("getData").invoke(world.response);
231266
assertEquals(
232267
World.lookup(world.context, fixturePath), World.lookup(responseData, responsePath));
233268
}
234269

235270
@Then("the response {string} has length {long}")
236271
public void theResponseHasLength(String responsePath, Long size)
237-
throws java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException,
238-
java.lang.InstantiationException, java.lang.NoSuchMethodException,
239-
java.lang.ClassNotFoundException, java.lang.NoSuchFieldException {
272+
throws java.lang.reflect.InvocationTargetException,
273+
java.lang.IllegalAccessException,
274+
java.lang.InstantiationException,
275+
java.lang.NoSuchMethodException,
276+
java.lang.ClassNotFoundException,
277+
java.lang.NoSuchFieldException {
240278
Object responseData = world.responseClass.getMethod("getData").invoke(world.response);
241279
List value = (List) World.lookup(responseData, responsePath);
242280
assertEquals(size, Long.valueOf(value.size()));
243281
}
244282

245283
@Then("the response has {int} items")
246284
public void theResponseHasItems(Integer size)
247-
throws java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException,
285+
throws java.lang.reflect.InvocationTargetException,
286+
java.lang.IllegalAccessException,
248287
java.lang.NoSuchMethodException {
249288
if (world.response.getClass().getSimpleName().equals("PaginationIterable")) {
250289
assertEquals(size, ((Object) world.paginatedItems.size()));

src/test/java/com/datadog/api/World.java

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,12 @@ public String getVersion() {
133133
}
134134

135135
private void configureClient(Class<?> clientClass, Object client)
136-
throws java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException,
137-
java.lang.InstantiationException, java.lang.NoSuchMethodException,
138-
java.lang.ClassNotFoundException, java.lang.NoSuchFieldException {
136+
throws java.lang.reflect.InvocationTargetException,
137+
java.lang.IllegalAccessException,
138+
java.lang.InstantiationException,
139+
java.lang.NoSuchMethodException,
140+
java.lang.ClassNotFoundException,
141+
java.lang.NoSuchFieldException {
139142
// client.setServerIndex(0);
140143
clientClass.getMethod("setServerIndex", Integer.class).invoke(client, 0);
141144

@@ -189,9 +192,12 @@ private void configureClient(Class<?> clientClass, Object client)
189192
}
190193

191194
public void setupClient(String apiVersion)
192-
throws java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException,
193-
java.lang.InstantiationException, java.lang.NoSuchMethodException,
194-
java.lang.ClassNotFoundException, java.lang.NoSuchFieldException {
195+
throws java.lang.reflect.InvocationTargetException,
196+
java.lang.IllegalAccessException,
197+
java.lang.InstantiationException,
198+
java.lang.NoSuchMethodException,
199+
java.lang.ClassNotFoundException,
200+
java.lang.NoSuchFieldException {
195201
// import com.datadog.api.client.ApiClient
196202
clientClass = Class.forName("com.datadog.api.client.ApiClient");
197203
// client = new ApiClient()
@@ -200,8 +206,10 @@ public void setupClient(String apiVersion)
200206
}
201207

202208
public void setupAPI(String apiVersion, String apiName)
203-
throws java.lang.ClassNotFoundException, java.lang.InstantiationException,
204-
java.lang.IllegalAccessException, java.lang.NoSuchMethodException,
209+
throws java.lang.ClassNotFoundException,
210+
java.lang.InstantiationException,
211+
java.lang.IllegalAccessException,
212+
java.lang.NoSuchMethodException,
205213
java.lang.reflect.InvocationTargetException {
206214
// import com.datadog.api.{{ apiVersion }}.client.api.{{ apiName }}Api
207215
apiClass = Class.forName("com.datadog.api.client." + apiVersion + ".api." + apiName + "Api");
@@ -210,7 +218,8 @@ public void setupAPI(String apiVersion, String apiName)
210218
}
211219

212220
public void setUnstableOperationEnabled(String operationId)
213-
throws java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException,
221+
throws java.lang.reflect.InvocationTargetException,
222+
java.lang.IllegalAccessException,
214223
java.lang.NoSuchMethodException {
215224
// client.setUnstableOperationEnabled(operationId, true)
216225
clientClass
@@ -219,14 +228,16 @@ public void setUnstableOperationEnabled(String operationId)
219228
}
220229

221230
public void configureApiKeys(Map<String, String> secrets)
222-
throws java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException,
231+
throws java.lang.reflect.InvocationTargetException,
232+
java.lang.IllegalAccessException,
223233
java.lang.NoSuchMethodException {
224234
// client.configureApiKeys(secrets)
225235
clientClass.getMethod("configureApiKeys", Map.class).invoke(client, secrets);
226236
}
227237

228238
public void authenticateClient(Class<?> clientClass, Object client)
229-
throws java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException,
239+
throws java.lang.reflect.InvocationTargetException,
240+
java.lang.IllegalAccessException,
230241
java.lang.NoSuchMethodException {
231242

232243
HashMap<String, String> secrets = new HashMap<String, String>();
@@ -258,8 +269,10 @@ public void newRequest(String name) {
258269
}
259270

260271
public void addRequestParameter(String parameterName, String value)
261-
throws java.lang.IllegalAccessException, java.lang.NoSuchFieldException,
262-
java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException,
272+
throws java.lang.IllegalAccessException,
273+
java.lang.NoSuchFieldException,
274+
java.lang.NoSuchMethodException,
275+
java.lang.reflect.InvocationTargetException,
263276
com.fasterxml.jackson.core.JsonProcessingException {
264277
String propertyName = toPropertyName(parameterName);
265278
Class fieldType = null;
@@ -294,8 +307,10 @@ public void addRequestParameter(String parameterName, String value)
294307
}
295308

296309
public void addRequestParameterFixture(String parameterName, String fixturePath)
297-
throws java.lang.IllegalAccessException, java.lang.NoSuchFieldException,
298-
java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException {
310+
throws java.lang.IllegalAccessException,
311+
java.lang.NoSuchFieldException,
312+
java.lang.NoSuchMethodException,
313+
java.lang.reflect.InvocationTargetException {
299314
String propertyName = toPropertyName(parameterName);
300315
Class fieldType = null;
301316
boolean isOptional = false;
@@ -571,7 +586,8 @@ public void sendPaginatedRequest() throws Exception {
571586
}
572587

573588
public ObjectMapper getObjectMapper()
574-
throws java.lang.IllegalAccessException, java.lang.NoSuchMethodException,
589+
throws java.lang.IllegalAccessException,
590+
java.lang.NoSuchMethodException,
575591
java.lang.reflect.InvocationTargetException {
576592
Method getJSON = clientClass.getMethod("getJSON");
577593
Object json = getJSON.invoke(client);

0 commit comments

Comments
 (0)