Search in sources :

Example 11 with StoredInfoTypeConfig

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

the class DlpServiceClientTest method createStoredInfoTypeExceptionTest.

@Test
public void createStoredInfoTypeExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockDlpService.addException(exception);
    try {
        LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
        StoredInfoTypeConfig config = StoredInfoTypeConfig.newBuilder().build();
        client.createStoredInfoType(parent, config);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) StoredInfoTypeConfig(com.google.privacy.dlp.v2.StoredInfoTypeConfig) OrganizationLocationName(com.google.privacy.dlp.v2.OrganizationLocationName) LocationName(com.google.privacy.dlp.v2.LocationName) Test(org.junit.Test)

Example 12 with StoredInfoTypeConfig

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

the class DlpServiceClientTest method createStoredInfoTypeTest4.

@Test
public void createStoredInfoTypeTest4() throws Exception {
    StoredInfoType expectedResponse = StoredInfoType.newBuilder().setName(StoredInfoTypeName.ofOrganizationStoredInfoTypeName("[ORGANIZATION]", "[STORED_INFO_TYPE]").toString()).setCurrentVersion(StoredInfoTypeVersion.newBuilder().build()).addAllPendingVersions(new ArrayList<StoredInfoTypeVersion>()).build();
    mockDlpService.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    StoredInfoTypeConfig config = StoredInfoTypeConfig.newBuilder().build();
    StoredInfoType actualResponse = client.createStoredInfoType(parent, config);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockDlpService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateStoredInfoTypeRequest actualRequest = ((CreateStoredInfoTypeRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertEquals(config, actualRequest.getConfig());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) CreateStoredInfoTypeRequest(com.google.privacy.dlp.v2.CreateStoredInfoTypeRequest) ProjectName(com.google.privacy.dlp.v2.ProjectName) ArrayList(java.util.ArrayList) StoredInfoType(com.google.privacy.dlp.v2.StoredInfoType) StoredInfoTypeConfig(com.google.privacy.dlp.v2.StoredInfoTypeConfig) Test(org.junit.Test)

Example 13 with StoredInfoTypeConfig

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

the class DlpServiceClientTest method updateStoredInfoTypeTest2.

@Test
public void updateStoredInfoTypeTest2() throws Exception {
    StoredInfoType expectedResponse = StoredInfoType.newBuilder().setName(StoredInfoTypeName.ofOrganizationStoredInfoTypeName("[ORGANIZATION]", "[STORED_INFO_TYPE]").toString()).setCurrentVersion(StoredInfoTypeVersion.newBuilder().build()).addAllPendingVersions(new ArrayList<StoredInfoTypeVersion>()).build();
    mockDlpService.addResponse(expectedResponse);
    String name = "name3373707";
    StoredInfoTypeConfig config = StoredInfoTypeConfig.newBuilder().build();
    FieldMask updateMask = FieldMask.newBuilder().build();
    StoredInfoType actualResponse = client.updateStoredInfoType(name, config, updateMask);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockDlpService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    UpdateStoredInfoTypeRequest actualRequest = ((UpdateStoredInfoTypeRequest) actualRequests.get(0));
    Assert.assertEquals(name, actualRequest.getName());
    Assert.assertEquals(config, actualRequest.getConfig());
    Assert.assertEquals(updateMask, actualRequest.getUpdateMask());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) UpdateStoredInfoTypeRequest(com.google.privacy.dlp.v2.UpdateStoredInfoTypeRequest) ArrayList(java.util.ArrayList) StoredInfoType(com.google.privacy.dlp.v2.StoredInfoType) ByteString(com.google.protobuf.ByteString) StoredInfoTypeConfig(com.google.privacy.dlp.v2.StoredInfoTypeConfig) FieldMask(com.google.protobuf.FieldMask) Test(org.junit.Test)

Example 14 with StoredInfoTypeConfig

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

the class DlpServiceClientTest method createStoredInfoTypeExceptionTest4.

@Test
public void createStoredInfoTypeExceptionTest4() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockDlpService.addException(exception);
    try {
        ProjectName parent = ProjectName.of("[PROJECT]");
        StoredInfoTypeConfig config = StoredInfoTypeConfig.newBuilder().build();
        client.createStoredInfoType(parent, config);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) ProjectName(com.google.privacy.dlp.v2.ProjectName) StatusRuntimeException(io.grpc.StatusRuntimeException) StoredInfoTypeConfig(com.google.privacy.dlp.v2.StoredInfoTypeConfig) Test(org.junit.Test)

Aggregations

StoredInfoTypeConfig (com.google.privacy.dlp.v2.StoredInfoTypeConfig)14 Test (org.junit.Test)14 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)7 StoredInfoType (com.google.privacy.dlp.v2.StoredInfoType)7 AbstractMessage (com.google.protobuf.AbstractMessage)7 StatusRuntimeException (io.grpc.StatusRuntimeException)7 ArrayList (java.util.ArrayList)7 CreateStoredInfoTypeRequest (com.google.privacy.dlp.v2.CreateStoredInfoTypeRequest)5 OrganizationLocationName (com.google.privacy.dlp.v2.OrganizationLocationName)4 ByteString (com.google.protobuf.ByteString)4 FieldMask (com.google.protobuf.FieldMask)4 LocationName (com.google.privacy.dlp.v2.LocationName)2 OrganizationName (com.google.privacy.dlp.v2.OrganizationName)2 ProjectName (com.google.privacy.dlp.v2.ProjectName)2 StoredInfoTypeName (com.google.privacy.dlp.v2.StoredInfoTypeName)2 UpdateStoredInfoTypeRequest (com.google.privacy.dlp.v2.UpdateStoredInfoTypeRequest)2