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