use of com.google.logging.v2.GetBucketRequest in project java-logging by googleapis.
the class ConfigClientTest method getBucketTest.
@Test
public void getBucketTest() throws Exception {
LogBucket expectedResponse = LogBucket.newBuilder().setName(LogBucketName.ofProjectLocationBucketName("[PROJECT]", "[LOCATION]", "[BUCKET]").toString()).setDescription("description-1724546052").setCreateTime(Timestamp.newBuilder().build()).setUpdateTime(Timestamp.newBuilder().build()).setRetentionDays(1544391896).setLocked(true).setLifecycleState(LifecycleState.forNumber(0)).addAllRestrictedFields(new ArrayList<String>()).setCmekSettings(CmekSettings.newBuilder().build()).build();
mockConfigServiceV2.addResponse(expectedResponse);
GetBucketRequest request = GetBucketRequest.newBuilder().setName(LogBucketName.ofProjectLocationBucketName("[PROJECT]", "[LOCATION]", "[BUCKET]").toString()).build();
LogBucket actualResponse = client.getBucket(request);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetBucketRequest actualRequest = ((GetBucketRequest) actualRequests.get(0));
Assert.assertEquals(request.getName(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.logging.v2.GetBucketRequest in project java-logging by googleapis.
the class ConfigClientTest method getBucketExceptionTest.
@Test
public void getBucketExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockConfigServiceV2.addException(exception);
try {
GetBucketRequest request = GetBucketRequest.newBuilder().setName(LogBucketName.ofProjectLocationBucketName("[PROJECT]", "[LOCATION]", "[BUCKET]").toString()).build();
client.getBucket(request);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
Aggregations