Search in sources :

Example 6 with Predicate

use of com.google.api.ads.adwords.axis.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);
    String[] values = new String[1];
    values[0] = propertyValue;
    predicate.setValues(values);
    this.predicates.add(predicate);
    return this;
}
Also used : Predicate(com.google.api.ads.adwords.axis.v201809.cm.Predicate)

Example 7 with Predicate

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

the class SelectorBuilderTest method testUniqueInternalPredicateState.

/**
 * Tests that the built selectors don't share internal Predicate state.
 */
@Test
public void testUniqueInternalPredicateState() {
    SelectorBuilder builder = new SelectorBuilder();
    Selector selectorOne = builder.equals("Id", "test").build();
    Selector selectorTwo = builder.build();
    Predicate predicateTwo = selectorTwo.getPredicates().get(0);
    predicateTwo.setField("Status");
    assertEquals("Id", selectorOne.getPredicates().get(0).getField());
    assertEquals("Status", selectorTwo.getPredicates().get(0).getField());
    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 8 with Predicate

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

the class SelectorBuilderTest method testPredicatesInBuild.

/**
 * Tests the predicate with the IN clause.
 */
@Test
public void testPredicatesInBuild() {
    SelectorBuilder builder = new SelectorBuilder();
    builder = builder.in("Status", CampaignStatus.ENABLED.toString(), CampaignStatus.REMOVED.toString());
    Selector selector = builder.build();
    assertNotNull(selector.getPredicates());
    assertEquals(1, selector.getPredicates().size());
    Predicate predicate = selector.getPredicates().get(0);
    assertEquals("Status", predicate.getField());
    assertEquals(PredicateOperator.IN, predicate.getOperator());
    assertNotNull(predicate.getValues());
    assertEquals(2, predicate.getValues().size());
    assertEquals(CampaignStatus.ENABLED.toString(), predicate.getValues().get(0));
    assertEquals(CampaignStatus.REMOVED.toString(), predicate.getValues().get(1));
    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 9 with Predicate

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

the class SelectorBuilderImpl method copyPredicatesSet.

/**
 * Copies the whole set of predicates, by creating new instances of each one in the given set.
 *
 * @return the new set of Predicate objects with different instance for each of the Predicate
 */
private Set<Predicate> copyPredicatesSet() {
    Set<Predicate> predicatesCopy = Sets.newLinkedHashSet();
    for (Predicate predicate : this.predicates) {
        Predicate copyPredicate = new Predicate();
        copyPredicate.setField(predicate.getField());
        copyPredicate.setOperator(predicate.getOperator());
        copyPredicate.getValues().addAll(predicate.getValues());
        predicatesCopy.add(copyPredicate);
    }
    return predicatesCopy;
}
Also used : Predicate(com.google.api.ads.adwords.jaxws.v201809.cm.Predicate)

Example 10 with Predicate

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

the class SelectorBuilderImpl method multipleValuePredicate.

/**
 * Adds a predicate for the specified field, property values, and operator.
 */
private SelectorBuilderImpl multipleValuePredicate(String field, String[] propertyValues, PredicateOperator operator) {
    if (propertyValues == null) {
        return this;
    }
    Predicate predicate = new Predicate();
    predicate.setOperator(operator);
    predicate.setField(field);
    for (String propertyValue : propertyValues) {
        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)5 Selector (com.google.api.ads.adwords.jaxws.v201809.cm.Selector)4 SelectorBuilder (com.google.api.ads.adwords.axis.utils.v201809.SelectorBuilder)1 AdWordsConversionTracker (com.google.api.ads.adwords.axis.v201809.cm.AdWordsConversionTracker)1 ConversionTracker (com.google.api.ads.adwords.axis.v201809.cm.ConversionTracker)1 ConversionTrackerPage (com.google.api.ads.adwords.axis.v201809.cm.ConversionTrackerPage)1 ConversionTrackerServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.ConversionTrackerServiceInterface)1 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 AdwordsUserListServiceInterface (com.google.api.ads.adwords.axis.v201809.rm.AdwordsUserListServiceInterface)1 BasicUserList (com.google.api.ads.adwords.axis.v201809.rm.BasicUserList)1 UserList (com.google.api.ads.adwords.axis.v201809.rm.UserList)1 UserListConversionType (com.google.api.ads.adwords.axis.v201809.rm.UserListConversionType)1 UserListOperation (com.google.api.ads.adwords.axis.v201809.rm.UserListOperation)1 UserListReturnValue (com.google.api.ads.adwords.axis.v201809.rm.UserListReturnValue)1 DateRange (com.google.api.ads.adwords.jaxws.v201809.cm.DateRange)1