Search in sources :

Example 1 with AdGroupBidLandscapePage

use of com.google.api.ads.adwords.axis.v201809.cm.AdGroupBidLandscapePage in project googleads-java-lib by googleads.

the class ServiceQueryTest method testNextPageWithNullEntriesOnAdGroupBidLandscapePage.

/**
 * Tests using {@link ServiceQuery#nextPage(AdGroupBidLandscapePage)} when the passed page has
 * a null {@code entries} array.
 */
@Test
public void testNextPageWithNullEntriesOnAdGroupBidLandscapePage() {
    AdGroupBidLandscapePage page = new AdGroupBidLandscapePage();
    page.setEntries(null);
    serviceQuery.nextPage(page);
    assertEquals(expectedAwql, serviceQuery.toString());
    // LIMIT clause stays the same as long as the page entries attribute is null.
    serviceQuery.nextPage(page);
    assertEquals(expectedAwql, serviceQuery.toString());
}
Also used : AdGroupBidLandscapePage(com.google.api.ads.adwords.axis.v201809.cm.AdGroupBidLandscapePage) Test(org.junit.Test)

Example 2 with AdGroupBidLandscapePage

use of com.google.api.ads.adwords.axis.v201809.cm.AdGroupBidLandscapePage in project googleads-java-lib by googleads.

the class ServiceQueryTest method testHasNextWithSpecifiedAdGroupBidLandscapePage.

/**
 * Tests using {@link ServiceQuery#hasNext(AdGroupBidLandscapePage)} to check if there is still a
 * next page.
 */
@Test
public void testHasNextWithSpecifiedAdGroupBidLandscapePage() {
    // First iteration. There are no previous pages.
    AdGroupBidLandscapePage page = null;
    assertTrue(serviceQuery.hasNext(page));
    // Make ad group bid landscape page contain 400 bid landscape points (200 per ad group bid
    // landscape point).
    int numBidLandscapePoints = 200;
    BidLandscapeLandscapePoint bidLandscapeLandscapePoint = new BidLandscapeLandscapePoint();
    List<BidLandscapeLandscapePoint> bidLandscapeLandscapePoints = new ArrayList<>();
    bidLandscapeLandscapePoints.addAll(Collections.nCopies(numBidLandscapePoints, bidLandscapeLandscapePoint));
    AdGroupBidLandscape bidLandscape = mock(AdGroupBidLandscape.class);
    when(bidLandscape.getLandscapePoints()).thenReturn(bidLandscapeLandscapePoints.toArray(new BidLandscapeLandscapePoint[0]));
    page = mock(AdGroupBidLandscapePage.class);
    when(page.getEntries()).thenReturn(new AdGroupBidLandscape[] { 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));
}
Also used : AdGroupBidLandscapePage(com.google.api.ads.adwords.axis.v201809.cm.AdGroupBidLandscapePage) ArrayList(java.util.ArrayList) BidLandscapeLandscapePoint(com.google.api.ads.adwords.axis.v201809.cm.BidLandscapeLandscapePoint) BidLandscapeLandscapePoint(com.google.api.ads.adwords.axis.v201809.cm.BidLandscapeLandscapePoint) AdGroupBidLandscape(com.google.api.ads.adwords.axis.v201809.cm.AdGroupBidLandscape) Test(org.junit.Test)

Example 3 with AdGroupBidLandscapePage

use of com.google.api.ads.adwords.axis.v201809.cm.AdGroupBidLandscapePage in project googleads-java-lib by googleads.

the class ServiceQueryTest method testHasNextWithEmptyEntriesOnAdGroupBidLandscapePage.

/**
 * Tests {@link ServiceQuery#hasNext(AdGroupBidLandscapePage)} when the page has an empty {@code
 * entries} list.
 */
@Test
public void testHasNextWithEmptyEntriesOnAdGroupBidLandscapePage() {
    AdGroupBidLandscapePage page = new AdGroupBidLandscapePage();
    assertFalse("hasNext should return false if entries is null", serviceQuery.hasNext(page));
    assertEquals("AWQL should not change after calling hasNext", expectedAwql, serviceQuery.toString());
}
Also used : AdGroupBidLandscapePage(com.google.api.ads.adwords.jaxws.v201809.cm.AdGroupBidLandscapePage) Test(org.junit.Test)

