Keyword keyword = new Keyword();
keyword.setText("mars cruise");
keyword.setMatchType(KeywordMatchType.BROAD);
// Create biddable ad group criterion.
BiddableAdGroupCriterion criterion = new BiddableAdGroupCriterion();
criterion.setAdGroupId(adGroupId);
criterion.setCriterion(keyword);
criterion.setUserStatus(UserStatus.PAUSED);
criterion.setDestinationUrl("http://www.example.com");
// Create bids.
ManualCPCAdGroupCriterionBids bids = new ManualCPCAdGroupCriterionBids();
bids.setMaxCpc(new Bid(new Money(null, 10000L)));
criterion.setBids(bids);
// Create operations.
AdGroupCriterionOperation keywordAdGroupCriterionOperation = new AdGroupCriterionOperation();
keywordAdGroupCriterionOperation.setOperand(criterion);
keywordAdGroupCriterionOperation.setOperator(Operator.ADD);
AdGroupCriterionOperation[] operations =
new AdGroupCriterionOperation[] {keywordAdGroupCriterionOperation};
// Add ad group criteria.
AdGroupCriterionReturnValue result = service.mutate(operations);
BiddableAdGroupCriterion testCriterion = (BiddableAdGroupCriterion) result.getValue()[0];
// Exclude generated fields.
criterion.getCriterion().setId(testCriterion.getCriterion().getId());
criterion.getCriterion().setCriterionType(testCriterion.getCriterion().getCriterionType());
criterion.setSystemServingStatus(testCriterion.getSystemServingStatus());
criterion.setApprovalStatus(testCriterion.getApprovalStatus());
criterion.setAdGroupCriterionType(testCriterion.getAdGroupCriterionType());
criterion.getBids().setAdGroupCriterionBidsType(
testCriterion.getBids().getAdGroupCriterionBidsType());
((ManualCPCAdGroupCriterionBids) criterion.getBids())
.getMaxCpc()
.getAmount()
.setComparableValueType(
(((ManualCPCAdGroupCriterionBids) testCriterion.getBids()).getMaxCpc().getAmount()
.getComparableValueType()));
((ManualCPCAdGroupCriterionBids) criterion.getBids())
.setBidSource((((ManualCPCAdGroupCriterionBids) testCriterion.getBids()).getBidSource()));
((ManualCPCAdGroupCriterionBids) criterion.getBids())
.setMaxCpc(((ManualCPCAdGroupCriterionBids) testCriterion.getBids()).getMaxCpc());
((ManualCPCAdGroupCriterionBids) criterion.getBids())
.setEnhancedCpcEnabled(((ManualCPCAdGroupCriterionBids) testCriterion.getBids())
.getEnhancedCpcEnabled());
criterion.setFirstPageCpc(testCriterion.getFirstPageCpc());
criterion.setQualityInfo(testCriterion.getQualityInfo());
criterion.setStats(testCriterion.getStats());
TestUtils.assertDeepReflectionEquals(criterion, testCriterion);
}