use of com.google.cloud.recommender.v1beta1.RecommenderClient.ListRecommendationsPagedResponse in project java-recommender by googleapis.
the class RecommenderClientTest method listRecommendationsTest2.
@Test
public void listRecommendationsTest2() throws Exception {
Recommendation responsesElement = Recommendation.newBuilder().build();
ListRecommendationsResponse expectedResponse = ListRecommendationsResponse.newBuilder().setNextPageToken("").addAllRecommendations(Arrays.asList(responsesElement)).build();
mockRecommender.addResponse(expectedResponse);
String parent = "parent-995424086";
ListRecommendationsPagedResponse pagedListResponse = client.listRecommendations(parent);
List<Recommendation> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getRecommendationsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockRecommender.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListRecommendationsRequest actualRequest = ((ListRecommendationsRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.recommender.v1beta1.RecommenderClient.ListRecommendationsPagedResponse in project java-recommender by googleapis.
the class RecommenderClientTest method listRecommendationsTest.
@Test
public void listRecommendationsTest() throws Exception {
Recommendation responsesElement = Recommendation.newBuilder().build();
ListRecommendationsResponse expectedResponse = ListRecommendationsResponse.newBuilder().setNextPageToken("").addAllRecommendations(Arrays.asList(responsesElement)).build();
mockRecommender.addResponse(expectedResponse);
RecommenderName parent = RecommenderName.ofProjectLocationRecommenderName("[PROJECT]", "[LOCATION]", "[RECOMMENDER]");
ListRecommendationsPagedResponse pagedListResponse = client.listRecommendations(parent);
List<Recommendation> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getRecommendationsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockRecommender.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListRecommendationsRequest actualRequest = ((ListRecommendationsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations