Search in sources :

Example 6 with Paging

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

the class SelectorBuilderTest method testPagingAndLimits.

/**
 * Tests the offset, limit and paging logic of the builder.
 */
@Test
public void testPagingAndLimits() {
    SelectorBuilder builder = new SelectorBuilder();
    builder = builder.offset(10);
    Selector selector = builder.build();
    assertNotNull(selector.getPaging());
    assertNotNull(selector.getPaging().getStartIndex());
    assertNull(selector.getPaging().getNumberResults());
    assertEquals(10, selector.getPaging().getStartIndex().intValue());
    selector = builder.offset(10).limit(20).build();
    assertNotNull(selector.getPaging());
    assertNotNull(selector.getPaging().getStartIndex());
    assertNotNull(selector.getPaging().getNumberResults());
    assertEquals(10, selector.getPaging().getStartIndex().intValue());
    assertEquals(20, selector.getPaging().getNumberResults().intValue());
    selector = builder.offset(10).limit(20).increaseOffsetBy(5).build();
    assertNotNull(selector.getPaging());
    assertNotNull(selector.getPaging().getStartIndex());
    assertNotNull(selector.getPaging().getNumberResults());
    assertEquals(15, selector.getPaging().getStartIndex().intValue());
    assertEquals(20, selector.getPaging().getNumberResults().intValue());
    selector = builder.offset(10).limit(20).removeLimitAndOffset().build();
    assertNull(selector.getPaging());
    selector = builder.offset(10).limit(20).removeLimitAndOffset().offset(55).limit(4).build();
    assertNotNull(selector.getPaging());
    assertNotNull(selector.getPaging().getStartIndex());
    assertNotNull(selector.getPaging().getNumberResults());
    assertEquals(55, selector.getPaging().getStartIndex().intValue());
    assertEquals(4, selector.getPaging().getNumberResults().intValue());
    checkUtilitiesState(false);
}
Also used : Selector(com.google.api.ads.adwords.jaxws.v201809.cm.Selector) Test(org.junit.Test)

Example 7 with Paging

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

the class SelectorBuilderImpl method build.

@Override
public Selector build() {
    Selector selectorCopy = new Selector();
    Set<OrderBy> orderingCopy = this.copyOrderingSet();
    Set<Predicate> predicatesCopy = this.copyPredicatesSet();
    selectorCopy.getFields().addAll(Sets.newLinkedHashSet(this.fields));
    selectorCopy.getOrdering().addAll(orderingCopy);
    selectorCopy.getPredicates().addAll(predicatesCopy);
    if (this.dateRange != null) {
        DateRange newDateRange = new DateRange();
        newDateRange.setMin(this.dateRange.getMin());
        newDateRange.setMax(this.dateRange.getMax());
        selectorCopy.setDateRange(newDateRange);
    }
    if (this.paging != null) {
        Paging newPaging = new Paging();
        newPaging.setStartIndex(this.paging.getStartIndex());
        newPaging.setNumberResults(this.paging.getNumberResults());
        selectorCopy.setPaging(newPaging);
    }
    return selectorCopy;
}
Also used : OrderBy(com.google.api.ads.adwords.jaxws.v201809.cm.OrderBy) DateRange(com.google.api.ads.adwords.jaxws.v201809.cm.DateRange) Paging(com.google.api.ads.adwords.jaxws.v201809.cm.Paging) Selector(com.google.api.ads.adwords.jaxws.v201809.cm.Selector) Predicate(com.google.api.ads.adwords.jaxws.v201809.cm.Predicate)

Example 8 with Paging

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

the class SelectorBuilderImpl method increaseOffsetBy.

@Override
public SelectorBuilderImpl increaseOffsetBy(int additionalOffset) {
    if (this.paging == null) {
        this.paging = new Paging();
    }
    Integer startIndex = this.paging.getStartIndex();
    if (startIndex == null) {
        startIndex = 0;
    }
    this.paging.setStartIndex(startIndex + additionalOffset);
    return this;
}
Also used : Paging(com.google.api.ads.adwords.jaxws.v201809.cm.Paging)

Aggregations

Paging (com.google.api.ads.adwords.axis.v201809.cm.Paging)4 Selector (com.google.api.ads.adwords.jaxws.v201809.cm.Selector)3 Selector (com.google.api.ads.adwords.axis.v201809.cm.Selector)2 Paging (com.google.api.ads.adwords.jaxws.v201809.cm.Paging)2 Test (org.junit.Test)2 Campaign (com.google.api.ads.adwords.axis.v201809.cm.Campaign)1 CampaignPage (com.google.api.ads.adwords.axis.v201809.cm.CampaignPage)1 CampaignServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.CampaignServiceInterface)1 DateRange (com.google.api.ads.adwords.axis.v201809.cm.DateRange)1 Language (com.google.api.ads.adwords.axis.v201809.cm.Language)1 Money (com.google.api.ads.adwords.axis.v201809.cm.Money)1 NetworkSetting (com.google.api.ads.adwords.axis.v201809.cm.NetworkSetting)1 OrderBy (com.google.api.ads.adwords.axis.v201809.cm.OrderBy)1 Predicate (com.google.api.ads.adwords.axis.v201809.cm.Predicate)1 Attribute (com.google.api.ads.adwords.axis.v201809.o.Attribute)1 AttributeType (com.google.api.ads.adwords.axis.v201809.o.AttributeType)1 DoubleAttribute (com.google.api.ads.adwords.axis.v201809.o.DoubleAttribute)1 IntegerSetAttribute (com.google.api.ads.adwords.axis.v201809.o.IntegerSetAttribute)1 LanguageSearchParameter (com.google.api.ads.adwords.axis.v201809.o.LanguageSearchParameter)1 LongAttribute (com.google.api.ads.adwords.axis.v201809.o.LongAttribute)1