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;
}
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;
}
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);
}
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);
}
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);
}
Aggregations