Search in sources :

Example 11 with ProductBrand

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));
}
Also used : ProductBrand(com.google.api.ads.adwords.axis.v201809.cm.ProductBrand) ProductCanonicalCondition(com.google.api.ads.adwords.axis.v201809.cm.ProductCanonicalCondition) Test(org.junit.Test)

Example 12 with ProductBrand

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;
}
Also used : ProductBrand(com.google.api.ads.adwords.axis.v201809.cm.ProductBrand)

Example 13 with 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));
}
Also used : ProductBrand(com.google.api.ads.adwords.axis.v201809.cm.ProductBrand) BiddableAdGroupCriterion(com.google.api.ads.adwords.axis.v201809.cm.BiddableAdGroupCriterion) BiddableAdGroupCriterion(com.google.api.ads.adwords.axis.v201809.cm.BiddableAdGroupCriterion) NegativeAdGroupCriterion(com.google.api.ads.adwords.axis.v201809.cm.NegativeAdGroupCriterion) AdGroupCriterion(com.google.api.ads.adwords.axis.v201809.cm.AdGroupCriterion) MockHttpIntegrationTest(com.google.api.ads.common.lib.testing.MockHttpIntegrationTest) Test(org.junit.Test)

Aggregations

ProductBrand (com.google.api.ads.adwords.axis.v201809.cm.ProductBrand)13 Test (org.junit.Test)11 AdGroupCriterion (com.google.api.ads.adwords.axis.v201809.cm.AdGroupCriterion)2 BiddableAdGroupCriterion (com.google.api.ads.adwords.axis.v201809.cm.BiddableAdGroupCriterion)2 NegativeAdGroupCriterion (com.google.api.ads.adwords.axis.v201809.cm.NegativeAdGroupCriterion)2 ProductCanonicalCondition (com.google.api.ads.adwords.axis.v201809.cm.ProductCanonicalCondition)2 MockHttpIntegrationTest (com.google.api.ads.common.lib.testing.MockHttpIntegrationTest)2 AdGroupCriterionOperation (com.google.api.ads.adwords.axis.v201809.cm.AdGroupCriterionOperation)1 CampaignCriterion (com.google.api.ads.adwords.axis.v201809.cm.CampaignCriterion)1 CampaignCriterionOperation (com.google.api.ads.adwords.axis.v201809.cm.CampaignCriterionOperation)1 CampaignCriterionReturnValue (com.google.api.ads.adwords.axis.v201809.cm.CampaignCriterionReturnValue)1 CampaignCriterionServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.CampaignCriterionServiceInterface)1 ProductBiddingCategory (com.google.api.ads.adwords.axis.v201809.cm.ProductBiddingCategory)1 ProductCustomAttribute (com.google.api.ads.adwords.axis.v201809.cm.ProductCustomAttribute)1 ProductDimension (com.google.api.ads.adwords.axis.v201809.cm.ProductDimension)1 ProductOfferId (com.google.api.ads.adwords.axis.v201809.cm.ProductOfferId)1 ProductScope (com.google.api.ads.adwords.axis.v201809.cm.ProductScope)1 ProductType (com.google.api.ads.adwords.axis.v201809.cm.ProductType)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1