use of com.google.logging.v2.LocationName in project java-dlp by googleapis.
the class DlpServiceClientTest method createInspectTemplateTest.
@Test
public void createInspectTemplateTest() throws Exception {
InspectTemplate expectedResponse = InspectTemplate.newBuilder().setName(InspectTemplateName.ofOrganizationInspectTemplateName("[ORGANIZATION]", "[INSPECT_TEMPLATE]").toString()).setDisplayName("displayName1714148973").setDescription("description-1724546052").setCreateTime(Timestamp.newBuilder().build()).setUpdateTime(Timestamp.newBuilder().build()).setInspectConfig(InspectConfig.newBuilder().build()).build();
mockDlpService.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
InspectTemplate inspectTemplate = InspectTemplate.newBuilder().build();
InspectTemplate actualResponse = client.createInspectTemplate(parent, inspectTemplate);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockDlpService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateInspectTemplateRequest actualRequest = ((CreateInspectTemplateRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(inspectTemplate, actualRequest.getInspectTemplate());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.logging.v2.LocationName in project java-dlp by googleapis.
the class DlpServiceClientTest method createStoredInfoTypeTest.
@Test
public void createStoredInfoTypeTest() 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);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
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()));
}
use of com.google.logging.v2.LocationName in project java-dlp by googleapis.
the class DlpServiceClientTest method createDlpJobTest.
@Test
public void createDlpJobTest() 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);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
InspectJobConfig inspectJob = InspectJobConfig.newBuilder().build();
DlpJob actualResponse = client.createDlpJob(parent, inspectJob);
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(inspectJob, actualRequest.getInspectJob());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.logging.v2.LocationName in project java-dlp by googleapis.
the class DlpServiceClientTest method createInspectTemplateExceptionTest.
@Test
public void createInspectTemplateExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockDlpService.addException(exception);
try {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
InspectTemplate inspectTemplate = InspectTemplate.newBuilder().build();
client.createInspectTemplate(parent, inspectTemplate);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.logging.v2.LocationName in project java-dlp by googleapis.
the class DlpServiceClientTest method listStoredInfoTypesTest.
@Test
public void listStoredInfoTypesTest() throws Exception {
StoredInfoType responsesElement = StoredInfoType.newBuilder().build();
ListStoredInfoTypesResponse expectedResponse = ListStoredInfoTypesResponse.newBuilder().setNextPageToken("").addAllStoredInfoTypes(Arrays.asList(responsesElement)).build();
mockDlpService.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
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()));
}
Aggregations