Search in sources :

Example 6 with ProductBrand

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

the class ProductPartitionNodeTest method testChildNodeBasicFunctionality.

@Test
public void testChildNodeBasicFunctionality() {
    rootNode = rootNode.asSubdivision();
    assertFalse("parent should not be a unit", rootNode.isUnit());
    assertTrue("parent should be a subdivision", rootNode.isSubdivision());
    ProductBrand childDimension = ProductDimensions.createBrand("google");
    ProductPartitionNode childNode = rootNode.addChild(childDimension);
    assertNotSame("getDimension should return a copy", childDimension, childNode.getDimension());
    assertEquals("dimension from getDimension should be logically equivalent to childDimension", 0, new ProductDimensionComparator().compare(childDimension, childNode.getDimension()));
    assertSame("child.getParent should return parentNode", rootNode, childNode.getParent());
    assertNull("partition ID is incorrect", childNode.getProductPartitionId());
    assertFalse("childNode should not have any children", childNode.getChildren().iterator().hasNext());
    assertTrue("new node should be a unit node by default", childNode.isUnit());
    assertTrue("new node should be a biddable unit node by default", childNode.isBiddableUnit());
    assertTrue("rootNode.hasChild should return true when passed the dimension of the added child", rootNode.hasChild(childDimension));
    assertFalse("rootNode.hasChild should return false when passed a dimension for a nonexistent " + "child", rootNode.hasChild(ProductDimensions.createBrand("xyz")));
    assertFalse("rootNode.hasChild should return false when passed a dimension for a nonexistent " + "child", rootNode.hasChild(null));
    String childToString = childNode.toString();
    assertNotNull("child toString returned null", childToString);
    String parentDetailedToString = rootNode.toDetailedString();
    assertThat("Parent toDetailedString does not contain the child's toString", parentDetailedToString, Matchers.containsString(childToString));
    String parentToString = rootNode.toString();
    assertNotNull("parent toString returned null", parentToString);
    assertThat("Parent toDetailedString does not contain the parent's toString", parentDetailedToString, Matchers.containsString(parentToString));
}
Also used : ProductBrand(com.google.api.ads.adwords.axis.v201809.cm.ProductBrand) Test(org.junit.Test)

Example 7 with ProductBrand

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

the class ProductPartitionNodeTest method testSetTrackingUrlTemplateOnExcludedUnit_fails.

/**
 * Checks that setting the tracking URL template on an excluded UNIT node fails.
 */
@Test
public void testSetTrackingUrlTemplateOnExcludedUnit_fails() {
    rootNode = rootNode.asSubdivision();
    ProductBrand childDimension = ProductDimensions.createBrand("google");
    ProductPartitionNode excludedUnitNode = rootNode.addChild(childDimension).asExcludedUnit();
    thrown.expect(IllegalStateException.class);
    excludedUnitNode.setTrackingUrlTemplate("http://www.example.com/tracking?{lpurl}");
}
Also used : ProductBrand(com.google.api.ads.adwords.axis.v201809.cm.ProductBrand) Test(org.junit.Test)

Example 8 with ProductBrand

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

the class ProductPartitionNodeTest method testDimensionToString_unknownAttribute.

/**
 * Test to confirm that {@link ProductPartitionNode#toString(ProductDimension)} handles a
 * malformed {@link ProductDimension} gracefully without throwing an exception.
 */
@Test
public void testDimensionToString_unknownAttribute() throws Exception {
    ProductBrand productBrand = mock(ProductBrand.class);
    when(productBrand.getValue()).thenThrow(new RuntimeException());
    assertThat("ProductPartitionNode did not fail gracefully when interpreting the attributes of " + "a malformed ProductDimension", ProductPartitionNode.toString(productBrand), Matchers.containsString("UNKNOWN"));
}
Also used : ProductBrand(com.google.api.ads.adwords.axis.v201809.cm.ProductBrand) Test(org.junit.Test)

Example 9 with ProductBrand

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

the class ProductDimensionsTest method testCreateBrand.

/**
 * Test method for createBrand.
 */
@Test
public void testCreateBrand() {
    ProductBrand brand = ProductDimensions.createBrand(STRING_VALUE);
    assertEquals(STRING_VALUE, brand.getValue());
}
Also used : ProductBrand(com.google.api.ads.adwords.axis.v201809.cm.ProductBrand) Test(org.junit.Test)

Example 10 with ProductBrand

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

the class ProductPartitionNodeTest method testPutCustomParametersOnExcludedUnit_fails.

/**
 * Checks that adding custom parameters to an excluded UNIT node fails.
 */
@Test
public void testPutCustomParametersOnExcludedUnit_fails() {
    rootNode = rootNode.asSubdivision();
    ProductBrand childDimension = ProductDimensions.createBrand("google");
    ProductPartitionNode excludedUnitNode = rootNode.addChild(childDimension).asExcludedUnit();
    thrown.expect(IllegalStateException.class);
    excludedUnitNode.putCustomParameter("param", "value");
}
Also used : ProductBrand(com.google.api.ads.adwords.axis.v201809.cm.ProductBrand) 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