* Test whether we can create a campaign.
*/
public void testCreateCampaigns() throws Exception {
// Create campaign.
Campaign campaign1 = new Campaign();
campaign1.setName("Campaign #" + System.currentTimeMillis());
campaign1.setStatus(CampaignStatus.PAUSED);
campaign1.setBiddingStrategy(new ManualCPC());
// Create campaign.
Campaign campaign2 = new Campaign();
campaign2.setName("Campaign #" + (System.currentTimeMillis() + 1L));
campaign2.setStatus(CampaignStatus.PAUSED);
campaign2.setBiddingStrategy(new ManualCPC());
// Create budget.
Budget budget = new Budget();
budget.setPeriod(BudgetBudgetPeriod.DAILY);
budget.setAmount(new Money(null, 50000000L));
budget.setDeliveryMethod(BudgetBudgetDeliveryMethod.STANDARD);
campaign1.setBudget(budget);
campaign2.setBudget(budget);
// Create operations.
CampaignOperation operation1 = new CampaignOperation();
operation1.setOperand(campaign1);
operation1.setOperator(Operator.ADD);
CampaignOperation operation2 = new CampaignOperation();
operation2.setOperand(campaign2);
operation2.setOperator(Operator.ADD);
CampaignOperation[] operations = new CampaignOperation[] {operation1, operation2};
// Add campaigns.
CampaignReturnValue result = campaignService.mutate(operations);
Campaign testCampaign1 = result.getValue()[0];
Campaign testCampaign2 = result.getValue()[1];
// Set the generated fields.
campaign1.setId(testCampaign1.getId());
campaign1.getBudget().getAmount()
.setComparableValueType(testCampaign1.getBudget().getAmount().getComparableValueType());
campaign1.getBiddingStrategy().setBiddingStrategyType(
testCampaign1.getBiddingStrategy().getBiddingStrategyType());
campaign1.setStartDate(testCampaign1.getStartDate());
campaign1.setEndDate(testCampaign1.getEndDate());
campaign1.setFrequencyCap(testCampaign1.getFrequencyCap());
campaign1.setConversionOptimizerEligibility(testCampaign1.getConversionOptimizerEligibility());
campaign1.setServingStatus(testCampaign1.getServingStatus());
campaign1.setAdServingOptimizationStatus(testCampaign1.getAdServingOptimizationStatus());
((ManualCPC) campaign1.getBiddingStrategy()).setPositionPreference(((ManualCPC) testCampaign1
.getBiddingStrategy()).getPositionPreference());
((ManualCPC) campaign1.getBiddingStrategy()).setEnhancedCpcEnabled(((ManualCPC) testCampaign1
.getBiddingStrategy()).getEnhancedCpcEnabled());
campaign2.setId(testCampaign2.getId());
campaign2.getBudget().getAmount()
.setComparableValueType(testCampaign2.getBudget().getAmount().getComparableValueType());
campaign2.getBiddingStrategy().setBiddingStrategyType(
testCampaign2.getBiddingStrategy().getBiddingStrategyType());
campaign2.setStartDate(testCampaign2.getStartDate());
campaign2.setEndDate(testCampaign2.getEndDate());
campaign2.setFrequencyCap(testCampaign2.getFrequencyCap());
campaign2.setConversionOptimizerEligibility(testCampaign2.getConversionOptimizerEligibility());
campaign2.setServingStatus(testCampaign2.getServingStatus());
campaign2.setAdServingOptimizationStatus(testCampaign2.getAdServingOptimizationStatus());
((ManualCPC) campaign2.getBiddingStrategy()).setPositionPreference(((ManualCPC) testCampaign2
.getBiddingStrategy()).getPositionPreference());
((ManualCPC) campaign2.getBiddingStrategy()).setEnhancedCpcEnabled(((ManualCPC) testCampaign2
.getBiddingStrategy()).getEnhancedCpcEnabled());
TestUtils.assertDeepReflectionEquals(campaign1, testCampaign1);
TestUtils.assertDeepReflectionEquals(campaign2, testCampaign2);