static void addAndUpdateAdGroupCriterion(long adGroupId) throws RemoteException, Exception { // Add a biddable criterion as the root. AdGroupCriterion root = addPartition( adGroupId, null, new ProductCondition() { { setOperand("All"); setAttribute(null); } }, ProductPartitionType.UNIT, getFixedBid(0.35), false); outputStatusMessage("Applying a biddable criterion as the root...\n"); ApplyProductPartitionActionsResponse applyPartitionActionsResponse = applyPartitionActions(_partitionActions); printCriterionIds( applyPartitionActionsResponse.getAdGroupCriterionIds(), applyPartitionActionsResponse.getPartialErrors()); ArrayOfAdGroupCriterion adGroupCriterions = getAdGroupCriterionsByIds(AccountId, adGroupId, null, CriterionType.PRODUCT_PARTITION); outputStatusMessage( "Printing the ad group's product partition; contains only the tree root node\n"); printProductPartitions(adGroupCriterions); // Update the bid of the root node that we just added. BiddableAdGroupCriterion updatedRoot = new BiddableAdGroupCriterion(); updatedRoot.setId(applyPartitionActionsResponse.getAdGroupCriterionIds().getLongs().get(0)); updatedRoot.setAdGroupId(adGroupId); updatedRoot.setCriterionBid(getFixedBid(0.40)); _partitionActions.getAdGroupCriterionActions().clear(); addPartitionAction(updatedRoot, ItemAction.UPDATE); outputStatusMessage("Updating the bid for the tree root node...\n"); applyPartitionActionsResponse = applyPartitionActions(_partitionActions); adGroupCriterions = getAdGroupCriterionsByIds(AccountId, adGroupId, null, CriterionType.PRODUCT_PARTITION); outputStatusMessage("Updated the bid for the tree root node\n"); printProductPartitions(adGroupCriterions); }