|
32 | 32 | import com.google.api.client.http.EmptyContent; |
33 | 33 | import com.google.api.client.http.HttpRequest; |
34 | 34 | import com.google.api.client.testing.http.MockHttpTransport; |
| 35 | +import com.google.api.gax.tracing.ApiTracer; |
35 | 36 | import com.google.common.truth.Truth; |
36 | 37 | import com.google.longrunning.ListOperationsRequest; |
37 | 38 | import com.google.protobuf.Empty; |
@@ -123,6 +124,32 @@ void testRequestUrl() throws IOException { |
123 | 124 | Truth.assertThat(httpRequest.getUrl().toString()).isEqualTo(expectedUrl); |
124 | 125 | } |
125 | 126 |
|
| 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 | + |
126 | 153 | @Test |
127 | 154 | void testRequestUrlUnnormalized() throws IOException { |
128 | 155 | ApiMethodDescriptor<Field, Empty> methodDescriptor = |
|
0 commit comments