Search in sources :

Example 1 with ListModelsPagedResponse

use of com.google.cloud.automl.v1beta1.AutoMlClient.ListModelsPagedResponse in project java-automl by googleapis.

the class AutoMlClientTest method listModelsTest2.

@Test
public void listModelsTest2() throws Exception {
    Model responsesElement = Model.newBuilder().build();
    ListModelsResponse expectedResponse = ListModelsResponse.newBuilder().setNextPageToken("").addAllModel(Arrays.asList(responsesElement)).build();
    mockAutoMl.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListModelsPagedResponse pagedListResponse = client.listModels(parent);
    List<Model> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getModelList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockAutoMl.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListModelsRequest actualRequest = ((ListModelsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListModelsPagedResponse(com.google.cloud.automl.v1.AutoMlClient.ListModelsPagedResponse) Test(org.junit.Test)

Example 2 with ListModelsPagedResponse

use of com.google.cloud.automl.v1beta1.AutoMlClient.ListModelsPagedResponse in project java-automl by googleapis.

the class AutoMlClientTest method listModelsTest.

@Test
public void listModelsTest() throws Exception {
    Model responsesElement = Model.newBuilder().build();
    ListModelsResponse expectedResponse = ListModelsResponse.newBuilder().setNextPageToken("").addAllModel(Arrays.asList(responsesElement)).build();
    mockAutoMl.addResponse(expectedResponse);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    ListModelsPagedResponse pagedListResponse = client.listModels(parent);
    List<Model> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getModelList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockAutoMl.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListModelsRequest actualRequest = ((ListModelsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListModelsPagedResponse(com.google.cloud.automl.v1.AutoMlClient.ListModelsPagedResponse) Test(org.junit.Test)

Example 3 with ListModelsPagedResponse

use of com.google.cloud.automl.v1beta1.AutoMlClient.ListModelsPagedResponse in project java-automl by googleapis.

the class AutoMlClientTest method listModelsTest.

@Test
public void listModelsTest() throws Exception {
    Model responsesElement = Model.newBuilder().build();
    ListModelsResponse expectedResponse = ListModelsResponse.newBuilder().setNextPageToken("").addAllModel(Arrays.asList(responsesElement)).build();
    mockAutoMl.addResponse(expectedResponse);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    ListModelsPagedResponse pagedListResponse = client.listModels(parent);
    List<Model> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getModelList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockAutoMl.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListModelsRequest actualRequest = ((ListModelsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListModelsPagedResponse(com.google.cloud.automl.v1beta1.AutoMlClient.ListModelsPagedResponse) Test(org.junit.Test)

Example 4 with ListModelsPagedResponse

use of com.google.cloud.automl.v1beta1.AutoMlClient.ListModelsPagedResponse in project java-automl by googleapis.

the class AutoMlClientTest method listModelsTest2.

@Test
public void listModelsTest2() throws Exception {
    Model responsesElement = Model.newBuilder().build();
    ListModelsResponse expectedResponse = ListModelsResponse.newBuilder().setNextPageToken("").addAllModel(Arrays.asList(responsesElement)).build();
    mockAutoMl.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListModelsPagedResponse pagedListResponse = client.listModels(parent);
    List<Model> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getModelList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockAutoMl.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListModelsRequest actualRequest = ((ListModelsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListModelsPagedResponse(com.google.cloud.automl.v1beta1.AutoMlClient.ListModelsPagedResponse) Test(org.junit.Test)

Aggregations

AbstractMessage (com.google.protobuf.AbstractMessage)4 Test (org.junit.Test)4 ListModelsPagedResponse (com.google.cloud.automl.v1.AutoMlClient.ListModelsPagedResponse)2 ListModelsPagedResponse (com.google.cloud.automl.v1beta1.AutoMlClient.ListModelsPagedResponse)2