From eb55bfb79e76527a8d665d6e05f7cdf49af969aa Mon Sep 17 00:00:00 2001 From: Mridula Peddada Date: Wed, 15 Mar 2023 12:48:01 -0400 Subject: [PATCH 01/14] chore: add simple unary callable showcase test for gRPC support --- .../showcase/v1beta1/it/ITFirstHttp.java | 68 ---------- .../showcase/v1beta1/it/ITFirstRpc.java | 75 ----------- .../showcase/v1beta1/it/ITUnaryCallable.java | 116 ++++++++++++++++++ 3 files changed, 116 insertions(+), 143 deletions(-) delete mode 100644 showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITFirstHttp.java delete mode 100644 showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITFirstRpc.java create mode 100644 showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java diff --git a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITFirstHttp.java b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITFirstHttp.java deleted file mode 100644 index e1a66d65ed..0000000000 --- a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITFirstHttp.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.showcase.v1beta1.it; - -import static org.junit.Assert.assertEquals; - -import com.google.api.client.http.javanet.NetHttpTransport; -import com.google.api.gax.core.NoCredentialsProvider; -import com.google.showcase.v1beta1.EchoClient; -import com.google.showcase.v1beta1.EchoRequest; -import com.google.showcase.v1beta1.EchoResponse; -import com.google.showcase.v1beta1.EchoSettings; -import java.io.IOException; -import java.security.GeneralSecurityException; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -public class ITFirstHttp { - - private static EchoClient client; - - @BeforeClass - public static void createClient() throws IOException, GeneralSecurityException { - EchoSettings echoSettings = - EchoSettings.newHttpJsonBuilder() - .setCredentialsProvider(NoCredentialsProvider.create()) - .setTransportChannelProvider( - EchoSettings.defaultHttpJsonTransportProviderBuilder() - .setHttpTransport( - new NetHttpTransport.Builder().doNotValidateCertificate().build()) - .setEndpoint("http://localhost:7469") - .build()) - .build(); - - client = EchoClient.create(echoSettings); - } - - @AfterClass - public static void destroyClient() { - client.close(); - } - - @Test - public void testEcho() { - assertEquals("http-echo?", echo("http-echo?")); - assertEquals("http-echo!", echo("http-echo!")); - } - - private String echo(String value) { - EchoResponse response = client.echo(EchoRequest.newBuilder().setContent(value).build()); - return response.getContent(); - } -} \ No newline at end of file diff --git a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITFirstRpc.java b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITFirstRpc.java deleted file mode 100644 index 46e681bb86..0000000000 --- a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITFirstRpc.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.showcase.v1beta1.it; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import com.google.api.gax.core.NoCredentialsProvider; -import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; -import com.google.showcase.v1beta1.EchoClient; -import com.google.showcase.v1beta1.EchoRequest; -import com.google.showcase.v1beta1.EchoResponse; -import com.google.showcase.v1beta1.EchoSettings; -import io.grpc.ManagedChannelBuilder; -import java.io.IOException; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -public class ITFirstRpc { - - private static EchoClient client; - - @Before - public void createClient() throws IOException { - EchoSettings echoSettings = - EchoSettings.newBuilder() - .setCredentialsProvider(NoCredentialsProvider.create()) - .setTransportChannelProvider( - InstantiatingGrpcChannelProvider.newBuilder() - .setChannelConfigurator(ManagedChannelBuilder::usePlaintext) - .build()) - .build(); - - client = EchoClient.create(echoSettings); - } - - @After - public void destroyClient() { - client.close(); - } - - @Test - public void testEcho() { - assertEquals("grpc-echo?", echo("grpc-echo?")); - assertEquals("grpc-echo!", echo("grpc-echo!")); - } - - @Test - public void testShutdown() { - assertFalse(client.isShutdown()); - client.shutdown(); - assertTrue(client.isShutdown()); - } - - private String echo(String value) { - EchoResponse response = client.echo(EchoRequest.newBuilder().setContent(value).build()); - return response.getContent(); - } -} \ No newline at end of file diff --git a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java new file mode 100644 index 0000000000..0d75af369f --- /dev/null +++ b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java @@ -0,0 +1,116 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.showcase.v1beta1.it; + +import com.google.api.client.http.javanet.NetHttpTransport; +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.grpc.GrpcStatusCode; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.rpc.CancelledException; +import com.google.api.gax.rpc.StatusCode; +import com.google.rpc.Status; +import com.google.showcase.v1beta1.EchoClient; +import com.google.showcase.v1beta1.EchoRequest; +import com.google.showcase.v1beta1.EchoResponse; +import com.google.showcase.v1beta1.EchoSettings; +import io.grpc.ManagedChannelBuilder; +import java.io.IOException; +import java.security.GeneralSecurityException; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class ITUnaryCallable { + + private static EchoClient grpcClient; + + private static EchoClient httpJsonClient; + + @Before + public void createClients() throws IOException, GeneralSecurityException { + // Create gRPC Echo Client + EchoSettings grpcEchoSettings = + EchoSettings.newBuilder() + .setCredentialsProvider(NoCredentialsProvider.create()) + .setTransportChannelProvider( + InstantiatingGrpcChannelProvider.newBuilder() + .setChannelConfigurator(ManagedChannelBuilder::usePlaintext) + .build()) + .build(); + grpcClient = EchoClient.create(grpcEchoSettings); + + // Create Http JSON Echo Client + EchoSettings httpJsonEchoSettings = + EchoSettings.newHttpJsonBuilder() + .setCredentialsProvider(NoCredentialsProvider.create()) + .setTransportChannelProvider( + EchoSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport( + new NetHttpTransport.Builder().doNotValidateCertificate().build()) + .setEndpoint("http://localhost:7469") + .build()) + .build(); + httpJsonClient = EchoClient.create(httpJsonEchoSettings); + } + + @After + public void destroyClient() { + grpcClient.close(); + httpJsonClient.close(); + } + + @Test + public void testGrpc() { + assertEquals("grpc-echo?", echoGrpc("grpc-echo?")); + assertEquals("grpc-echo!", echoGrpc("grpc-echo!")); + } + + @Test + public void testGrpc_cancelledError() { + Status cancelledStatus = Status.newBuilder().setCode(StatusCode.Code.CANCELLED.ordinal()).build(); + EchoRequest requestWithError = EchoRequest.newBuilder().setError(cancelledStatus).build(); + CancelledException exception = assertThrows(CancelledException.class, () -> grpcClient.echo(requestWithError)); + assertEquals(GrpcStatusCode.Code.CANCELLED, exception.getStatusCode().getCode()); + } + + @Test + public void testGrpc_shutdown() { + assertFalse(grpcClient.isShutdown()); + grpcClient.shutdown(); + assertTrue(grpcClient.isShutdown()); + } + + + @Test + public void testHttpJson() { + assertEquals("http-echo?", echoHttpJson("http-echo?")); + assertEquals("http-echo!", echoHttpJson("http-echo!")); + } + + private String echoGrpc(String value) { + EchoResponse response = grpcClient.echo(EchoRequest.newBuilder().setContent(value).build()); + return response.getContent(); + } + + private String echoHttpJson(String value) { + EchoResponse response = httpJsonClient.echo(EchoRequest.newBuilder().setContent(value).build()); + return response.getContent(); + } +} \ No newline at end of file From 5c07488704b6db3618a3de21b6477bae116bcc58 Mon Sep 17 00:00:00 2001 From: Mridula Peddada Date: Wed, 15 Mar 2023 17:08:54 -0400 Subject: [PATCH 02/14] install maven modules before calling bazelisk --- .github/workflows/ci-maven.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci-maven.yaml b/.github/workflows/ci-maven.yaml index e614dea160..f96d2e409b 100644 --- a/.github/workflows/ci-maven.yaml +++ b/.github/workflows/ci-maven.yaml @@ -25,6 +25,10 @@ jobs: mvn install --batch-mode --no-transfer-progress -Dcheckstyle.skip \ -Dfmt.skip - run: bazelisk version + - name: Install all modules + shell: bash + run: | + mvn -V -B -ntp clean install -DskipTests - name: Integration Tests run: | bazelisk --batch test //test/integration/... From 61c0ed565ad2a1ff1c04b882004ccada2fcc5766 Mon Sep 17 00:00:00 2001 From: Mridula Peddada Date: Wed, 15 Mar 2023 17:13:33 -0400 Subject: [PATCH 03/14] undo previous commit --- .github/workflows/ci-maven.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/ci-maven.yaml b/.github/workflows/ci-maven.yaml index f96d2e409b..e614dea160 100644 --- a/.github/workflows/ci-maven.yaml +++ b/.github/workflows/ci-maven.yaml @@ -25,10 +25,6 @@ jobs: mvn install --batch-mode --no-transfer-progress -Dcheckstyle.skip \ -Dfmt.skip - run: bazelisk version - - name: Install all modules - shell: bash - run: | - mvn -V -B -ntp clean install -DskipTests - name: Integration Tests run: | bazelisk --batch test //test/integration/... From 33f10a84fa04c1eb865f52c8fbe27fddd1c85afd Mon Sep 17 00:00:00 2001 From: Mridula Peddada Date: Wed, 15 Mar 2023 22:15:24 -0400 Subject: [PATCH 04/14] use truth --- showcase/gapic-showcase/pom.xml | 7 ++++++ .../showcase/v1beta1/it/ITUnaryCallable.java | 25 ++++++++++--------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/showcase/gapic-showcase/pom.xml b/showcase/gapic-showcase/pom.xml index 8c3de921fd..7276f273cf 100644 --- a/showcase/gapic-showcase/pom.xml +++ b/showcase/gapic-showcase/pom.xml @@ -162,6 +162,13 @@ test + + com.google.truth + truth + 1.1.3 + test + + com.google.api.grpc grpc-gapic-showcase-v1beta1 diff --git a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java index 0d75af369f..7787e9d497 100644 --- a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java +++ b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,9 @@ package com.google.showcase.v1beta1.it; +import static com.google.common.truth.Truth.assertThat; +import static org.junit.Assert.assertThrows; + import com.google.api.client.http.javanet.NetHttpTransport; import com.google.api.gax.core.NoCredentialsProvider; import com.google.api.gax.grpc.GrpcStatusCode; @@ -35,8 +38,6 @@ import org.junit.Before; import org.junit.Test; -import static org.junit.Assert.*; - public class ITUnaryCallable { private static EchoClient grpcClient; @@ -77,31 +78,31 @@ public void destroyClient() { } @Test - public void testGrpc() { - assertEquals("grpc-echo?", echoGrpc("grpc-echo?")); - assertEquals("grpc-echo!", echoGrpc("grpc-echo!")); + public void testGrpc_echoMessageBack() { + assertThat(echoGrpc("grpc-echo?")).isEqualTo("grpc-echo?"); + assertThat(echoGrpc("grpc-echo!")).isEqualTo("grpc-echo!"); } @Test - public void testGrpc_cancelledError() { + public void testGrpc_cancelledError_echoErrorBack() { Status cancelledStatus = Status.newBuilder().setCode(StatusCode.Code.CANCELLED.ordinal()).build(); EchoRequest requestWithError = EchoRequest.newBuilder().setError(cancelledStatus).build(); CancelledException exception = assertThrows(CancelledException.class, () -> grpcClient.echo(requestWithError)); - assertEquals(GrpcStatusCode.Code.CANCELLED, exception.getStatusCode().getCode()); + assertThat(exception.getStatusCode().getCode()).isEqualTo(GrpcStatusCode.Code.CANCELLED); } @Test public void testGrpc_shutdown() { - assertFalse(grpcClient.isShutdown()); + assertThat(grpcClient.isShutdown()).isFalse(); grpcClient.shutdown(); - assertTrue(grpcClient.isShutdown()); + assertThat(grpcClient.isShutdown()).isTrue(); } @Test public void testHttpJson() { - assertEquals("http-echo?", echoHttpJson("http-echo?")); - assertEquals("http-echo!", echoHttpJson("http-echo!")); + assertThat(echoHttpJson("http-echo?")).isEqualTo("http-echo?"); + assertThat(echoHttpJson("http-echo!")).isEqualTo("http-echo!"); } private String echoGrpc(String value) { From 8f667d18ab74b509eeaa0f877f62e207114e0757 Mon Sep 17 00:00:00 2001 From: Mridula Peddada Date: Thu, 16 Mar 2023 16:30:05 -0400 Subject: [PATCH 05/14] rename tests --- .../com/google/showcase/v1beta1/it/ITUnaryCallable.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java index 7787e9d497..2e1353872c 100644 --- a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java +++ b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java @@ -78,16 +78,16 @@ public void destroyClient() { } @Test - public void testGrpc_echoMessageBack() { + public void testGrpc_receiveContent() { assertThat(echoGrpc("grpc-echo?")).isEqualTo("grpc-echo?"); assertThat(echoGrpc("grpc-echo!")).isEqualTo("grpc-echo!"); } @Test - public void testGrpc_cancelledError_echoErrorBack() { + public void testGrpc_serverResponseError_throwsException() { Status cancelledStatus = Status.newBuilder().setCode(StatusCode.Code.CANCELLED.ordinal()).build(); - EchoRequest requestWithError = EchoRequest.newBuilder().setError(cancelledStatus).build(); - CancelledException exception = assertThrows(CancelledException.class, () -> grpcClient.echo(requestWithError)); + EchoRequest requestWithServerError = EchoRequest.newBuilder().setError(cancelledStatus).build(); + CancelledException exception = assertThrows(CancelledException.class, () -> grpcClient.echo(requestWithServerError)); assertThat(exception.getStatusCode().getCode()).isEqualTo(GrpcStatusCode.Code.CANCELLED); } From a719db759b5dcbc2bea6ddd45291805b8693df7d Mon Sep 17 00:00:00 2001 From: Mridula Peddada Date: Mon, 20 Mar 2023 11:27:42 -0400 Subject: [PATCH 06/14] fix formatting and use Before/AfterClass --- .../showcase/v1beta1/it/ITUnaryCallable.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java index 2e1353872c..1d6a6e2215 100644 --- a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java +++ b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java @@ -33,9 +33,8 @@ import io.grpc.ManagedChannelBuilder; import java.io.IOException; import java.security.GeneralSecurityException; - -import org.junit.After; -import org.junit.Before; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Test; public class ITUnaryCallable { @@ -44,7 +43,7 @@ public class ITUnaryCallable { private static EchoClient httpJsonClient; - @Before + @BeforeClass public void createClients() throws IOException, GeneralSecurityException { // Create gRPC Echo Client EchoSettings grpcEchoSettings = @@ -59,19 +58,19 @@ public void createClients() throws IOException, GeneralSecurityException { // Create Http JSON Echo Client EchoSettings httpJsonEchoSettings = - EchoSettings.newHttpJsonBuilder() - .setCredentialsProvider(NoCredentialsProvider.create()) - .setTransportChannelProvider( - EchoSettings.defaultHttpJsonTransportProviderBuilder() - .setHttpTransport( - new NetHttpTransport.Builder().doNotValidateCertificate().build()) - .setEndpoint("http://localhost:7469") - .build()) - .build(); + EchoSettings.newHttpJsonBuilder() + .setCredentialsProvider(NoCredentialsProvider.create()) + .setTransportChannelProvider( + EchoSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport( + new NetHttpTransport.Builder().doNotValidateCertificate().build()) + .setEndpoint("http://localhost:7469") + .build()) + .build(); httpJsonClient = EchoClient.create(httpJsonEchoSettings); } - @After + @AfterClass public void destroyClient() { grpcClient.close(); httpJsonClient.close(); @@ -85,9 +84,11 @@ public void testGrpc_receiveContent() { @Test public void testGrpc_serverResponseError_throwsException() { - Status cancelledStatus = Status.newBuilder().setCode(StatusCode.Code.CANCELLED.ordinal()).build(); + Status cancelledStatus = + Status.newBuilder().setCode(StatusCode.Code.CANCELLED.ordinal()).build(); EchoRequest requestWithServerError = EchoRequest.newBuilder().setError(cancelledStatus).build(); - CancelledException exception = assertThrows(CancelledException.class, () -> grpcClient.echo(requestWithServerError)); + CancelledException exception = + assertThrows(CancelledException.class, () -> grpcClient.echo(requestWithServerError)); assertThat(exception.getStatusCode().getCode()).isEqualTo(GrpcStatusCode.Code.CANCELLED); } @@ -98,7 +99,6 @@ public void testGrpc_shutdown() { assertThat(grpcClient.isShutdown()).isTrue(); } - @Test public void testHttpJson() { assertThat(echoHttpJson("http-echo?")).isEqualTo("http-echo?"); @@ -114,4 +114,4 @@ private String echoHttpJson(String value) { EchoResponse response = httpJsonClient.echo(EchoRequest.newBuilder().setContent(value).build()); return response.getContent(); } -} \ No newline at end of file +} From 0be9ff1d8c09e878aa0ee749e4a531b01e463754 Mon Sep 17 00:00:00 2001 From: Mridula Peddada Date: Mon, 20 Mar 2023 11:32:49 -0400 Subject: [PATCH 07/14] make createClients static --- .../java/com/google/showcase/v1beta1/it/ITUnaryCallable.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java index 1d6a6e2215..7a99907ab2 100644 --- a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java +++ b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java @@ -44,7 +44,7 @@ public class ITUnaryCallable { private static EchoClient httpJsonClient; @BeforeClass - public void createClients() throws IOException, GeneralSecurityException { + public static void createClients() throws IOException, GeneralSecurityException { // Create gRPC Echo Client EchoSettings grpcEchoSettings = EchoSettings.newBuilder() @@ -71,7 +71,7 @@ public void createClients() throws IOException, GeneralSecurityException { } @AfterClass - public void destroyClient() { + public static void destroyClient() { grpcClient.close(); httpJsonClient.close(); } From 7717e433d61125dcef35dd826267de0226107ef1 Mon Sep 17 00:00:00 2001 From: Mridula Peddada Date: Mon, 20 Mar 2023 14:43:37 -0400 Subject: [PATCH 08/14] add formatter for ITs --- showcase/gapic-showcase/pom.xml | 12 ++++++++---- .../google/showcase/v1beta1/MessagingClientTest.java | 1 + .../google/showcase/v1beta1/it/ITNumericEnums.java | 5 ++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/showcase/gapic-showcase/pom.xml b/showcase/gapic-showcase/pom.xml index 7276f273cf..503751e5fd 100644 --- a/showcase/gapic-showcase/pom.xml +++ b/showcase/gapic-showcase/pom.xml @@ -18,10 +18,6 @@ 0.0.1-SNAPSHOT - - true - - enable-golden-tests @@ -102,6 +98,14 @@ + + com.coveo + fmt-maven-plugin + 2.9 + + IT.*\.java + + diff --git a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/MessagingClientTest.java b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/MessagingClientTest.java index 0f4e531141..1bb9494340 100644 --- a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/MessagingClientTest.java +++ b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/MessagingClientTest.java @@ -48,6 +48,7 @@ import java.util.UUID; import java.util.concurrent.ExecutionException; import javax.annotation.Generated; + import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; diff --git a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITNumericEnums.java b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITNumericEnums.java index 7d87b37d0c..232c3392d2 100644 --- a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITNumericEnums.java +++ b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITNumericEnums.java @@ -23,10 +23,9 @@ import com.google.showcase.v1beta1.ComplianceClient; import com.google.showcase.v1beta1.ComplianceSettings; import com.google.showcase.v1beta1.EnumRequest; +import com.google.showcase.v1beta1.EnumResponse; import java.io.IOException; import java.security.GeneralSecurityException; - -import com.google.showcase.v1beta1.EnumResponse; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -61,4 +60,4 @@ public void verifyEnums() { EnumResponse initialResponse = client.getEnum(request); assertEquals(initialResponse, client.verifyEnum(initialResponse)); } -} \ No newline at end of file +} From 04cfebfc89d95904abf45627e49df35477490914 Mon Sep 17 00:00:00 2001 From: Mridula Peddada Date: Mon, 20 Mar 2023 14:59:16 -0400 Subject: [PATCH 09/14] undo space addition --- .../java/com/google/showcase/v1beta1/MessagingClientTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/MessagingClientTest.java b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/MessagingClientTest.java index 1bb9494340..0f4e531141 100644 --- a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/MessagingClientTest.java +++ b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/MessagingClientTest.java @@ -48,7 +48,6 @@ import java.util.UUID; import java.util.concurrent.ExecutionException; import javax.annotation.Generated; - import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; From 6b1cc2f866b3e7278cf847cf86f319d355ce484f Mon Sep 17 00:00:00 2001 From: Mridula Peddada Date: Mon, 20 Mar 2023 15:20:09 -0400 Subject: [PATCH 10/14] add formatter for other test classes --- showcase/gapic-showcase/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/showcase/gapic-showcase/pom.xml b/showcase/gapic-showcase/pom.xml index 503751e5fd..0729f654f4 100644 --- a/showcase/gapic-showcase/pom.xml +++ b/showcase/gapic-showcase/pom.xml @@ -103,7 +103,7 @@ fmt-maven-plugin 2.9 - IT.*\.java + (IT.*\.java)|(.*Test.java) From a74248b9648404d725b51dcf08c56b8d5523b7fa Mon Sep 17 00:00:00 2001 From: Mridula Peddada Date: Mon, 20 Mar 2023 15:32:48 -0400 Subject: [PATCH 11/14] test commit to verify fmt behavior --- .../java/com/google/showcase/v1beta1/MessagingClientTest.java | 1 + .../java/com/google/showcase/v1beta1/it/ITUnaryCallable.java | 1 + 2 files changed, 2 insertions(+) diff --git a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/MessagingClientTest.java b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/MessagingClientTest.java index 0f4e531141..1bb9494340 100644 --- a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/MessagingClientTest.java +++ b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/MessagingClientTest.java @@ -48,6 +48,7 @@ import java.util.UUID; import java.util.concurrent.ExecutionException; import javax.annotation.Generated; + import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; diff --git a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java index 7a99907ab2..ad6e47d643 100644 --- a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java +++ b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java @@ -33,6 +33,7 @@ import io.grpc.ManagedChannelBuilder; import java.io.IOException; import java.security.GeneralSecurityException; + import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; From e7011fdeafe4960ac641cde9aa551d7372494862 Mon Sep 17 00:00:00 2001 From: Mridula Peddada Date: Mon, 20 Mar 2023 15:47:01 -0400 Subject: [PATCH 12/14] add lint checker to showcase testing --- .github/workflows/ci-maven.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-maven.yaml b/.github/workflows/ci-maven.yaml index e614dea160..d9e6c6e667 100644 --- a/.github/workflows/ci-maven.yaml +++ b/.github/workflows/ci-maven.yaml @@ -164,7 +164,10 @@ jobs: - name: Install maven modules run: | mvn install -B -ntp -DskipTests -Dclirr.skip -Dcheckstyle.skip - + - name: Java Linter + working-directory: showcase + run: | + mvn -B -ntp fmt:check - name: Showcase golden tests working-directory: showcase run: | From de5bf88e98796408f3010dc239221d0f9a33ecf1 Mon Sep 17 00:00:00 2001 From: Mridula Peddada Date: Mon, 20 Mar 2023 15:53:57 -0400 Subject: [PATCH 13/14] fix formatting --- .../java/com/google/showcase/v1beta1/MessagingClientTest.java | 1 - .../java/com/google/showcase/v1beta1/it/ITUnaryCallable.java | 1 - 2 files changed, 2 deletions(-) diff --git a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/MessagingClientTest.java b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/MessagingClientTest.java index 1bb9494340..0f4e531141 100644 --- a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/MessagingClientTest.java +++ b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/MessagingClientTest.java @@ -48,7 +48,6 @@ import java.util.UUID; import java.util.concurrent.ExecutionException; import javax.annotation.Generated; - import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; diff --git a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java index ad6e47d643..7a99907ab2 100644 --- a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java +++ b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java @@ -33,7 +33,6 @@ import io.grpc.ManagedChannelBuilder; import java.io.IOException; import java.security.GeneralSecurityException; - import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; From 40e4f5a00dd47eaec5db9bc1d4036638580dcd02 Mon Sep 17 00:00:00 2001 From: Mridula Peddada Date: Wed, 22 Mar 2023 14:25:27 -0400 Subject: [PATCH 14/14] avoid using static variable --- .../showcase/v1beta1/it/ITUnaryCallable.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java index 7a99907ab2..82fb80be0e 100644 --- a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java +++ b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java @@ -33,18 +33,18 @@ import io.grpc.ManagedChannelBuilder; import java.io.IOException; import java.security.GeneralSecurityException; -import org.junit.AfterClass; -import org.junit.BeforeClass; +import org.junit.After; +import org.junit.Before; import org.junit.Test; public class ITUnaryCallable { - private static EchoClient grpcClient; + private EchoClient grpcClient; - private static EchoClient httpJsonClient; + private EchoClient httpJsonClient; - @BeforeClass - public static void createClients() throws IOException, GeneralSecurityException { + @Before + public void createClients() throws IOException, GeneralSecurityException { // Create gRPC Echo Client EchoSettings grpcEchoSettings = EchoSettings.newBuilder() @@ -70,8 +70,8 @@ public static void createClients() throws IOException, GeneralSecurityException httpJsonClient = EchoClient.create(httpJsonEchoSettings); } - @AfterClass - public static void destroyClient() { + @After + public void destroyClient() { grpcClient.close(); httpJsonClient.close(); }