@Test public void testCreateCriterionForAdd_excludedCriterion() { childNode = childNode.asExcludedUnit(); testCommonAttributes(childNode, ProductPartitionNodeAdapter.createCriterionForAdd(childNode, adGroupId, biddingConfig), false); }
static AdGroupCriterion createCriterionForAdd(ProductPartitionNode node, long adGroupId, BiddingStrategyConfiguration biddingConfig) { Preconditions.checkNotNull(node, "Null node"); Preconditions.checkNotNull(biddingConfig, "Null bidding configuration"); AdGroupCriterion adGroupCriterion; if (node.isExcludedUnit()) { adGroupCriterion = new NegativeAdGroupCriterion(); } else if (node.isBiddableUnit()){ BiddableAdGroupCriterion biddableCriterion = new BiddableAdGroupCriterion(); if (node.getBid() != null) { Money bidMoney = new Money(); bidMoney.setMicroAmount(node.getBid()); CpcBid cpcBid = new CpcBid(); cpcBid.setBid(bidMoney); cpcBid.setCpcBidSource(BidSource.CRITERION); biddingConfig.setBids(new Bids[] {cpcBid}); biddableCriterion.setBiddingStrategyConfiguration( biddingConfig); } if (node.getTrackingUrlTemplate() != null) { biddableCriterion.setTrackingUrlTemplate( node.getTrackingUrlTemplate()); } biddableCriterion.setUrlCustomParameters(createCustomParameters(node)); adGroupCriterion = biddableCriterion; } else { adGroupCriterion = new BiddableAdGroupCriterion(); } adGroupCriterion.setAdGroupId(adGroupId); ProductPartition partition = new ProductPartition(); partition.setId(node.getProductPartitionId()); if (node.getParent() != null) { partition.setParentCriterionId(node.getParent().getProductPartitionId()); } partition.setCaseValue(node.getDimension()); partition.setPartitionType( node.isUnit() ? ProductPartitionType.UNIT : ProductPartitionType.SUBDIVISION); adGroupCriterion.setCriterion(partition); return adGroupCriterion; }
ProductPartitionNodeAdapter { static AdGroupCriterion createCriterionForAdd(ProductPartitionNode node, long adGroupId, BiddingStrategyConfiguration biddingConfig) { Preconditions.checkNotNull(node, "Null node"); Preconditions.checkNotNull(biddingConfig, "Null bidding configuration"); AdGroupCriterion adGroupCriterion; if (node.isExcludedUnit()) { adGroupCriterion = new NegativeAdGroupCriterion(); } else if (node.isBiddableUnit()){ BiddableAdGroupCriterion biddableCriterion = new BiddableAdGroupCriterion(); if (node.getBid() != null) { Money bidMoney = new Money(); bidMoney.setMicroAmount(node.getBid()); CpcBid cpcBid = new CpcBid(); cpcBid.setBid(bidMoney); cpcBid.setCpcBidSource(BidSource.CRITERION); biddingConfig.setBids(new Bids[] {cpcBid}); biddableCriterion.setBiddingStrategyConfiguration( biddingConfig); } if (node.getTrackingUrlTemplate() != null) { biddableCriterion.setTrackingUrlTemplate( node.getTrackingUrlTemplate()); } biddableCriterion.setUrlCustomParameters(createCustomParameters(node)); adGroupCriterion = biddableCriterion; } else { adGroupCriterion = new BiddableAdGroupCriterion(); } adGroupCriterion.setAdGroupId(adGroupId); ProductPartition partition = new ProductPartition(); partition.setId(node.getProductPartitionId()); if (node.getParent() != null) { partition.setParentCriterionId(node.getParent().getProductPartitionId()); } partition.setCaseValue(node.getDimension()); partition.setPartitionType( node.isUnit() ? ProductPartitionType.UNIT : ProductPartitionType.SUBDIVISION); adGroupCriterion.setCriterion(partition); return adGroupCriterion; } }
ProductPartitionNodeAdapter { static AdGroupCriterion createCriterionForAdd(ProductPartitionNode node, long adGroupId, BiddingStrategyConfiguration biddingConfig) { Preconditions.checkNotNull(node, "Null node"); Preconditions.checkNotNull(biddingConfig, "Null bidding configuration"); AdGroupCriterion adGroupCriterion; if (node.isExcludedUnit()) { adGroupCriterion = new NegativeAdGroupCriterion(); } else if (node.isBiddableUnit()){ BiddableAdGroupCriterion biddableCriterion = new BiddableAdGroupCriterion(); if (node.getBid() != null) { Money bidMoney = new Money(); bidMoney.setMicroAmount(node.getBid()); CpcBid cpcBid = new CpcBid(); cpcBid.setBid(bidMoney); cpcBid.setCpcBidSource(BidSource.CRITERION); biddingConfig.setBids(new Bids[] {cpcBid}); biddableCriterion.setBiddingStrategyConfiguration( biddingConfig); } if (node.getTrackingUrlTemplate() != null) { biddableCriterion.setTrackingUrlTemplate( node.getTrackingUrlTemplate()); } biddableCriterion.setUrlCustomParameters(createCustomParameters(node)); adGroupCriterion = biddableCriterion; } else { adGroupCriterion = new BiddableAdGroupCriterion(); } adGroupCriterion.setAdGroupId(adGroupId); ProductPartition partition = new ProductPartition(); partition.setId(node.getProductPartitionId()); if (node.getParent() != null) { partition.setParentCriterionId(node.getParent().getProductPartitionId()); } partition.setCaseValue(node.getDimension()); partition.setPartitionType( node.isUnit() ? ProductPartitionType.UNIT : ProductPartitionType.SUBDIVISION); adGroupCriterion.setCriterion(partition); return adGroupCriterion; } private  ProductPartitionNodeAdapter(); }
ProductPartitionNodeAdapter { static AdGroupCriterion createCriterionForAdd(ProductPartitionNode node, long adGroupId, BiddingStrategyConfiguration biddingConfig) { Preconditions.checkNotNull(node, "Null node"); Preconditions.checkNotNull(biddingConfig, "Null bidding configuration"); AdGroupCriterion adGroupCriterion; if (node.isExcludedUnit()) { adGroupCriterion = new NegativeAdGroupCriterion(); } else if (node.isBiddableUnit()){ BiddableAdGroupCriterion biddableCriterion = new BiddableAdGroupCriterion(); if (node.getBid() != null) { Money bidMoney = new Money(); bidMoney.setMicroAmount(node.getBid()); CpcBid cpcBid = new CpcBid(); cpcBid.setBid(bidMoney); cpcBid.setCpcBidSource(BidSource.CRITERION); biddingConfig.setBids(new Bids[] {cpcBid}); biddableCriterion.setBiddingStrategyConfiguration( biddingConfig); } if (node.getTrackingUrlTemplate() != null) { biddableCriterion.setTrackingUrlTemplate( node.getTrackingUrlTemplate()); } biddableCriterion.setUrlCustomParameters(createCustomParameters(node)); adGroupCriterion = biddableCriterion; } else { adGroupCriterion = new BiddableAdGroupCriterion(); } adGroupCriterion.setAdGroupId(adGroupId); ProductPartition partition = new ProductPartition(); partition.setId(node.getProductPartitionId()); if (node.getParent() != null) { partition.setParentCriterionId(node.getParent().getProductPartitionId()); } partition.setCaseValue(node.getDimension()); partition.setPartitionType( node.isUnit() ? ProductPartitionType.UNIT : ProductPartitionType.SUBDIVISION); adGroupCriterion.setCriterion(partition); return adGroupCriterion; } private  ProductPartitionNodeAdapter();  }
ProductPartitionNodeAdapter { static AdGroupCriterion createCriterionForAdd(ProductPartitionNode node, long adGroupId, BiddingStrategyConfiguration biddingConfig) { Preconditions.checkNotNull(node, "Null node"); Preconditions.checkNotNull(biddingConfig, "Null bidding configuration"); AdGroupCriterion adGroupCriterion; if (node.isExcludedUnit()) { adGroupCriterion = new NegativeAdGroupCriterion(); } else if (node.isBiddableUnit()){ BiddableAdGroupCriterion biddableCriterion = new BiddableAdGroupCriterion(); if (node.getBid() != null) { Money bidMoney = new Money(); bidMoney.setMicroAmount(node.getBid()); CpcBid cpcBid = new CpcBid(); cpcBid.setBid(bidMoney); cpcBid.setCpcBidSource(BidSource.CRITERION); biddingConfig.setBids(new Bids[] {cpcBid}); biddableCriterion.setBiddingStrategyConfiguration( biddingConfig); } if (node.getTrackingUrlTemplate() != null) { biddableCriterion.setTrackingUrlTemplate( node.getTrackingUrlTemplate()); } biddableCriterion.setUrlCustomParameters(createCustomParameters(node)); adGroupCriterion = biddableCriterion; } else { adGroupCriterion = new BiddableAdGroupCriterion(); } adGroupCriterion.setAdGroupId(adGroupId); ProductPartition partition = new ProductPartition(); partition.setId(node.getProductPartitionId()); if (node.getParent() != null) { partition.setParentCriterionId(node.getParent().getProductPartitionId()); } partition.setCaseValue(node.getDimension()); partition.setPartitionType( node.isUnit() ? ProductPartitionType.UNIT : ProductPartitionType.SUBDIVISION); adGroupCriterion.setCriterion(partition); return adGroupCriterion; } private  ProductPartitionNodeAdapter();   }