Search in sources :

Example 1 with ListDataItemsPagedResponse

use of com.google.cloud.aiplatform.v1.DatasetServiceClient.ListDataItemsPagedResponse in project java-aiplatform by googleapis.

the class DatasetServiceClientTest method listDataItemsTest.

@Test
public void listDataItemsTest() throws Exception {
    DataItem responsesElement = DataItem.newBuilder().build();
    ListDataItemsResponse expectedResponse = ListDataItemsResponse.newBuilder().setNextPageToken("").addAllDataItems(Arrays.asList(responsesElement)).build();
    mockDatasetService.addResponse(expectedResponse);
    DatasetName parent = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]");
    ListDataItemsPagedResponse pagedListResponse = client.listDataItems(parent);
    List<DataItem> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getDataItemsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockDatasetService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListDataItemsRequest actualRequest = ((ListDataItemsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListDataItemsPagedResponse(com.google.cloud.aiplatform.v1beta1.DatasetServiceClient.ListDataItemsPagedResponse) Test(org.junit.Test)

Example 2 with ListDataItemsPagedResponse

use of com.google.cloud.aiplatform.v1.DatasetServiceClient.ListDataItemsPagedResponse in project java-aiplatform by googleapis.

the class DatasetServiceClientTest method listDataItemsTest2.

@Test
public void listDataItemsTest2() throws Exception {
    DataItem responsesElement = DataItem.newBuilder().build();
    ListDataItemsResponse expectedResponse = ListDataItemsResponse.newBuilder().setNextPageToken("").addAllDataItems(Arrays.asList(responsesElement)).build();
    mockDatasetService.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListDataItemsPagedResponse pagedListResponse = client.listDataItems(parent);
    List<DataItem> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getDataItemsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockDatasetService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListDataItemsRequest actualRequest = ((ListDataItemsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListDataItemsPagedResponse(com.google.cloud.aiplatform.v1beta1.DatasetServiceClient.ListDataItemsPagedResponse) Test(org.junit.Test)

Example 3 with ListDataItemsPagedResponse

use of com.google.cloud.aiplatform.v1.DatasetServiceClient.ListDataItemsPagedResponse in project java-aiplatform by googleapis.

the class DatasetServiceClientTest method listDataItemsTest2.

@Test
public void listDataItemsTest2() throws Exception {
    DataItem responsesElement = DataItem.newBuilder().build();
    ListDataItemsResponse expectedResponse = ListDataItemsResponse.newBuilder().setNextPageToken("").addAllDataItems(Arrays.asList(responsesElement)).build();
    mockDatasetService.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListDataItemsPagedResponse pagedListResponse = client.listDataItems(parent);
    List<DataItem> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getDataItemsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockDatasetService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListDataItemsRequest actualRequest = ((ListDataItemsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListDataItemsPagedResponse(com.google.cloud.aiplatform.v1.DatasetServiceClient.ListDataItemsPagedResponse) Test(org.junit.Test)

Example 4 with ListDataItemsPagedResponse

use of com.google.cloud.aiplatform.v1.DatasetServiceClient.ListDataItemsPagedResponse in project java-aiplatform by googleapis.

the class DatasetServiceClientTest method listDataItemsTest.

@Test
public void listDataItemsTest() throws Exception {
    DataItem responsesElement = DataItem.newBuilder().build();
    ListDataItemsResponse expectedResponse = ListDataItemsResponse.newBuilder().setNextPageToken("").addAllDataItems(Arrays.asList(responsesElement)).build();
    mockDatasetService.addResponse(expectedResponse);
    DatasetName parent = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]");
    ListDataItemsPagedResponse pagedListResponse = client.listDataItems(parent);
    List<DataItem> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getDataItemsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockDatasetService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListDataItemsRequest actualRequest = ((ListDataItemsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListDataItemsPagedResponse(com.google.cloud.aiplatform.v1.DatasetServiceClient.ListDataItemsPagedResponse) Test(org.junit.Test)

Aggregations

AbstractMessage (com.google.protobuf.AbstractMessage)4 Test (org.junit.Test)4 ListDataItemsPagedResponse (com.google.cloud.aiplatform.v1.DatasetServiceClient.ListDataItemsPagedResponse)2 ListDataItemsPagedResponse (com.google.cloud.aiplatform.v1beta1.DatasetServiceClient.ListDataItemsPagedResponse)2