Package com.google.api.adwords.v201306.cm

Examples of com.google.api.adwords.v201306.cm.Campaign


  /**
   * Test whether we can validate a correctly formed create campaign request.
   */
  public void testValidCreateCampaign() throws Exception {
    Campaign campaign = new Campaign();
    campaign.setName("Test Campaign " + System.currentTimeMillis());
    campaign.setStatus(CampaignStatus.PAUSED);
    campaign.setBiddingStrategy(new ManualCPC());

    // Create budget.
    Budget budget = new Budget();
    budget.setPeriod(BudgetBudgetPeriod.DAILY);
    budget.setAmount(new Money(null, 50000000L));
    budget.setDeliveryMethod(BudgetBudgetDeliveryMethod.STANDARD);
    campaign.setBudget(budget);

    // Create operations.
    CampaignOperation operation = new CampaignOperation();
    operation.setOperand(campaign);
    operation.setOperator(Operator.ADD);
View Full Code Here


  /**
   * Test whether we can validate an incorrectly formed create campaign request.
   */
  public void testInvalidCreateCampaign() throws Exception {
    // Create campaign.
    Campaign campaign = new Campaign();

    // Create operations.
    CampaignOperation operation = new CampaignOperation();
    operation.setOperand(campaign);
    operation.setOperator(Operator.ADD);

    CampaignOperation[] operations = new CampaignOperation[] {operation};

    CampaignReturnValue result;
    try {
      result = service.mutate(operations);
      Campaign testCampaign = result.getValue()[0];
    } catch (ApiException e) {
      // Expected API Exception.
    } catch (Exception e) {
      throw e;
    }
View Full Code Here

    // Get CampaignService
    CampaignServiceInterface campaignService =
        user.getService(AdWordsService.V201008.CAMPAIGN_SERVICE);

    // Create campaign.
    Campaign campaign = new Campaign();
    campaign.setName("Test Campaign #" + System.currentTimeMillis());
    campaign.setBiddingStrategy(new ManualCPC());
    campaign.setStatus(CampaignStatus.PAUSED);

    // Create budget
    Budget budget = new Budget();
    budget.setPeriod(BudgetBudgetPeriod.DAILY);
    budget.setAmount(new Money(null, 50000000L));
    budget.setDeliveryMethod(BudgetBudgetDeliveryMethod.STANDARD);
    campaign.setBudget(budget);

    // Create operations.
    CampaignOperation operation = new CampaignOperation();
    operation.setOperand(campaign);
    operation.setOperator(Operator.ADD);
View Full Code Here

    CampaignServiceInterface campaignService;

    campaignService = user.getService(AdWordsService.V201008.CAMPAIGN_SERVICE);

    // Create campaign with DELETED status.
    Campaign campaign = new Campaign();
    campaign.setId(campaignId);
    campaign.setStatus(CampaignStatus.DELETED);

    // Create operations.
    CampaignOperation operation = new CampaignOperation();
    operation.setOperand(campaign);
    operation.setOperator(Operator.SET);
View Full Code Here

  /**
   * Test whether we can create a campaign.
   */
  public void testCreateCampaign() throws Exception {
    // Create campaign.
    Campaign campaign = new Campaign();
    campaign.setName("Campaign #" + System.currentTimeMillis());
    campaign.setStatus(CampaignStatus.PAUSED);
    campaign.setBiddingStrategy(new ManualCPC());

    // Create budget.
    Budget budget = new Budget();
    budget.setPeriod(BudgetBudgetPeriod.DAILY);
    budget.setAmount(new Money(null, 50000000L));
    budget.setDeliveryMethod(BudgetBudgetDeliveryMethod.STANDARD);
    campaign.setBudget(budget);

    // Create operations.
    CampaignOperation operation = new CampaignOperation();
    operation.setOperand(campaign);
    operation.setOperator(Operator.ADD);

    CampaignOperation[] operations = new CampaignOperation[] {operation};

    // Add campaign.
    CampaignReturnValue result = campaignService.mutate(operations);
    Campaign testCampaign = result.getValue()[0];

    // Set the generated fields.
    campaign.setId(testCampaign.getId());
    campaign.getBudget().getAmount()
        .setComparableValueType(testCampaign.getBudget().getAmount().getComparableValueType());
    campaign.getBiddingStrategy().setBiddingStrategyType(
        testCampaign.getBiddingStrategy().getBiddingStrategyType());
    campaign.setStartDate(testCampaign.getStartDate());
    campaign.setEndDate(testCampaign.getEndDate());
    campaign.setFrequencyCap(testCampaign.getFrequencyCap());
    campaign.setConversionOptimizerEligibility(testCampaign.getConversionOptimizerEligibility());
    campaign.setServingStatus(testCampaign.getServingStatus());
    campaign.setAdServingOptimizationStatus(testCampaign.getAdServingOptimizationStatus());
    ((ManualCPC) campaign.getBiddingStrategy()).setPositionPreference(((ManualCPC) testCampaign
        .getBiddingStrategy()).getPositionPreference());
    ((ManualCPC) campaign.getBiddingStrategy()).setEnhancedCpcEnabled(((ManualCPC) testCampaign
        .getBiddingStrategy()).getEnhancedCpcEnabled());

    TestUtils.assertDeepReflectionEquals(campaign, testCampaign);
    this.campaign1 = campaign;
  }
View Full Code Here

   * 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);

View Full Code Here

    selector.setIds(ids);
    selector.setStatsSelector(new StatsSelector(new DateRange("20090101", "20090131"), null));

    // Get all campaigns.
    CampaignPage page = campaignService.get(selector);
    Campaign testCampaign = page.getEntries()[0];

    // Set the generated fields.
    campaign1.setCampaignStats(testCampaign.getCampaignStats());
    campaign1.setAdServingOptimizationStatus(testCampaign.getAdServingOptimizationStatus());
    campaign1.setConversionOptimizerEligibility(testCampaign.getConversionOptimizerEligibility());

    TestUtils.assertDeepReflectionEquals(campaign1, testCampaign);
  }
