Skip to content

Commit 27291b0

Browse files
committed
style: apply fmt-maven-plugin formatting
1 parent 15dbe99 commit 27291b0

2 files changed

Lines changed: 51 additions & 34 deletions

File tree

sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelTracePropagation.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import com.google.api.gax.httpjson.ApiMethodDescriptor;
2222
import com.google.api.gax.httpjson.ForwardingHttpJsonClientCall;
23-
import com.google.api.gax.httpjson.ForwardingHttpJsonClientCallListener;
2423
import com.google.api.gax.httpjson.HttpJsonCallOptions;
2524
import com.google.api.gax.httpjson.HttpJsonChannel;
2625
import com.google.api.gax.httpjson.HttpJsonClientCall;
@@ -77,7 +76,8 @@ public <RequestT, ResponseT> ClientCall<RequestT, ResponseT> interceptCall(
7776
public void start(ClientCall.Listener<ResponseT> responseListener, Metadata headers) {
7877
requestHeaders = headers;
7978
ClientCall.Listener<ResponseT> forwardingResponseListener =
80-
new ForwardingClientCallListener.SimpleForwardingClientCallListener<ResponseT>(responseListener) {
79+
new ForwardingClientCallListener.SimpleForwardingClientCallListener<ResponseT>(
80+
responseListener) {
8181
@Override
8282
public void onClose(io.grpc.Status status, Metadata trailers) {
8383
responseTrailers = trailers;
@@ -90,7 +90,8 @@ public void onClose(io.grpc.Status status, Metadata trailers) {
9090
}
9191
}
9292

93-
private static class HttpJsonResponseCapturingClientInterceptor implements HttpJsonClientInterceptor {
93+
private static class HttpJsonResponseCapturingClientInterceptor
94+
implements HttpJsonClientInterceptor {
9495
private HttpJsonMetadata requestHeaders;
9596

9697
@Override
@@ -203,7 +204,8 @@ void testTracePropagation_grpc() {
203204
String expectedTraceId = attemptSpan.getSpanContext().getTraceId();
204205
String expectedSpanId = attemptSpan.getSpanContext().getSpanId();
205206
String expectedTraceFlags = attemptSpan.getSpanContext().getTraceFlags().asHex();
206-
String expectedTraceparent = "00-" + expectedTraceId + "-" + expectedSpanId + "-" + expectedTraceFlags;
207+
String expectedTraceparent =
208+
"00-" + expectedTraceId + "-" + expectedSpanId + "-" + expectedTraceFlags;
207209

208210
String headerValue = grpcInterceptor.requestHeaders.get(TRACEPARENT_GRPC_HEADER_KEY);
209211
assertThat(headerValue).isNotNull();
@@ -228,7 +230,8 @@ void testTracePropagation_httpjson() {
228230
String expectedTraceId = attemptSpan.getSpanContext().getTraceId();
229231
String expectedSpanId = attemptSpan.getSpanContext().getSpanId();
230232
String expectedTraceFlags = attemptSpan.getSpanContext().getTraceFlags().asHex();
231-
String expectedTraceparent = "00-" + expectedTraceId + "-" + expectedSpanId + "-" + expectedTraceFlags;
233+
String expectedTraceparent =
234+
"00-" + expectedTraceId + "-" + expectedSpanId + "-" + expectedTraceFlags;
232235

233236
assertThat(httpJsonInterceptor.requestHeaders).isNotNull();
234237
Map<String, Object> headers = httpJsonInterceptor.requestHeaders.getHeaders();
@@ -237,12 +240,12 @@ void testTracePropagation_httpjson() {
237240

238241
Object headerVal = headers.get(expectedHttpHeaderKey);
239242
if (headerVal instanceof List) {
240-
@SuppressWarnings("unchecked")
241-
List<String> traceparentHeaders = (List<String>) headerVal;
242-
assertThat(traceparentHeaders).hasSize(1);
243-
assertThat(traceparentHeaders.get(0)).isEqualTo(expectedTraceparent);
243+
@SuppressWarnings("unchecked")
244+
List<String> traceparentHeaders = (List<String>) headerVal;
245+
assertThat(traceparentHeaders).hasSize(1);
246+
assertThat(traceparentHeaders.get(0)).isEqualTo(expectedTraceparent);
244247
} else {
245-
assertThat(String.valueOf(headerVal)).isEqualTo(expectedTraceparent);
248+
assertThat(String.valueOf(headerVal)).isEqualTo(expectedTraceparent);
246249
}
247250
}
248251
}

sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/logging/ITActionableErrorsLogging.java

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -180,21 +180,27 @@ public LowLevelHttpResponse execute() throws IOException {
180180
assertThat(testAppender.events.size()).isAtLeast(1);
181181
ILoggingEvent loggingEvent = testAppender.events.get(testAppender.events.size() - 1);
182182

183-
assertThat(loggingEvent.getMessage()).contains("This is a mock JSON error generated by the server");
183+
assertThat(loggingEvent.getMessage())
184+
.contains("This is a mock JSON error generated by the server");
184185

185186
Map<String, Object> kvps = getKvps(loggingEvent);
186187
assertThat(kvps).containsEntry(ObservabilityAttributes.RPC_SYSTEM_NAME_ATTRIBUTE, "http");
187188
assertThat(kvps).containsEntry(ObservabilityAttributes.HTTP_METHOD_ATTRIBUTE, "POST");
188-
assertThat(kvps).containsEntry(ObservabilityAttributes.HTTP_URL_TEMPLATE_ATTRIBUTE, "v1beta1/echo:echo");
189-
assertThat(kvps).containsEntry(ObservabilityAttributes.RPC_RESPONSE_STATUS_ATTRIBUTE, "ABORTED");
190-
assertThat(kvps).containsEntry(ObservabilityAttributes.ERROR_TYPE_ATTRIBUTE, "mock_error_reason");
191-
assertThat(kvps).containsEntry(ObservabilityAttributes.ERROR_DOMAIN_ATTRIBUTE, "mock.googleapis.com");
189+
assertThat(kvps)
190+
.containsEntry(ObservabilityAttributes.HTTP_URL_TEMPLATE_ATTRIBUTE, "v1beta1/echo:echo");
191+
assertThat(kvps)
192+
.containsEntry(ObservabilityAttributes.RPC_RESPONSE_STATUS_ATTRIBUTE, "ABORTED");
193+
assertThat(kvps)
194+
.containsEntry(ObservabilityAttributes.ERROR_TYPE_ATTRIBUTE, "mock_error_reason");
195+
assertThat(kvps)
196+
.containsEntry(ObservabilityAttributes.ERROR_DOMAIN_ATTRIBUTE, "mock.googleapis.com");
192197
assertThat(kvps)
193198
.containsEntry(
194199
ObservabilityAttributes.ERROR_METADATA_ATTRIBUTE_PREFIX + "mock_key", "mock_value");
195200

196201
mockHttpJsonClient.close();
197-
mockHttpJsonClient.awaitTermination(TestClientInitializer.AWAIT_TERMINATION_SECONDS, TimeUnit.SECONDS);
202+
mockHttpJsonClient.awaitTermination(
203+
TestClientInitializer.AWAIT_TERMINATION_SECONDS, TimeUnit.SECONDS);
198204
}
199205

200206
@Test
@@ -208,16 +214,18 @@ void testHttpJson_noLogEmittedForSuccess() {
208214
void testHttpJson_clientLevelFailureAttributes() throws Exception {
209215
com.google.showcase.v1beta1.stub.EchoStubSettings.Builder stubSettingsBuilder =
210216
com.google.showcase.v1beta1.stub.EchoStubSettings.newHttpJsonBuilder();
211-
stubSettingsBuilder.echoSettings().setRetrySettings(
212-
com.google.api.gax.retrying.RetrySettings.newBuilder()
213-
.setInitialRpcTimeoutDuration(java.time.Duration.ofMillis(0))
214-
.setTotalTimeoutDuration(java.time.Duration.ofMillis(0))
215-
.setMaxAttempts(1)
216-
.build());
217+
stubSettingsBuilder
218+
.echoSettings()
219+
.setRetrySettings(
220+
com.google.api.gax.retrying.RetrySettings.newBuilder()
221+
.setInitialRpcTimeoutDuration(java.time.Duration.ofMillis(0))
222+
.setTotalTimeoutDuration(java.time.Duration.ofMillis(0))
223+
.setMaxAttempts(1)
224+
.build());
217225
stubSettingsBuilder.setTracerFactory(new LoggingTracerFactory());
218226
stubSettingsBuilder.setCredentialsProvider(NoCredentialsProvider.create());
219227
stubSettingsBuilder.setEndpoint("localhost:1");
220-
228+
221229
try (com.google.showcase.v1beta1.stub.EchoStub stub = stubSettingsBuilder.build().createStub();
222230
EchoClient client = EchoClient.create(stub)) {
223231
assertThrows(ApiException.class, () -> client.echo(EchoRequest.newBuilder().build()));
@@ -240,13 +248,17 @@ void testGrpc_logEmittedForLowLevelRequestFailure() {
240248
Map<String, Object> kvps = getKvps(loggingEvent);
241249
assertThat(kvps).containsEntry(ObservabilityAttributes.RPC_SYSTEM_NAME_ATTRIBUTE, "grpc");
242250
assertThat(kvps)
243-
.containsEntry(ObservabilityAttributes.GRPC_RPC_METHOD_ATTRIBUTE, "google.showcase.v1beta1.Echo/Echo");
244-
assertThat(kvps).containsEntry(ObservabilityAttributes.RPC_RESPONSE_STATUS_ATTRIBUTE, "INVALID_ARGUMENT");
251+
.containsEntry(
252+
ObservabilityAttributes.GRPC_RPC_METHOD_ATTRIBUTE, "google.showcase.v1beta1.Echo/Echo");
253+
assertThat(kvps)
254+
.containsEntry(ObservabilityAttributes.RPC_RESPONSE_STATUS_ATTRIBUTE, "INVALID_ARGUMENT");
245255
assertThat(kvps).containsEntry(ObservabilityAttributes.ERROR_TYPE_ATTRIBUTE, "TEST_REASON");
246-
assertThat(kvps).containsEntry(ObservabilityAttributes.ERROR_DOMAIN_ATTRIBUTE, "test.googleapis.com");
256+
assertThat(kvps)
257+
.containsEntry(ObservabilityAttributes.ERROR_DOMAIN_ATTRIBUTE, "test.googleapis.com");
247258
assertThat(kvps)
248259
.containsEntry(
249-
ObservabilityAttributes.ERROR_METADATA_ATTRIBUTE_PREFIX + "test_metadata", "test_value");
260+
ObservabilityAttributes.ERROR_METADATA_ATTRIBUTE_PREFIX + "test_metadata",
261+
"test_value");
250262
}
251263

252264
@Test
@@ -260,16 +272,18 @@ void testGrpc_noLogEmittedForSuccess() {
260272
void testGrpc_clientLevelFailureAttributes() throws Exception {
261273
com.google.showcase.v1beta1.stub.EchoStubSettings.Builder stubSettingsBuilder =
262274
com.google.showcase.v1beta1.stub.EchoStubSettings.newBuilder();
263-
stubSettingsBuilder.echoSettings().setRetrySettings(
264-
com.google.api.gax.retrying.RetrySettings.newBuilder()
265-
.setInitialRpcTimeoutDuration(java.time.Duration.ofMillis(0))
266-
.setTotalTimeoutDuration(java.time.Duration.ofMillis(0))
267-
.setMaxAttempts(1)
268-
.build());
275+
stubSettingsBuilder
276+
.echoSettings()
277+
.setRetrySettings(
278+
com.google.api.gax.retrying.RetrySettings.newBuilder()
279+
.setInitialRpcTimeoutDuration(java.time.Duration.ofMillis(0))
280+
.setTotalTimeoutDuration(java.time.Duration.ofMillis(0))
281+
.setMaxAttempts(1)
282+
.build());
269283
stubSettingsBuilder.setTracerFactory(new LoggingTracerFactory());
270284
stubSettingsBuilder.setCredentialsProvider(NoCredentialsProvider.create());
271285
stubSettingsBuilder.setEndpoint("localhost:1");
272-
286+
273287
try (com.google.showcase.v1beta1.stub.EchoStub stub = stubSettingsBuilder.build().createStub();
274288
EchoClient client = EchoClient.create(stub)) {
275289
assertThrows(ApiException.class, () -> client.echo(EchoRequest.newBuilder().build()));

0 commit comments

Comments
 (0)