Search in sources :

Example 6 with StoredInfoTypeName

use of com.google.privacy.dlp.v2.StoredInfoTypeName in project java-dlp by googleapis.

the class DlpServiceClientTest method deleteStoredInfoTypeExceptionTest.

@Test
public void deleteStoredInfoTypeExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockDlpService.addException(exception);
    try {
        StoredInfoTypeName name = StoredInfoTypeName.ofOrganizationStoredInfoTypeName("[ORGANIZATION]", "[STORED_INFO_TYPE]");
        client.deleteStoredInfoType(name);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) StoredInfoTypeName(com.google.privacy.dlp.v2.StoredInfoTypeName) Test(org.junit.Test)

Example 7 with StoredInfoTypeName

use of com.google.privacy.dlp.v2.StoredInfoTypeName in project java-dlp by googleapis.

the class DlpServiceClientTest method deleteStoredInfoTypeTest.

@Test
public void deleteStoredInfoTypeTest() throws Exception {
    Empty expectedResponse = Empty.newBuilder().build();
    mockDlpService.addResponse(expectedResponse);
    StoredInfoTypeName name = StoredInfoTypeName.ofOrganizationStoredInfoTypeName("[ORGANIZATION]", "[STORED_INFO_TYPE]");
    client.deleteStoredInfoType(name);
    List<AbstractMessage> actualRequests = mockDlpService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    DeleteStoredInfoTypeRequest actualRequest = ((DeleteStoredInfoTypeRequest) 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) DeleteStoredInfoTypeRequest(com.google.privacy.dlp.v2.DeleteStoredInfoTypeRequest) StoredInfoTypeName(com.google.privacy.dlp.v2.StoredInfoTypeName) Test(org.junit.Test)

Aggregations

StoredInfoTypeName (com.google.privacy.dlp.v2.StoredInfoTypeName)6 Test (org.junit.Test)6 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)3 AbstractMessage (com.google.protobuf.AbstractMessage)3 StatusRuntimeException (io.grpc.StatusRuntimeException)3 DeleteStoredInfoTypeRequest (com.google.privacy.dlp.v2.DeleteStoredInfoTypeRequest)2 StoredInfoType (com.google.privacy.dlp.v2.StoredInfoType)2 StoredInfoTypeConfig (com.google.privacy.dlp.v2.StoredInfoTypeConfig)2 FieldMask (com.google.protobuf.FieldMask)2 ArrayList (java.util.ArrayList)2 GetStoredInfoTypeRequest (com.google.privacy.dlp.v2.GetStoredInfoTypeRequest)1 UpdateStoredInfoTypeRequest (com.google.privacy.dlp.v2.UpdateStoredInfoTypeRequest)1 Empty (com.google.protobuf.Empty)1