From ff19831cb8ae79cbf57df9f152024ebc4e082a6a Mon Sep 17 00:00:00 2001 From: Lawrence Qiu Date: Thu, 23 Mar 2023 20:53:21 +0000 Subject: [PATCH] chore: Add Showcase Callables IT (#1483) * chore: Add Showcase Callables IT * chore: Add test scope * deps: update google http client dependencies to v1.43.1 (#1487) * build(deps): update dependency org.apache.maven.plugins:maven-surefire-plugin to v3.0.0 (#1488) Co-authored-by: Lawrence Qiu * chore(main): release 2.15.3 (#1445) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Lawrence Qiu * chore(main): release 2.15.4-SNAPSHOT (#1489) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> * chore: Refactor paged logic * chore: Format ITCallables * chore: Format ITCallables * chore: Fix to not found status code * chore: Add HttpJson Unary Callable Showcase Test * chore: Fix truth dependency * chore: Update test name * chore: Address code smell * chore: Remove incorrect comment * chore: Update test to CANCELLED * chore: Clean up PR --------- Co-authored-by: Mend Renovate Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- showcase/gapic-showcase/pom.xml | 1 - .../showcase/v1beta1/it/ITUnaryCallable.java | 20 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/showcase/gapic-showcase/pom.xml b/showcase/gapic-showcase/pom.xml index 3ff935c1de..96b4045ebd 100644 --- a/showcase/gapic-showcase/pom.xml +++ b/showcase/gapic-showcase/pom.xml @@ -165,7 +165,6 @@ junit test - com.google.truth truth 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 82fb80be0e..1d1ccd1bec 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 @@ -100,11 +100,29 @@ public void testGrpc_shutdown() { } @Test - public void testHttpJson() { + public void testHttpJson_receiveContent() { assertThat(echoHttpJson("http-echo?")).isEqualTo("http-echo?"); assertThat(echoHttpJson("http-echo!")).isEqualTo("http-echo!"); } + @Test + public void testHttpJson_serverResponseError_throwsException() { + EchoRequest requestWithServerError = + EchoRequest.newBuilder() + .setError(Status.newBuilder().setCode(StatusCode.Code.CANCELLED.ordinal()).build()) + .build(); + CancelledException exception = + assertThrows(CancelledException.class, () -> httpJsonClient.echo(requestWithServerError)); + assertThat(exception.getStatusCode().getCode()).isEqualTo(StatusCode.Code.CANCELLED); + } + + @Test + public void testHttpJson_shutdown() { + assertThat(httpJsonClient.isShutdown()).isFalse(); + httpJsonClient.shutdown(); + assertThat(httpJsonClient.isShutdown()).isTrue(); + } + private String echoGrpc(String value) { EchoResponse response = grpcClient.echo(EchoRequest.newBuilder().setContent(value).build()); return response.getContent();