use of com.google.cloud.talent.v4.ProjectName in project java-dlp by googleapis.
the class DlpServiceClientTest method listStoredInfoTypesTest4.
@Test
public void listStoredInfoTypesTest4() throws Exception {
StoredInfoType responsesElement = StoredInfoType.newBuilder().build();
ListStoredInfoTypesResponse expectedResponse = ListStoredInfoTypesResponse.newBuilder().setNextPageToken("").addAllStoredInfoTypes(Arrays.asList(responsesElement)).build();
mockDlpService.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
ListStoredInfoTypesPagedResponse pagedListResponse = client.listStoredInfoTypes(parent);
List<StoredInfoType> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getStoredInfoTypesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockDlpService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListStoredInfoTypesRequest actualRequest = ((ListStoredInfoTypesRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.talent.v4.ProjectName in project java-dlp by googleapis.
the class DlpServiceClientTest method listInspectTemplatesExceptionTest4.
@Test
public void listInspectTemplatesExceptionTest4() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockDlpService.addException(exception);
try {
ProjectName parent = ProjectName.of("[PROJECT]");
client.listInspectTemplates(parent);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.cloud.talent.v4.ProjectName in project java-dlp by googleapis.
the class DlpServiceClientTest method createDlpJobTest4.
@Test
public void createDlpJobTest4() throws Exception {
DlpJob expectedResponse = DlpJob.newBuilder().setName(DlpJobName.ofProjectDlpJobName("[PROJECT]", "[DLP_JOB]").toString()).setType(DlpJobType.forNumber(0)).setCreateTime(Timestamp.newBuilder().build()).setStartTime(Timestamp.newBuilder().build()).setEndTime(Timestamp.newBuilder().build()).setJobTriggerName("jobTriggerName494333030").addAllErrors(new ArrayList<Error>()).build();
mockDlpService.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
RiskAnalysisJobConfig riskJob = RiskAnalysisJobConfig.newBuilder().build();
DlpJob actualResponse = client.createDlpJob(parent, riskJob);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockDlpService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateDlpJobRequest actualRequest = ((CreateDlpJobRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(riskJob, actualRequest.getRiskJob());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.talent.v4.ProjectName in project java-dlp by googleapis.
the class DlpServiceClientTest method listJobTriggersTest2.
@Test
public void listJobTriggersTest2() throws Exception {
JobTrigger responsesElement = JobTrigger.newBuilder().build();
ListJobTriggersResponse expectedResponse = ListJobTriggersResponse.newBuilder().setNextPageToken("").addAllJobTriggers(Arrays.asList(responsesElement)).build();
mockDlpService.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
ListJobTriggersPagedResponse pagedListResponse = client.listJobTriggers(parent);
List<JobTrigger> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getJobTriggersList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockDlpService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListJobTriggersRequest actualRequest = ((ListJobTriggersRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.talent.v4.ProjectName in project java-dlp by googleapis.
the class DlpServiceClientTest method createDeidentifyTemplateTest4.
@Test
public void createDeidentifyTemplateTest4() 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);
ProjectName parent = ProjectName.of("[PROJECT]");
DeidentifyTemplate deidentifyTemplate = DeidentifyTemplate.newBuilder().build();
DeidentifyTemplate actualResponse = client.createDeidentifyTemplate(parent, deidentifyTemplate);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockDlpService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateDeidentifyTemplateRequest actualRequest = ((CreateDeidentifyTemplateRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(deidentifyTemplate, actualRequest.getDeidentifyTemplate());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations