use of com.google.logging.v2.FolderLocationName in project java-logging by googleapis.
the class ConfigClientTest method listBucketsTest2.
@Test
public void listBucketsTest2() throws Exception {
LogBucket responsesElement = LogBucket.newBuilder().build();
ListBucketsResponse expectedResponse = ListBucketsResponse.newBuilder().setNextPageToken("").addAllBuckets(Arrays.asList(responsesElement)).build();
mockConfigServiceV2.addResponse(expectedResponse);
FolderLocationName parent = FolderLocationName.of("[FOLDER]", "[LOCATION]");
ListBucketsPagedResponse pagedListResponse = client.listBuckets(parent);
List<LogBucket> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getBucketsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListBucketsRequest actualRequest = ((ListBucketsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.logging.v2.FolderLocationName in project java-logging by googleapis.
the class ConfigClientTest method listBucketsExceptionTest2.
@Test
public void listBucketsExceptionTest2() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockConfigServiceV2.addException(exception);
try {
FolderLocationName parent = FolderLocationName.of("[FOLDER]", "[LOCATION]");
client.listBuckets(parent);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
Aggregations