Search in sources :

Example 1 with UpdateDeidentifyTemplateRequest

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

the class DlpServiceClientTest method updateDeidentifyTemplateTest.

@Test
public void updateDeidentifyTemplateTest() throws Exception {
    DeidentifyTemplate expectedResponse = DeidentifyTemplate.newBuilder().setName(DeidentifyTemplateName.ofOrganizationDeidentifyTemplateName("[ORGANIZATION]", "[DEIDENTIFY_TEMPLATE]").toString()).setDisplayName("displayName1714148973").setDescription("description-1724546052").setCreateTime(Timestamp.newBuilder().build()).setUpdateTime(Timestamp.newBuilder().build()).setDeidentifyConfig(DeidentifyConfig.newBuilder().build()).build();
    mockDlpService.addResponse(expectedResponse);
    DeidentifyTemplateName name = DeidentifyTemplateName.ofOrganizationDeidentifyTemplateName("[ORGANIZATION]", "[DEIDENTIFY_TEMPLATE]");
    DeidentifyTemplate deidentifyTemplate = DeidentifyTemplate.newBuilder().build();
    FieldMask updateMask = FieldMask.newBuilder().build();
    DeidentifyTemplate actualResponse = client.updateDeidentifyTemplate(name, deidentifyTemplate, updateMask);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockDlpService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    UpdateDeidentifyTemplateRequest actualRequest = ((UpdateDeidentifyTemplateRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertEquals(deidentifyTemplate, actualRequest.getDeidentifyTemplate());
    Assert.assertEquals(updateMask, actualRequest.getUpdateMask());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : UpdateDeidentifyTemplateRequest(com.google.privacy.dlp.v2.UpdateDeidentifyTemplateRequest) AbstractMessage(com.google.protobuf.AbstractMessage) DeidentifyTemplateName(com.google.privacy.dlp.v2.DeidentifyTemplateName) FieldMask(com.google.protobuf.FieldMask) DeidentifyTemplate(com.google.privacy.dlp.v2.DeidentifyTemplate) Test(org.junit.Test)

Example 2 with UpdateDeidentifyTemplateRequest

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

the class DlpServiceClientTest method updateDeidentifyTemplateTest2.

@Test
public void updateDeidentifyTemplateTest2() throws Exception {
    DeidentifyTemplate expectedResponse = DeidentifyTemplate.newBuilder().setName(DeidentifyTemplateName.ofOrganizationDeidentifyTemplateName("[ORGANIZATION]", "[DEIDENTIFY_TEMPLATE]").toString()).setDisplayName("displayName1714148973").setDescription("description-1724546052").setCreateTime(Timestamp.newBuilder().build()).setUpdateTime(Timestamp.newBuilder().build()).setDeidentifyConfig(DeidentifyConfig.newBuilder().build()).build();
    mockDlpService.addResponse(expectedResponse);
    String name = "name3373707";
    DeidentifyTemplate deidentifyTemplate = DeidentifyTemplate.newBuilder().build();
    FieldMask updateMask = FieldMask.newBuilder().build();
    DeidentifyTemplate actualResponse = client.updateDeidentifyTemplate(name, deidentifyTemplate, updateMask);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockDlpService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    UpdateDeidentifyTemplateRequest actualRequest = ((UpdateDeidentifyTemplateRequest) actualRequests.get(0));
    Assert.assertEquals(name, actualRequest.getName());
    Assert.assertEquals(deidentifyTemplate, actualRequest.getDeidentifyTemplate());
    Assert.assertEquals(updateMask, actualRequest.getUpdateMask());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : UpdateDeidentifyTemplateRequest(com.google.privacy.dlp.v2.UpdateDeidentifyTemplateRequest) AbstractMessage(com.google.protobuf.AbstractMessage) ByteString(com.google.protobuf.ByteString) FieldMask(com.google.protobuf.FieldMask) DeidentifyTemplate(com.google.privacy.dlp.v2.DeidentifyTemplate) Test(org.junit.Test)

Aggregations

DeidentifyTemplate (com.google.privacy.dlp.v2.DeidentifyTemplate)2 UpdateDeidentifyTemplateRequest (com.google.privacy.dlp.v2.UpdateDeidentifyTemplateRequest)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 FieldMask (com.google.protobuf.FieldMask)2 Test (org.junit.Test)2 DeidentifyTemplateName (com.google.privacy.dlp.v2.DeidentifyTemplateName)1 ByteString (com.google.protobuf.ByteString)1