Search in sources :

Example 6 with OrderBy

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

the class SelectorBuilderImpl method copyOrderingSet.

/**
 * Copies the whole set of OrderBy objects, by creating new instances of each one in the given
 * set.
 *
 * @return the new set of OrderBy objects with different instance for each of the OrderBy
 */
private Set<OrderBy> copyOrderingSet() {
    Set<OrderBy> orderingCopy = Sets.newLinkedHashSet();
    for (OrderBy order : this.ordering) {
        OrderBy copyOrder = new OrderBy();
        copyOrder.setField(order.getField());
        copyOrder.setSortOrder(order.getSortOrder());
        orderingCopy.add(copyOrder);
    }
    return orderingCopy;
}
Also used : OrderBy(com.google.api.ads.adwords.jaxws.v201809.cm.OrderBy)

Example 7 with OrderBy

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

the class SelectorBuilderImpl method orderAscBy.

@Override
public SelectorBuilderImpl orderAscBy(String field) {
    OrderBy orderBy = new OrderBy();
    orderBy.setField(field);
    orderBy.setSortOrder(SortOrder.ASCENDING);
    this.ordering.add(orderBy);
    return this;
}
Also used : OrderBy(com.google.api.ads.adwords.axis.v201809.cm.OrderBy)

Example 8 with OrderBy

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

the class SelectorBuilderTest method testUniqueInternalOrderByState.

/**
 * Tests that the built selectors don't share internal OrderBy state.
 */
@Test
public void testUniqueInternalOrderByState() {
    SelectorBuilder builder = new SelectorBuilder();
    Selector selectorOne = builder.orderAscBy(CampaignField.Id).build();
    Selector selectorTwo = builder.build();
    OrderBy orderTwo = selectorTwo.getOrdering(0);
    orderTwo.setField("Status");
    assertEquals("Id", selectorOne.getOrdering(0).getField());
    assertEquals("Status", selectorTwo.getOrdering(0).getField());
    checkUtilitiesState(true);
}
Also used : OrderBy(com.google.api.ads.adwords.axis.v201809.cm.OrderBy) Selector(com.google.api.ads.adwords.axis.v201809.cm.Selector) Test(org.junit.Test)

Example 9 with OrderBy

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

the class SelectorBuilderTest method testOrderBySubstitution.

/**
 * Tests that when a repeated ORDER BY clause is added to the selector, it is actually ignored.
 */
@Test
public void testOrderBySubstitution() {
    SelectorBuilder builder = new SelectorBuilder();
    builder = builder.orderAscBy(CampaignField.AdvertisingChannelType).orderDescBy(CampaignField.Amount);
    Selector selector = builder.build();
    assertNotNull(selector.getOrdering());
    assertEquals(2, selector.getOrdering().size());
    builder.orderAscBy(CampaignField.AdvertisingChannelType);
    selector = builder.build();
    assertNotNull(selector.getOrdering());
    assertEquals(2, selector.getOrdering().size());
    OrderBy orderBy = selector.getOrdering().get(0);
    assertEquals("AdvertisingChannelType", orderBy.getField());
    assertEquals(SortOrder.ASCENDING, orderBy.getSortOrder());
    orderBy = selector.getOrdering().get(1);
    assertEquals("Amount", orderBy.getField());
    assertEquals(SortOrder.DESCENDING, orderBy.getSortOrder());
    checkUtilitiesState(true);
}
Also used : OrderBy(com.google.api.ads.adwords.jaxws.v201809.cm.OrderBy) Selector(com.google.api.ads.adwords.jaxws.v201809.cm.Selector) Test(org.junit.Test)

Example 10 with OrderBy

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

the class SelectorBuilderTest method testUniqueInternalOrderByState.

/**
 * Tests that the built selectors don't share internal OrderBy state.
 */
@Test
public void testUniqueInternalOrderByState() {
    SelectorBuilder builder = new SelectorBuilder();
    Selector selectorOne = builder.orderAscBy("Id").build();
    Selector selectorTwo = builder.build();
    OrderBy orderTwo = selectorTwo.getOrdering().get(0);
    orderTwo.setField("Status");
    assertEquals("Id", selectorOne.getOrdering().get(0).getField());
    assertEquals("Status", selectorTwo.getOrdering().get(0).getField());
    checkUtilitiesState(false);
}
Also used : OrderBy(com.google.api.ads.adwords.jaxws.v201809.cm.OrderBy) Selector(com.google.api.ads.adwords.jaxws.v201809.cm.Selector) Test(org.junit.Test)

Aggregations

OrderBy (com.google.api.ads.adwords.axis.v201809.cm.OrderBy)7 Test (org.junit.Test)6 OrderBy (com.google.api.ads.adwords.jaxws.v201809.cm.OrderBy)5 Selector (com.google.api.ads.adwords.axis.v201809.cm.Selector)4 Selector (com.google.api.ads.adwords.jaxws.v201809.cm.Selector)4 ServiceQuery (com.google.api.ads.adwords.axis.utils.v201809.ServiceQuery)2 AdGroupAd (com.google.api.ads.adwords.axis.v201809.cm.AdGroupAd)1 AdGroupAdPage (com.google.api.ads.adwords.axis.v201809.cm.AdGroupAdPage)1 AdGroupAdPolicySummary (com.google.api.ads.adwords.axis.v201809.cm.AdGroupAdPolicySummary)1 AdGroupAdServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.AdGroupAdServiceInterface)1 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 Paging (com.google.api.ads.adwords.axis.v201809.cm.Paging)1 PolicyTopicEntry (com.google.api.ads.adwords.axis.v201809.cm.PolicyTopicEntry)1 PolicyTopicEvidence (com.google.api.ads.adwords.axis.v201809.cm.PolicyTopicEvidence)1 Predicate (com.google.api.ads.adwords.axis.v201809.cm.Predicate)1 DateRange (com.google.api.ads.adwords.jaxws.v201809.cm.DateRange)1 Paging (com.google.api.ads.adwords.jaxws.v201809.cm.Paging)1