use of com.google.api.ads.adwords.jaxws.v201809.cm.CriterionBidLandscape in project googleads-java-lib by googleads.
the class ServiceQueryTest method testHasNextWithSpecifiedCriterionBidLandscapePage.
/**
* Tests using {@link ServiceQuery#hasNext(CriterionBidLandscapePage)} to check if there is still
* a next page.
*/
@Test
public void testHasNextWithSpecifiedCriterionBidLandscapePage() {
// First iteration. There are no previous pages.
CriterionBidLandscapePage page = null;
assertTrue(serviceQuery.hasNext(page));
// Make criterion bid landscape page contain 400 bid landscape points (200 per criterion bid
// landscape point).
int numBidLandscapePoints = 200;
BidLandscapeLandscapePoint bidLandscapeLandscapePoint = new BidLandscapeLandscapePoint();
List<BidLandscapeLandscapePoint> bidLandscapeLandscapePoints = new ArrayList<>();
bidLandscapeLandscapePoints.addAll(Collections.nCopies(numBidLandscapePoints, bidLandscapeLandscapePoint));
CriterionBidLandscape bidLandscape = mock(CriterionBidLandscape.class);
when(bidLandscape.getLandscapePoints()).thenReturn(bidLandscapeLandscapePoints);
page = mock(CriterionBidLandscapePage.class);
when(page.getEntries()).thenReturn(ImmutableList.of(bidLandscape, bidLandscape));
serviceQuery = new ServiceQuery.Builder().fields("Id", "Name").limit(0, 100).build();
// 2 * 200 landscape points are greater than the page size that is 100.
assertTrue(serviceQuery.hasNext(page));
serviceQuery = new ServiceQuery.Builder().fields("Id", "Name").limit(0, 500).build();
// 2 * 200 landscape points are less than the page size that is 500.
assertFalse(serviceQuery.hasNext(page));
}
Aggregations