use of com.google.api.ads.adwords.axis.v201809.cm.ProductBrand in project googleads-java-lib by googleads.
the class ProductPartitionNodeTest method testNavigation.
@Test
public void testNavigation() {
rootNode = rootNode.asSubdivision();
ProductBrand brandGoogle = ProductDimensions.createBrand("google");
ProductBrand brandOther = ProductDimensions.createBrand(null);
ProductCanonicalCondition conditionNew = ProductDimensions.createCanonicalCondition(ProductCanonicalConditionCondition.NEW);
ProductCanonicalCondition conditionUsed = ProductDimensions.createCanonicalCondition(ProductCanonicalConditionCondition.USED);
ProductCanonicalCondition conditionOther = ProductDimensions.createCanonicalCondition(null);
// Build up the brand = Google node under the root.
ProductPartitionNode brandGoogleNode = rootNode.addChild(brandGoogle).asSubdivision();
brandGoogleNode.addChild(conditionNew);
brandGoogleNode.addChild(conditionUsed);
brandGoogleNode.addChild(conditionOther);
assertTrue("hasChild should return true for existing child dimension", brandGoogleNode.hasChild(conditionNew));
assertSame("parent->getChild->getParent should return parent", brandGoogleNode, brandGoogleNode.getChild(conditionNew).getParent());
assertTrue("hasChild should return true for existing child dimension", brandGoogleNode.hasChild(conditionUsed));
assertSame("parent->getChild->getParent should return parent", brandGoogleNode, brandGoogleNode.getChild(conditionUsed).getParent());
assertTrue("hasChild should return true for existing child dimension", brandGoogleNode.hasChild(conditionOther));
assertSame("parent->getChild->getParent should return parent", brandGoogleNode, brandGoogleNode.getChild(conditionOther).getParent());
// Build up the brand = null (other) node under the root.
ProductPartitionNode brandOtherNode = rootNode.addChild(brandOther).asSubdivision();
brandOtherNode.addChild(conditionNew);
assertTrue("hasChild should return true for existing child dimension", brandOtherNode.hasChild(conditionNew));
assertSame("parent->getChild->getParent should return parent", brandOtherNode, brandOtherNode.getChild(conditionNew).getParent());
assertFalse("hasChild should return false for nonexistent child dimension", brandOtherNode.hasChild(conditionUsed));
assertFalse("hasChild should return false for nonexistent child dimension", brandOtherNode.hasChild(conditionOther));
brandOtherNode.addChild(conditionOther);
assertTrue("hasChild should return true for existing child dimension", brandOtherNode.hasChild(conditionOther));
assertSame("parent->getChild->getParent should return parent", brandOtherNode, brandOtherNode.getChild(conditionOther).getParent());
// Remove one of the children of brand = null.
brandOtherNode.removeChild(conditionOther);
assertFalse("hasChild should return false for a removed child dimension", brandOtherNode.hasChild(conditionOther));
// Remove the rest of the children of brand = null.
brandOtherNode.removeAllChildren();
assertFalse("hasChild should return false for any removed child dimension", brandOtherNode.hasChild(conditionNew));
assertFalse("hasChild should return false for any removed child dimension", brandOtherNode.hasChild(conditionUsed));
}
use of com.google.api.ads.adwords.axis.v201809.cm.ProductBrand in project googleads-java-lib by googleads.
the class ProductDimensions method createBrand.
/**
* Creates a new ProductBrand.
*
* @param brand may be null if creating an "other" dimension
*/
public static ProductBrand createBrand(@Nullable String brand) {
ProductBrand productBrand = new ProductBrand();
productBrand.setValue(brand);
return productBrand;
}
use of com.google.api.ads.adwords.axis.v201809.cm.ProductBrand in project googleads-java-lib by googleads.
the class ProductPartitionTreeTest method testRemovedCriteriaIgnored.
/**
* Tests that the factory method ignores removed criteria.
*/
@Test
public void testRemovedCriteriaIgnored() {
CriterionDescriptor rootDescriptor = new CriterionDescriptor(true, false, null, 1000000L, 1L, null);
List<AdGroupCriterion> criteria = Lists.newArrayList();
criteria.add(rootDescriptor.createCriterion());
// Create a criteria for a child node and set its UserStatus to REMOVED.
ProductBrand brandGoogle = ProductDimensions.createBrand("google");
CriterionDescriptor removedDescriptor = new CriterionDescriptor(true, false, brandGoogle, null, 2L, 1L);
AdGroupCriterion removedCriterion = removedDescriptor.createCriterion();
((BiddableAdGroupCriterion) removedCriterion).setUserStatus(UserStatus.REMOVED);
criteria.add(removedCriterion);
ProductPartitionTree tree = ProductPartitionTree.createAdGroupTree(-1L, biddingStrategyConfig, criteria);
assertFalse("Brand = google criteria had status removed, but it is in the tree", tree.getRoot().hasChild(brandGoogle));
}
Aggregations