use of com.google.cloud.automl.v1.LocationName in project java-dlp by googleapis.
the class DlpServiceClientTest method createDeidentifyTemplateTest.
@Test
public void createDeidentifyTemplateTest() 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);
LocationName parent = LocationName.of("[PROJECT]", "[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.cloud.automl.v1.LocationName in project java-dlp by googleapis.
the class DlpServiceClientTest method listDlpJobsExceptionTest.
@Test
public void listDlpJobsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockDlpService.addException(exception);
try {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
client.listDlpJobs(parent);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.cloud.automl.v1.LocationName in project java-logging by googleapis.
the class ConfigClientTest method listBucketsExceptionTest3.
@Test
public void listBucketsExceptionTest3() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockConfigServiceV2.addException(exception);
try {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
client.listBuckets(parent);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.cloud.automl.v1.LocationName in project java-servicedirectory by googleapis.
the class NamespacesCreate method createNamespace.
// Create a new namespace.
public static void createNamespace(String projectId, String locationId, String namespaceId) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (RegistrationServiceClient client = RegistrationServiceClient.create()) {
// The project and location to create the namespace in.
LocationName parent = LocationName.of(projectId, locationId);
// The namespace object to create. Here, we use the default instance.
Namespace namespace = Namespace.newBuilder().build();
// Send the request to create the namespace.
Namespace createdNamespace = client.createNamespace(parent, namespace, namespaceId);
// Process the response.
System.out.println("Created Namespace: " + createdNamespace.getName());
}
}
use of com.google.cloud.automl.v1.LocationName in project java-cloudbuild by googleapis.
the class CloudBuildClientTest method listWorkerPoolsTest.
@Test
public void listWorkerPoolsTest() throws Exception {
WorkerPool responsesElement = WorkerPool.newBuilder().build();
ListWorkerPoolsResponse expectedResponse = ListWorkerPoolsResponse.newBuilder().setNextPageToken("").addAllWorkerPools(Arrays.asList(responsesElement)).build();
mockCloudBuild.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListWorkerPoolsPagedResponse pagedListResponse = client.listWorkerPools(parent);
List<WorkerPool> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getWorkerPoolsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockCloudBuild.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListWorkerPoolsRequest actualRequest = ((ListWorkerPoolsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations