use of com.google.logging.v2.OrganizationLocationName in project java-dlp by googleapis.
the class DlpServiceClientTest method listInspectTemplatesTest2.
@Test
public void listInspectTemplatesTest2() throws Exception {
InspectTemplate responsesElement = InspectTemplate.newBuilder().build();
ListInspectTemplatesResponse expectedResponse = ListInspectTemplatesResponse.newBuilder().setNextPageToken("").addAllInspectTemplates(Arrays.asList(responsesElement)).build();
mockDlpService.addResponse(expectedResponse);
OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]");
ListInspectTemplatesPagedResponse pagedListResponse = client.listInspectTemplates(parent);
List<InspectTemplate> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getInspectTemplatesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockDlpService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListInspectTemplatesRequest actualRequest = ((ListInspectTemplatesRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.logging.v2.OrganizationLocationName in project java-dlp by googleapis.
the class DlpServiceClientTest method createDeidentifyTemplateTest2.
@Test
public void createDeidentifyTemplateTest2() 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);
OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]");
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()));
}
use of com.google.logging.v2.OrganizationLocationName in project java-dlp by googleapis.
the class DlpServiceClientTest method createStoredInfoTypeTest2.
@Test
public void createStoredInfoTypeTest2() 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);
OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[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.OrganizationLocationName in project java-dlp by googleapis.
the class DlpServiceClientTest method listInspectTemplatesExceptionTest2.
@Test
public void listInspectTemplatesExceptionTest2() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockDlpService.addException(exception);
try {
OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]");
client.listInspectTemplates(parent);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.logging.v2.OrganizationLocationName in project gapic-generator-java by googleapis.
the class ConfigClientTest method listBucketsExceptionTest4.
@Test
public void listBucketsExceptionTest4() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockConfigServiceV2.addException(exception);
try {
OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]");
client.listBuckets(parent);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
Aggregations