Search in sources :

Example 16 with LogExclusionName

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

the class ConfigClientTest method deleteExclusionTest.

@Test
public void deleteExclusionTest() throws Exception {
    Empty expectedResponse = Empty.newBuilder().build();
    mockConfigServiceV2.addResponse(expectedResponse);
    LogExclusionName name = LogExclusionName.ofProjectExclusionName("[PROJECT]", "[EXCLUSION]");
    client.deleteExclusion(name);
    List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    DeleteExclusionRequest actualRequest = ((DeleteExclusionRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Empty(com.google.protobuf.Empty) AbstractMessage(com.google.protobuf.AbstractMessage) DeleteExclusionRequest(com.google.logging.v2.DeleteExclusionRequest) LogExclusionName(com.google.logging.v2.LogExclusionName) Test(org.junit.Test)

Example 17 with LogExclusionName

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

the class ConfigClientTest method deleteExclusionExceptionTest.

@Test
public void deleteExclusionExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockConfigServiceV2.addException(exception);
    try {
        LogExclusionName name = LogExclusionName.ofProjectExclusionName("[PROJECT]", "[EXCLUSION]");
        client.deleteExclusion(name);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) LogExclusionName(com.google.logging.v2.LogExclusionName) Test(org.junit.Test)

Aggregations

LogExclusionName (com.google.logging.v2.LogExclusionName)15 Test (org.junit.Test)12 LogExclusion (com.google.logging.v2.LogExclusion)8 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)6 AbstractMessage (com.google.protobuf.AbstractMessage)6 StatusRuntimeException (io.grpc.StatusRuntimeException)6 FieldMask (com.google.protobuf.FieldMask)5 DeleteExclusionRequest (com.google.logging.v2.DeleteExclusionRequest)4 ConfigClient (com.google.cloud.logging.v2.ConfigClient)3 GetExclusionRequest (com.google.logging.v2.GetExclusionRequest)2 UpdateExclusionRequest (com.google.logging.v2.UpdateExclusionRequest)2 Empty (com.google.protobuf.Empty)2