Example 4 with AdGroupBidLandscapePage

use of com.google.api.ads.adwords.axis.v201809.cm.AdGroupBidLandscapePage in project googleads-java-lib by googleads.

the class ServiceQueryTest method testNextPageWithSpecifiedAdGroupBidLandscapePage.

/**
 * Tests using {@link ServiceQuery#nextPage(AdGroupBidLandscapePage)} ] to get a next page of the
 * result by specifying the previous ad group bid landscape page.
 */
@Test
public void testNextPageWithSpecifiedAdGroupBidLandscapePage() {
    // Make ad group bid landscape page contain 400 bid landscape points (200 per ad group bid
    // landscape point).
    int numBidLandscapePoints = 200;
    BidLandscapeLandscapePoint bidLandscapeLandscapePoint = new BidLandscapeLandscapePoint();
    List<BidLandscapeLandscapePoint> bidLandscapeLandscapePoints = new ArrayList<>();
    bidLandscapeLandscapePoints.addAll(Collections.nCopies(numBidLandscapePoints, bidLandscapeLandscapePoint));
    AdGroupBidLandscape bidLandscape = mock(AdGroupBidLandscape.class);
    when(bidLandscape.getLandscapePoints()).thenReturn(bidLandscapeLandscapePoints.toArray(new BidLandscapeLandscapePoint[0]));
    AdGroupBidLandscapePage page = mock(AdGroupBidLandscapePage.class);
    when(page.getEntries()).thenReturn(new AdGroupBidLandscape[] { bidLandscape, bidLandscape });
    expectedAwql = "SELECT Id, Name WHERE Status = \"ENABLED\" ORDER BY Name DESC LIMIT 400,100";
    serviceQuery.nextPage(page);
    assertEquals(expectedAwql, serviceQuery.toString());
}
Also used : AdGroupBidLandscapePage(com.google.api.ads.adwords.axis.v201809.cm.AdGroupBidLandscapePage) ArrayList(java.util.ArrayList) BidLandscapeLandscapePoint(com.google.api.ads.adwords.axis.v201809.cm.BidLandscapeLandscapePoint) BidLandscapeLandscapePoint(com.google.api.ads.adwords.axis.v201809.cm.BidLandscapeLandscapePoint) AdGroupBidLandscape(com.google.api.ads.adwords.axis.v201809.cm.AdGroupBidLandscape) Test(org.junit.Test)

Example 5 with AdGroupBidLandscapePage

use of com.google.api.ads.adwords.axis.v201809.cm.AdGroupBidLandscapePage in project googleads-java-lib by googleads.

the class ServiceQueryTest method testHasNextWithNullEntriesOnAdGroupBidLandscapePage.

/**
 * Tests {@link ServiceQuery#hasNext(AdGroupBidLandscapePage)} when the page has a null {@code
 * entries} array.
 */
@Test
public void testHasNextWithNullEntriesOnAdGroupBidLandscapePage() {
    AdGroupBidLandscapePage page = new AdGroupBidLandscapePage();
    page.setEntries(null);
    assertFalse("hasNext should return false if entries is null", serviceQuery.hasNext(page));
    assertEquals("AWQL should not change after calling hasNext", expectedAwql, serviceQuery.toString());
}
Also used : AdGroupBidLandscapePage(com.google.api.ads.adwords.axis.v201809.cm.AdGroupBidLandscapePage) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)10 AdGroupBidLandscapePage (com.google.api.ads.adwords.axis.v201809.cm.AdGroupBidLandscapePage)5 AdGroupBidLandscapePage (com.google.api.ads.adwords.jaxws.v201809.cm.AdGroupBidLandscapePage)5 ArrayList (java.util.ArrayList)4 AdGroupBidLandscape (com.google.api.ads.adwords.axis.v201809.cm.AdGroupBidLandscape)2 BidLandscapeLandscapePoint (com.google.api.ads.adwords.axis.v201809.cm.BidLandscapeLandscapePoint)2 AdGroupBidLandscape (com.google.api.ads.adwords.jaxws.v201809.cm.AdGroupBidLandscape)2 BidLandscapeLandscapePoint (com.google.api.ads.adwords.jaxws.v201809.cm.BidLandscapeLandscapePoint)2