Search in sources :

Example 11 with Predicate

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

the class SelectorBuilderTest method testPredicatesBuild.

/**
 * Tests the predicate build for the ID field.
 */
@Test
public void testPredicatesBuild() {
    SelectorBuilder builder = new SelectorBuilder();
    builder = builder.equalsId(10L);
    Selector selector = builder.build();
    assertNotNull(selector.getPredicates());
    assertEquals(1, selector.getPredicates().length);
    Predicate predicate = selector.getPredicates()[0];
    assertEquals("Id", predicate.getField());
    assertEquals(PredicateOperator.EQUALS, predicate.getOperator());
    assertNotNull(predicate.getValues());
    assertEquals(1, predicate.getValues().length);
    assertEquals("10", predicate.getValues()[0]);
    checkUtilitiesState(false);
}
Also used : Selector(com.google.api.ads.adwords.axis.v201809.cm.Selector) Predicate(com.google.api.ads.adwords.axis.v201809.cm.Predicate) Test(org.junit.Test)

Example 12 with Predicate

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

the class SelectorBuilderTest method testPredicatesBuild.

/**
 * Tests the predicate build for the ID field.
 */
@Test
public void testPredicatesBuild() {
    SelectorBuilder builder = new SelectorBuilder();
    builder = builder.equalsId(10L);
    Selector selector = builder.build();
    assertNotNull(selector.getPredicates());
    assertEquals(1, selector.getPredicates().size());
    Predicate predicate = selector.getPredicates().get(0);
    assertEquals("Id", predicate.getField());
    assertEquals(PredicateOperator.EQUALS, predicate.getOperator());
    assertNotNull(predicate.getValues());
    assertEquals(1, predicate.getValues().size());
    assertEquals("10", predicate.getValues().get(0));
    checkUtilitiesState(false);
}
Also used : Selector(com.google.api.ads.adwords.jaxws.v201809.cm.Selector) Predicate(com.google.api.ads.adwords.jaxws.v201809.cm.Predicate) Test(org.junit.Test)

Example 13 with Predicate

use of com.google.api.ads.adwords.jaxws.v201809.cm.Predicate 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 14 with Predicate

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

the class SelectorBuilderImpl method singleValuePredicate.

/**
 * Adds a predicate for the specified field, property value, and operator.
 */
private SelectorBuilderImpl singleValuePredicate(String field, String propertyValue, PredicateOperator operator) {
    Predicate predicate = new Predicate();
    predicate.setField(field);
    predicate.setOperator(operator);
    predicate.getValues().add(propertyValue);
    this.predicates.add(predicate);
    return this;
}
Also used : Predicate(com.google.api.ads.adwords.jaxws.v201809.cm.Predicate)

Aggregations

Predicate (com.google.api.ads.adwords.axis.v201809.cm.Predicate)7 Predicate (com.google.api.ads.adwords.jaxws.v201809.cm.Predicate)7 Test (org.junit.Test)6 Selector (com.google.api.ads.adwords.axis.v201809.cm.Selector)4 Selector (com.google.api.ads.adwords.jaxws.v201809.cm.Selector)4 DateRange (com.google.api.ads.adwords.axis.v201809.cm.DateRange)1 OrderBy (com.google.api.ads.adwords.axis.v201809.cm.OrderBy)1 Paging (com.google.api.ads.adwords.axis.v201809.cm.Paging)1 DateRange (com.google.api.ads.adwords.jaxws.v201809.cm.DateRange)1 OrderBy (com.google.api.ads.adwords.jaxws.v201809.cm.OrderBy)1 Paging (com.google.api.ads.adwords.jaxws.v201809.cm.Paging)1