Search in sources :

Example 1 with DeleteBucketRequest

use of com.google.storage.v2.DeleteBucketRequest in project java-logging by googleapis.

the class ConfigClientTest method deleteBucketTest.

@Test
public void deleteBucketTest() throws Exception {
    Empty expectedResponse = Empty.newBuilder().build();
    mockConfigServiceV2.addResponse(expectedResponse);
    DeleteBucketRequest request = DeleteBucketRequest.newBuilder().setName(LogBucketName.ofProjectLocationBucketName("[PROJECT]", "[LOCATION]", "[BUCKET]").toString()).build();
    client.deleteBucket(request);
    List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    DeleteBucketRequest actualRequest = ((DeleteBucketRequest) actualRequests.get(0));
    Assert.assertEquals(request.getName(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Empty(com.google.protobuf.Empty) AbstractMessage(com.google.protobuf.AbstractMessage) DeleteBucketRequest(com.google.logging.v2.DeleteBucketRequest) Test(org.junit.Test)

Example 2 with DeleteBucketRequest

use of com.google.storage.v2.DeleteBucketRequest in project gapic-generator-java by googleapis.

the class ConfigClientTest method deleteBucketExceptionTest.

@Test
public void deleteBucketExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockConfigServiceV2.addException(exception);
    try {
        DeleteBucketRequest request = DeleteBucketRequest.newBuilder().setName(LogBucketName.ofProjectLocationBucketName("[PROJECT]", "[LOCATION]", "[BUCKET]").toString()).build();
        client.deleteBucket(request);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) DeleteBucketRequest(com.google.logging.v2.DeleteBucketRequest) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Example 3 with DeleteBucketRequest

use of com.google.storage.v2.DeleteBucketRequest in project gapic-generator-java by googleapis.

the class ConfigClientTest method deleteBucketTest.

@Test
public void deleteBucketTest() throws Exception {
    Empty expectedResponse = Empty.newBuilder().build();
    mockConfigServiceV2.addResponse(expectedResponse);
    DeleteBucketRequest request = DeleteBucketRequest.newBuilder().setName(LogBucketName.ofProjectLocationBucketName("[PROJECT]", "[LOCATION]", "[BUCKET]").toString()).build();
    client.deleteBucket(request);
    List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    DeleteBucketRequest actualRequest = ((DeleteBucketRequest) actualRequests.get(0));
    Assert.assertEquals(request.getName(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Empty(com.google.protobuf.Empty) AbstractMessage(com.google.protobuf.AbstractMessage) DeleteBucketRequest(com.google.logging.v2.DeleteBucketRequest) Test(org.junit.Test)

Example 4 with DeleteBucketRequest

use of com.google.storage.v2.DeleteBucketRequest in project gapic-generator-java by googleapis.

the class AsyncDeleteBucket method asyncDeleteBucket.

public static void asyncDeleteBucket() throws Exception {
    // It may require modifications to work in your environment.
    try (ConfigClient configClient = ConfigClient.create()) {
        DeleteBucketRequest request = DeleteBucketRequest.newBuilder().setName(LogBucketName.ofProjectLocationBucketName("[PROJECT]", "[LOCATION]", "[BUCKET]").toString()).build();
        ApiFuture<Empty> future = configClient.deleteBucketCallable().futureCall(request);
        // Do something.
        future.get();
    }
}
Also used : ConfigClient(com.google.cloud.logging.v2.ConfigClient) Empty(com.google.protobuf.Empty) DeleteBucketRequest(com.google.logging.v2.DeleteBucketRequest)

Example 5 with DeleteBucketRequest

use of com.google.storage.v2.DeleteBucketRequest in project java-logging by googleapis.

the class ConfigClientTest method deleteBucketExceptionTest.

@Test
public void deleteBucketExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockConfigServiceV2.addException(exception);
    try {
        DeleteBucketRequest request = DeleteBucketRequest.newBuilder().setName(LogBucketName.ofProjectLocationBucketName("[PROJECT]", "[LOCATION]", "[BUCKET]").toString()).build();
        client.deleteBucket(request);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) DeleteBucketRequest(com.google.logging.v2.DeleteBucketRequest) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Aggregations

DeleteBucketRequest (com.google.logging.v2.DeleteBucketRequest)6 Empty (com.google.protobuf.Empty)4 Test (org.junit.Test)4 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)2 ConfigClient (com.google.cloud.logging.v2.ConfigClient)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 StatusRuntimeException (io.grpc.StatusRuntimeException)2 DeleteBucketRequest (com.google.storage.v2.DeleteBucketRequest)1 StorageClient (com.google.storage.v2.StorageClient)1