Search in sources :

Example 1 with ListTracesResponse

use of com.google.devtools.cloudtrace.v1.ListTracesResponse in project google-cloud-java by GoogleCloudPlatform.

the class TraceServiceClientTest method listTracesTest.

@Test
@SuppressWarnings("all")
public void listTracesTest() {
    String nextPageToken = "";
    Trace tracesElement = Trace.newBuilder().build();
    List<Trace> traces = Arrays.asList(tracesElement);
    ListTracesResponse expectedResponse = ListTracesResponse.newBuilder().setNextPageToken(nextPageToken).addAllTraces(traces).build();
    mockTraceService.addResponse(expectedResponse);
    String projectId = "projectId-1969970175";
    ListTracesPagedResponse pagedListResponse = client.listTraces(projectId);
    List<Trace> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getTracesList().get(0), resources.get(0));
    List<GeneratedMessageV3> actualRequests = mockTraceService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListTracesRequest actualRequest = (ListTracesRequest) actualRequests.get(0);
    Assert.assertEquals(projectId, actualRequest.getProjectId());
}
Also used : Trace(com.google.devtools.cloudtrace.v1.Trace) ListTracesResponse(com.google.devtools.cloudtrace.v1.ListTracesResponse) ListTracesPagedResponse(com.google.cloud.trace.spi.v1.PagedResponseWrappers.ListTracesPagedResponse) ListTracesRequest(com.google.devtools.cloudtrace.v1.ListTracesRequest) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Aggregations

ListTracesPagedResponse (com.google.cloud.trace.spi.v1.PagedResponseWrappers.ListTracesPagedResponse)1 ListTracesRequest (com.google.devtools.cloudtrace.v1.ListTracesRequest)1 ListTracesResponse (com.google.devtools.cloudtrace.v1.ListTracesResponse)1 Trace (com.google.devtools.cloudtrace.v1.Trace)1 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)1 Test (org.junit.Test)1