View Full Code Here

  public void testUpdateCampaign() throws Exception {
    if (this.campaign1 == null) {
      testCreateCampaign();
    }

    Campaign campaign = new Campaign();
    campaign.setId(campaign1.getId());
    campaign.setStatus(CampaignStatus.ACTIVE);

    // Create budget.
    Budget budget = new Budget();
    budget.setPeriod(BudgetBudgetPeriod.DAILY);
    budget.setAmount(new Money(null, 2000000L));
    budget.setDeliveryMethod(BudgetBudgetDeliveryMethod.STANDARD);
    campaign.setBudget(budget);

    // Create operations.
    CampaignOperation operation = new CampaignOperation();
    operation.setOperand(campaign);
    operation.setOperator(Operator.SET);

    CampaignOperation[] operations = new CampaignOperation[] {operation};
    CampaignReturnValue result = campaignService.mutate(operations);
    Campaign testCampaign = result.getValue()[0];

    // Set the updated fields.
    campaign1.setStatus(CampaignStatus.ACTIVE);
    budget.getAmount().setComparableValueType(
        testCampaign.getBudget().getAmount().getComparableValueType());
    campaign1.setBudget(budget);

    // Set the generated fields.
    campaign1.setCampaignStats(testCampaign.getCampaignStats());
    campaign1.setAdServingOptimizationStatus(testCampaign.getAdServingOptimizationStatus());
    campaign1.setServingStatus(testCampaign.getServingStatus());
    campaign1.setConversionOptimizerEligibility(testCampaign.getConversionOptimizerEligibility());

    TestUtils.assertDeepReflectionEquals(campaign1, testCampaign);
  }
View Full Code Here

    if (campaign1 == null || campaign2 == null) {
      this.testCreateCampaigns();
    }

    // Create campaign.
    Campaign campaign1 = new Campaign();
    campaign1.setId(this.campaign1.getId());
    campaign1.setStatus(CampaignStatus.DELETED);

    Campaign campaign2 = new Campaign();
    campaign2.setId(this.campaign2.getId());
    campaign2.setStatus(CampaignStatus.DELETED);

    // Create and set budget.
    Budget budget = new Budget();
    budget.setPeriod(BudgetBudgetPeriod.DAILY);
    budget.setAmount(new Money(null, 3000000L));
    budget.setDeliveryMethod(BudgetBudgetDeliveryMethod.STANDARD);
    campaign1.setBudget(budget);
    campaign2.setBudget(budget);

    // Create operations.
    CampaignOperation operation1 = new CampaignOperation();
    operation1.setOperand(campaign1);
    operation1.setOperator(Operator.SET);

    CampaignOperation operation2 = new CampaignOperation();
    operation2.setOperand(campaign2);
    operation2.setOperator(Operator.SET);

    CampaignOperation[] operations = new CampaignOperation[] {operation1, operation2};
    CampaignReturnValue result = campaignService.mutate(operations);
    Campaign testCampaign1 = result.getValue()[0];
    Campaign testCampaign2 = result.getValue()[1];

    // Set the updated fields.
    this.campaign1.setStatus(CampaignStatus.DELETED);
    budget.getAmount().setComparableValueType(
        testCampaign1.getBudget().getAmount().getComparableValueType());
    this.campaign1.setBudget(budget);

    this.campaign2.setStatus(CampaignStatus.DELETED);
    budget.getAmount().setComparableValueType(
        testCampaign2.getBudget().getAmount().getComparableValueType());
    this.campaign2.setBudget(budget);

    // Set the generated fields.
    this.campaign1.setCampaignStats(testCampaign1.getCampaignStats());
    this.campaign1.setAdServingOptimizationStatus(testCampaign1.getAdServingOptimizationStatus());
    this.campaign1.setServingStatus(testCampaign1.getServingStatus());
    this.campaign1.setConversionOptimizerEligibility(testCampaign1
        .getConversionOptimizerEligibility());

    this.campaign2.setCampaignStats(testCampaign2.getCampaignStats());
    this.campaign2.setAdServingOptimizationStatus(testCampaign2.getAdServingOptimizationStatus());
    this.campaign2.setServingStatus(testCampaign2.getServingStatus());
    this.campaign2.setConversionOptimizerEligibility(testCampaign2
        .getConversionOptimizerEligibility());

    TestUtils.assertDeepReflectionEquals(this.campaign1, testCampaign1);
    TestUtils.assertDeepReflectionEquals(this.campaign2, testCampaign2);
  }
View Full Code Here

      // Create ad extension override.
      AdExtensionOverride adExtensionOverride = new AdExtensionOverride();
      adExtensionOverride.setAdId(adId);

      // Create ad extension using existing id.
      AdExtension adExtension = new AdExtension();
      adExtension.setId(campaignAdExtensionId);
      adExtensionOverride.setAdExtension(adExtension);

      // Create operations.
      AdExtensionOverrideOperation operation = new AdExtensionOverrideOperation();
      operation.setOperand(adExtensionOverride);
View Full Code Here

TOP

Related Classes of com.google.api.adwords.v201306.cm.Campaign

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.