/** * * * <pre> * [Optional] List only data for the given time range. * If not set a default time range is used. The field time_range_begin * in the response will specify the beginning of this time range. * </pre> * * <code>.google.devtools.clouderrorreporting.v1beta1.QueryTimeRange time_range = 4;</code> */ public Builder setTimeRange( com.google.devtools.clouderrorreporting.v1beta1.QueryTimeRange.Builder builderForValue) { if (timeRangeBuilder_ == null) { timeRange_ = builderForValue.build(); onChanged(); } else { timeRangeBuilder_.setMessage(builderForValue.build()); } return this; } /**
/** * * * <pre> * [Optional] List data for the given time range. * If not set a default time range is used. The field time_range_begin * in the response will specify the beginning of this time range. * Only <code>ErrorGroupStats</code> with a non-zero count in the given time * range are returned, unless the request contains an explicit group_id list. * If a group_id list is given, also <code>ErrorGroupStats</code> with zero * occurrences are returned. * </pre> * * <code>.google.devtools.clouderrorreporting.v1beta1.QueryTimeRange time_range = 5;</code> */ public Builder setTimeRange( com.google.devtools.clouderrorreporting.v1beta1.QueryTimeRange.Builder builderForValue) { if (timeRangeBuilder_ == null) { timeRange_ = builderForValue.build(); onChanged(); } else { timeRangeBuilder_.setMessage(builderForValue.build()); } return this; } /**
@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.of("[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, ProjectName.parse(actualRequest.getProjectName())); Assert.assertEquals(timeRange, actualRequest.getTimeRange()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
/** * * * <pre> * [Optional] List data for the given time range. * If not set a default time range is used. The field time_range_begin * in the response will specify the beginning of this time range. * Only <code>ErrorGroupStats</code> with a non-zero count in the given time * range are returned, unless the request contains an explicit group_id list. * If a group_id list is given, also <code>ErrorGroupStats</code> with zero * occurrences are returned. * </pre> * * <code>.google.devtools.clouderrorreporting.v1beta1.QueryTimeRange time_range = 5;</code> */ public Builder setTimeRange( com.google.devtools.clouderrorreporting.v1beta1.QueryTimeRange.Builder builderForValue) { if (timeRangeBuilder_ == null) { timeRange_ = builderForValue.build(); onChanged(); } else { timeRangeBuilder_.setMessage(builderForValue.build()); } return this; } /**
/** * * * <pre> * [Optional] List only data for the given time range. * If not set a default time range is used. The field time_range_begin * in the response will specify the beginning of this time range. * </pre> * * <code>.google.devtools.clouderrorreporting.v1beta1.QueryTimeRange time_range = 4;</code> */ public Builder setTimeRange( com.google.devtools.clouderrorreporting.v1beta1.QueryTimeRange.Builder builderForValue) { if (timeRangeBuilder_ == null) { timeRange_ = builderForValue.build(); onChanged(); } else { timeRangeBuilder_.setMessage(builderForValue.build()); } return this; } /**
@Test @SuppressWarnings("all") public void listGroupStatsExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockErrorStatsService.addException(exception); try { ProjectName projectName = ProjectName.of("[PROJECT]"); QueryTimeRange timeRange = QueryTimeRange.newBuilder().build(); client.listGroupStats(projectName, timeRange); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }