use of com.google.cloud.aiplatform.v1.LocationName in project java-aiplatform by googleapis.
the class ImportDataImageObjectDetectionSampleTest method setUp.
@Before
public void setUp() throws InterruptedException, ExecutionException, TimeoutException, IOException {
bout = new ByteArrayOutputStream();
out = new PrintStream(bout);
originalPrintStream = System.out;
System.setOut(out);
// create a temp dataset for importing data
DatasetServiceSettings datasetServiceSettings = DatasetServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
try (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create(datasetServiceSettings)) {
String metadataSchemaUri = "gs://google-cloud-aiplatform/schema/dataset/metadata/image_1.0.0.yaml";
LocationName locationName = LocationName.of(PROJECT, LOCATION);
Dataset dataset = Dataset.newBuilder().setDisplayName("test_dataset_display_name").setMetadataSchemaUri(metadataSchemaUri).build();
OperationFuture<Dataset, CreateDatasetOperationMetadata> datasetFuture = datasetServiceClient.createDatasetAsync(locationName, dataset);
Dataset datasetResponse = datasetFuture.get(120, TimeUnit.SECONDS);
String[] datasetValues = datasetResponse.getName().split("/");
datasetId = datasetValues[datasetValues.length - 1];
}
}
use of com.google.cloud.aiplatform.v1.LocationName in project java-aiplatform by googleapis.
the class IndexEndpointServiceClientTest method listIndexEndpointsTest.
@Test
public void listIndexEndpointsTest() throws Exception {
IndexEndpoint responsesElement = IndexEndpoint.newBuilder().build();
ListIndexEndpointsResponse expectedResponse = ListIndexEndpointsResponse.newBuilder().setNextPageToken("").addAllIndexEndpoints(Arrays.asList(responsesElement)).build();
mockIndexEndpointService.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListIndexEndpointsPagedResponse pagedListResponse = client.listIndexEndpoints(parent);
List<IndexEndpoint> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getIndexEndpointsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockIndexEndpointService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListIndexEndpointsRequest actualRequest = ((ListIndexEndpointsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.aiplatform.v1.LocationName in project java-aiplatform by googleapis.
the class MetadataServiceClientTest method listMetadataStoresTest.
@Test
public void listMetadataStoresTest() throws Exception {
MetadataStore responsesElement = MetadataStore.newBuilder().build();
ListMetadataStoresResponse expectedResponse = ListMetadataStoresResponse.newBuilder().setNextPageToken("").addAllMetadataStores(Arrays.asList(responsesElement)).build();
mockMetadataService.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListMetadataStoresPagedResponse pagedListResponse = client.listMetadataStores(parent);
List<MetadataStore> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getMetadataStoresList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockMetadataService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListMetadataStoresRequest actualRequest = ((ListMetadataStoresRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.aiplatform.v1.LocationName in project java-aiplatform by googleapis.
the class JobServiceClientTest method listHyperparameterTuningJobsTest.
@Test
public void listHyperparameterTuningJobsTest() throws Exception {
HyperparameterTuningJob responsesElement = HyperparameterTuningJob.newBuilder().build();
ListHyperparameterTuningJobsResponse expectedResponse = ListHyperparameterTuningJobsResponse.newBuilder().setNextPageToken("").addAllHyperparameterTuningJobs(Arrays.asList(responsesElement)).build();
mockJobService.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListHyperparameterTuningJobsPagedResponse pagedListResponse = client.listHyperparameterTuningJobs(parent);
List<HyperparameterTuningJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getHyperparameterTuningJobsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockJobService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListHyperparameterTuningJobsRequest actualRequest = ((ListHyperparameterTuningJobsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.aiplatform.v1.LocationName in project java-aiplatform by googleapis.
the class JobServiceClientTest method listDataLabelingJobsTest.
@Test
public void listDataLabelingJobsTest() throws Exception {
DataLabelingJob responsesElement = DataLabelingJob.newBuilder().build();
ListDataLabelingJobsResponse expectedResponse = ListDataLabelingJobsResponse.newBuilder().setNextPageToken("").addAllDataLabelingJobs(Arrays.asList(responsesElement)).build();
mockJobService.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListDataLabelingJobsPagedResponse pagedListResponse = client.listDataLabelingJobs(parent);
List<DataLabelingJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getDataLabelingJobsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockJobService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListDataLabelingJobsRequest actualRequest = ((ListDataLabelingJobsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations