Search in sources :

Example 1 with ErrorEvent

use of com.google.devtools.clouderrorreporting.v1beta1.ErrorEvent in project google-cloud-java by GoogleCloudPlatform.

the class ErrorStatsServiceClientTest method listEventsTest.

@Test
@SuppressWarnings("all")
public void listEventsTest() {
    String nextPageToken = "";
    ErrorEvent errorEventsElement = ErrorEvent.newBuilder().build();
    List<ErrorEvent> errorEvents = Arrays.asList(errorEventsElement);
    ListEventsResponse expectedResponse = ListEventsResponse.newBuilder().setNextPageToken(nextPageToken).addAllErrorEvents(errorEvents).build();
    mockErrorStatsService.addResponse(expectedResponse);
    ProjectName projectName = ProjectName.create("[PROJECT]");
    String groupId = "groupId506361563";
    ListEventsPagedResponse pagedListResponse = client.listEvents(projectName, groupId);
    List<ErrorEvent> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getErrorEventsList().get(0), resources.get(0));
    List<GeneratedMessageV3> actualRequests = mockErrorStatsService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListEventsRequest actualRequest = (ListEventsRequest) actualRequests.get(0);
    Assert.assertEquals(projectName, actualRequest.getProjectNameAsProjectName());
    Assert.assertEquals(groupId, actualRequest.getGroupId());
}
Also used : ListEventsResponse(com.google.devtools.clouderrorreporting.v1beta1.ListEventsResponse) ProjectName(com.google.devtools.clouderrorreporting.v1beta1.ProjectName) ListEventsRequest(com.google.devtools.clouderrorreporting.v1beta1.ListEventsRequest) ErrorEvent(com.google.devtools.clouderrorreporting.v1beta1.ErrorEvent) ListEventsPagedResponse(com.google.cloud.errorreporting.spi.v1beta1.PagedResponseWrappers.ListEventsPagedResponse) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Aggregations

ListEventsPagedResponse (com.google.cloud.errorreporting.spi.v1beta1.PagedResponseWrappers.ListEventsPagedResponse)1 ErrorEvent (com.google.devtools.clouderrorreporting.v1beta1.ErrorEvent)1 ListEventsRequest (com.google.devtools.clouderrorreporting.v1beta1.ListEventsRequest)1 ListEventsResponse (com.google.devtools.clouderrorreporting.v1beta1.ListEventsResponse)1 ProjectName (com.google.devtools.clouderrorreporting.v1beta1.ProjectName)1 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)1 Test (org.junit.Test)1