Skip to content

Commit ff0cf54

Browse files
committed
test: add tests for HttpRequestRunnable
1 parent 8fb8f3c commit ff0cf54

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

sdk-platform-java/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpRequestRunnableTest.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import com.google.api.client.http.EmptyContent;
3333
import com.google.api.client.http.HttpRequest;
3434
import com.google.api.client.testing.http.MockHttpTransport;
35+
import com.google.api.gax.tracing.ApiTracer;
3536
import com.google.common.truth.Truth;
3637
import com.google.longrunning.ListOperationsRequest;
3738
import com.google.protobuf.Empty;
@@ -123,6 +124,32 @@ void testRequestUrl() throws IOException {
123124
Truth.assertThat(httpRequest.getUrl().toString()).isEqualTo(expectedUrl);
124125
}
125126

127+
@Test
128+
void testApiTracerRequestUrlResolved() throws IOException {
129+
ApiTracer tracer = Mockito.mock(ApiTracer.class);
130+
ApiMethodDescriptor<Field, Empty> methodDescriptor =
131+
ApiMethodDescriptor.<Field, Empty>newBuilder()
132+
.setFullMethodName("house.cat.get")
133+
.setHttpMethod(null)
134+
.setRequestFormatter(requestFormatter)
135+
.setResponseParser(responseParser)
136+
.build();
137+
138+
HttpRequestRunnable<Field, Empty> httpRequestRunnable =
139+
new HttpRequestRunnable<>(
140+
requestMessage,
141+
methodDescriptor,
142+
ENDPOINT,
143+
HttpJsonCallOptions.newBuilder().setTracer(tracer).build(),
144+
new MockHttpTransport(),
145+
HttpJsonMetadata.newBuilder().build(),
146+
(result) -> {});
147+
148+
httpRequestRunnable.createHttpRequest();
149+
String expectedUrl = ENDPOINT + "/name/feline" + "?food=bird&food=mouse&size=small";
150+
Mockito.verify(tracer).requestUrlResolved(expectedUrl);
151+
}
152+
126153
@Test
127154
void testRequestUrlUnnormalized() throws IOException {
128155
ApiMethodDescriptor<Field, Empty> methodDescriptor =

0 commit comments

Comments
 (0)