Search in sources :

Example 1 with QueryTimeRange

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

the class ErrorStatsServiceClientTest method listGroupStatsTest.

@Test
@SuppressWarnings("all")
public void listGroupStatsTest() {
    String nextPageToken = "";
    ErrorGroupStats errorGroupStatsElement = ErrorGroupStats.newBuilder().build();
    List<ErrorGroupStats> errorGroupStats = Arrays.asList(errorGroupStatsElement);
    ListGroupStatsResponse expectedResponse = ListGroupStatsResponse.newBuilder().setNextPageToken(nextPageToken).addAllErrorGroupStats(errorGroupStats).build();
    mockErrorStatsService.addResponse(expectedResponse);
    ProjectName projectName = ProjectName.create("[PROJECT]");
    QueryTimeRange timeRange = QueryTimeRange.newBuilder().build();
    ListGroupStatsPagedResponse pagedListResponse = client.listGroupStats(projectName, timeRange);
    List<ErrorGroupStats> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getErrorGroupStatsList().get(0), resources.get(0));
    List<GeneratedMessageV3> actualRequests = mockErrorStatsService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListGroupStatsRequest actualRequest = (ListGroupStatsRequest) actualRequests.get(0);
    Assert.assertEquals(projectName, actualRequest.getProjectNameAsProjectName());
    Assert.assertEquals(timeRange, actualRequest.getTimeRange());
}
Also used : ErrorGroupStats(com.google.devtools.clouderrorreporting.v1beta1.ErrorGroupStats) ListGroupStatsRequest(com.google.devtools.clouderrorreporting.v1beta1.ListGroupStatsRequest) ProjectName(com.google.devtools.clouderrorreporting.v1beta1.ProjectName) ListGroupStatsResponse(com.google.devtools.clouderrorreporting.v1beta1.ListGroupStatsResponse) ListGroupStatsPagedResponse(com.google.cloud.errorreporting.spi.v1beta1.PagedResponseWrappers.ListGroupStatsPagedResponse) QueryTimeRange(com.google.devtools.clouderrorreporting.v1beta1.QueryTimeRange) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Example 2 with QueryTimeRange

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

the class ErrorStatsServiceClientTest method listGroupStatsExceptionTest.

@Test
@SuppressWarnings("all")
public void listGroupStatsExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
    mockErrorStatsService.addException(exception);
    try {
        ProjectName projectName = ProjectName.create("[PROJECT]");
        QueryTimeRange timeRange = QueryTimeRange.newBuilder().build();
        client.listGroupStats(projectName, timeRange);
        Assert.fail("No exception raised");
    } catch (ApiException e) {
        Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
    }
}
Also used : ProjectName(com.google.devtools.clouderrorreporting.v1beta1.ProjectName) StatusRuntimeException(io.grpc.StatusRuntimeException) QueryTimeRange(com.google.devtools.clouderrorreporting.v1beta1.QueryTimeRange) ApiException(com.google.api.gax.grpc.ApiException) Test(org.junit.Test)

Aggregations

ProjectName (com.google.devtools.clouderrorreporting.v1beta1.ProjectName)2 QueryTimeRange (com.google.devtools.clouderrorreporting.v1beta1.QueryTimeRange)2 Test (org.junit.Test)2 ApiException (com.google.api.gax.grpc.ApiException)1 ListGroupStatsPagedResponse (com.google.cloud.errorreporting.spi.v1beta1.PagedResponseWrappers.ListGroupStatsPagedResponse)1 ErrorGroupStats (com.google.devtools.clouderrorreporting.v1beta1.ErrorGroupStats)1 ListGroupStatsRequest (com.google.devtools.clouderrorreporting.v1beta1.ListGroupStatsRequest)1 ListGroupStatsResponse (com.google.devtools.clouderrorreporting.v1beta1.ListGroupStatsResponse)1 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)1 StatusRuntimeException (io.grpc.StatusRuntimeException)1