Search in sources :

Example 1 with UndeleteBucketRequest

use of com.google.logging.v2.UndeleteBucketRequest in project gapic-generator-java by googleapis.

the class ConfigClientTest method undeleteBucketTest.

@Test
public void undeleteBucketTest() throws Exception {
    Empty expectedResponse = Empty.newBuilder().build();
    mockConfigServiceV2.addResponse(expectedResponse);
    UndeleteBucketRequest request = UndeleteBucketRequest.newBuilder().setName(LogBucketName.ofProjectLocationBucketName("[PROJECT]", "[LOCATION]", "[BUCKET]").toString()).build();
    client.undeleteBucket(request);
    List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    UndeleteBucketRequest actualRequest = ((UndeleteBucketRequest) 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) UndeleteBucketRequest(com.google.logging.v2.UndeleteBucketRequest) Test(org.junit.Test)

Example 2 with UndeleteBucketRequest

use of com.google.logging.v2.UndeleteBucketRequest in project gapic-generator-java by googleapis.

the class ConfigClientTest method undeleteBucketExceptionTest.

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

Example 3 with UndeleteBucketRequest

use of com.google.logging.v2.UndeleteBucketRequest in project gapic-generator-java by googleapis.

the class AsyncUndeleteBucket method asyncUndeleteBucket.

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

Example 4 with UndeleteBucketRequest

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

the class ConfigClientTest method undeleteBucketExceptionTest.

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

Example 5 with UndeleteBucketRequest

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

the class ConfigClientTest method undeleteBucketTest.

@Test
public void undeleteBucketTest() throws Exception {
    Empty expectedResponse = Empty.newBuilder().build();
    mockConfigServiceV2.addResponse(expectedResponse);
    UndeleteBucketRequest request = UndeleteBucketRequest.newBuilder().setName(LogBucketName.ofProjectLocationBucketName("[PROJECT]", "[LOCATION]", "[BUCKET]").toString()).build();
    client.undeleteBucket(request);
    List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    UndeleteBucketRequest actualRequest = ((UndeleteBucketRequest) 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) UndeleteBucketRequest(com.google.logging.v2.UndeleteBucketRequest) Test(org.junit.Test)

Aggregations

UndeleteBucketRequest (com.google.logging.v2.UndeleteBucketRequest)6 Test (org.junit.Test)4 Empty (com.google.protobuf.Empty)3 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