Package com.google.api.adwords.v201008.cm

Examples of com.google.api.adwords.v201008.cm.AdGroup


      int numAdGrp = generator.nextInt(6) + 1;
      for (int j = 0; j < numAdGrp; j++) {
        AdGroupPage adGroupPage =
            adGroupService.get(new AdGroupSelector(campaign.getId(), null, null, null));
        AdGroup[] adGroups = adGroupPage.getEntries();
        AdGroup adGroup = null;
        if (adGroups != null && j < adGroups.length) {
          adGroup = adGroups[j];
        } else {
          adGroup = new AdGroup();
          adGroup.setName("AdGroup " + (j + 1));
          adGroup.setBids(new ManualCPCAdGroupBids(null, new Bid(new Money("USD",
              generator.nextInt(10) * 50000L + 50000L)), null, null));
          adGroup.setCampaignId(campaign.getId());

          AdGroupReturnValue adGroupReturnValue =
              adGroupService.mutate(new AdGroupOperation[] {new AdGroupOperation(Operator.ADD,
                  null, adGroup)});
          adGroup = adGroupReturnValue.getValue()[0];
        }

        int numAds = generator.nextInt(10) + 1;
        for (int k = 0; k < numAds; k++) {
          TextAd ad = new TextAd();
          ad.setDescription1("This is the description");
          ad.setDescription2("Second line of the description");
          ad.setHeadline("This is the headline " + generator.nextInt(5000));
          ad.setDisplayUrl("http://google.com/");
          ad.setUrl("http://example.com");

          AdGroupAd adGroupAd = new AdGroupAd();
          adGroupAd.setAd(ad);
          adGroupAd.setAdGroupId(adGroup.getId());

          adGroupAdService.mutate(new AdGroupAdOperation[] {new AdGroupAdOperation(Operator.ADD,
              "ADD", adGroupAd, null)});
        }

        numAds = generator.nextInt(10) + 1;
        for (int k = 0; k < numAds; k++) {
          ImageAd ad = new ImageAd();
          Image image = new Image();
          image.setData(DataUtils.getTestImage());
          image.setName("name.jpg");
          ad.setImage(image);
          ad.setDisplayUrl("http://google.com/");
          ad.setUrl("http://example.com");
          ad.setName("name.jpg");

          AdGroupAd adGroupAd = new AdGroupAd();
          adGroupAd.setAd(ad);
          adGroupAd.setAdGroupId(adGroup.getId());

          adGroupAdService.mutate(new AdGroupAdOperation[] {new AdGroupAdOperation(Operator.ADD,
              "ADD", adGroupAd, null)});
        }

        ArrayList<AdGroupCriterionOperation> criteriaOps =
            new ArrayList<AdGroupCriterionOperation>();

        int numKeywords = generator.nextInt(10) + 1;
        for (int k = 0; k < numKeywords; k++) {
          Keyword keyword = new Keyword();
          keyword.setText("test" + generator.nextInt(5000));
          keyword.setMatchType(KeywordMatchType.PHRASE);

          BiddableAdGroupCriterion criterion = new BiddableAdGroupCriterion();
          criterion.setAdGroupId(adGroup.getId());
          criterion.setCriterion(keyword);

          criteriaOps.add(new AdGroupCriterionOperation(Operator.ADD, "ADD", criterion, null));
        }

View Full Code Here


  /**
   * Test updating an ad group ad.
   */
  public void testUpdate() throws Exception {
    // Create ad with updated status.
    Ad ad = new Ad();
    ad.setId(adId);

    // Create ad with updated status
    AdGroupAd adGroupAd = new AdGroupAd();
    adGroupAd.setAdGroupId(adGroupId);
    adGroupAd.setAd(ad);
View Full Code Here

  /**
   * Test removing an ad group ad.
   */
  public void testRemove() throws Exception {
    // Create ad with updated status.
    Ad ad = new Ad();
    ad.setId(adId);

    // Create ad with updated status
    AdGroupAd adGroupAd = new AdGroupAd();
    adGroupAd.setAdGroupId(adGroupId);
    adGroupAd.setAd(ad);
View Full Code Here

   */
  public void testRemove() throws Exception {
    // Create campaign ad extension
    CampaignAdExtension extension = new CampaignAdExtension();
    extension.setCampaignId(campaignId);
    extension.setAdExtension(new AdExtension(adExtensionId, null));

    // Create operations.
    CampaignAdExtensionOperation operation = new CampaignAdExtensionOperation();
    operation.setOperand(extension);
    operation.setOperator(Operator.REMOVE);
View Full Code Here

    // Get the AdGroupService.
    AdGroupServiceInterface adGroupService;
    adGroupService = user.getService(AdWordsService.V201008.ADGROUP_SERVICE);

    // Create ad group.
    AdGroup adGroup = new AdGroup();
    adGroup.setName("Earth to Mars Cruises #" + System.currentTimeMillis());
    adGroup.setStatus(AdGroupStatus.ENABLED);
    adGroup.setCampaignId(campaignId);

    // Create ad group bid.
    ManualCPCAdGroupBids adGroupBids = new ManualCPCAdGroupBids();
    adGroupBids.setKeywordMaxCpc(new Bid(new Money(null, 10000000L)));
    adGroup.setBids(adGroupBids);

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

  /**
   * Test whether we can create a ad group.
   */
  public void testAdd() throws Exception {
    // Create ad group.
    AdGroup adGroup = new AdGroup();
    adGroup.setName("Ad Group #" + System.currentTimeMillis());
    adGroup.setStatus(AdGroupStatus.PAUSED);
    adGroup.setCampaignId(campaignId);

    // Create ad group bid.
    ManualCPCAdGroupBids adGroupBids = new ManualCPCAdGroupBids();
    adGroupBids.setKeywordMaxCpc(new Bid(new Money(null, 1000000L)));
    adGroup.setBids(adGroupBids);

    // Create operations.
    AdGroupOperation operation = new AdGroupOperation();
    operation.setOperand(adGroup);
    operation.setOperator(Operator.ADD);

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

    // Add ad group.
    AdGroupReturnValue result = adGroupService.mutate(operations);
    AdGroup testAdGroup = result.getValue()[0];

    // Set the generated fields.
    adGroup.setId(testAdGroup.getId());
    adGroup.setCampaignName(testAdGroup.getCampaignName());
    adGroup.getBids().setAdGroupBidsType(
        (testAdGroup.getBids().getAdGroupBidsType()));
    ((ManualCPCAdGroupBids) adGroup.getBids())
        .setEnhancedCpcEnabled(((ManualCPCAdGroupBids) testAdGroup
            .getBids()).getEnhancedCpcEnabled());
    ((ManualCPCAdGroupBids) adGroup.getBids())
        .getKeywordMaxCpc()
        .getAmount()
        .setComparableValueType(
            ((ManualCPCAdGroupBids) testAdGroup.getBids())
                .getKeywordMaxCpc().getAmount()
                .getComparableValueType());

    TestUtils.assertDeepReflectionEquals(adGroup, testAdGroup);
  }
View Full Code Here

  public void testUpdate() throws Exception {
    // Get the AdGroupService.
    adGroupService = user.getService(AdWordsService.V201008.ADGROUP_SERVICE);

    // Create ad group.
    AdGroup adGroup = new AdGroup();
    adGroup.setId(adGroupId);

    // Create updated ad group bid.
    ManualCPCAdGroupBids adGroupBids = new ManualCPCAdGroupBids();
    adGroupBids.setKeywordMaxCpc(new Bid(new Money(null, 2000000L)));
    adGroup.setBids(adGroupBids);

    // Create operations.
    AdGroupOperation operation = new AdGroupOperation();
    operation.setOperand(adGroup);
    operation.setOperator(Operator.SET);

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

    // Update ad group.
    AdGroupReturnValue result = adGroupService.mutate(operations);
    AdGroup testAdGroup = result.getValue()[0];

    // Exclude generated fields.
    adGroup.setCampaignName(testAdGroup.getCampaignName());
    adGroup.setCampaignId(testAdGroup.getCampaignId());
    adGroup.setStatus(testAdGroup.getStatus());
    adGroup.setName(testAdGroup.getName());
    adGroup.getBids().setAdGroupBidsType(
        (testAdGroup.getBids().getAdGroupBidsType()));
    ((ManualCPCAdGroupBids) adGroup.getBids())
        .setEnhancedCpcEnabled(((ManualCPCAdGroupBids) testAdGroup
            .getBids()).getEnhancedCpcEnabled());
    ((ManualCPCAdGroupBids) adGroup.getBids())
        .getKeywordMaxCpc()
        .getAmount()
        .setComparableValueType(
            ((ManualCPCAdGroupBids) testAdGroup.getBids())
                .getKeywordMaxCpc().getAmount()
                .getComparableValueType());

    TestUtils.assertDeepReflectionEquals(adGroup, testAdGroup);
  }
View Full Code Here

  public void testDelete() throws Exception {
    // Get the AdGroupService.
    adGroupService = user.getService(AdWordsService.V201008.ADGROUP_SERVICE);

    // Create ad group with DELETED status.
    AdGroup adGroup = new AdGroup();
    adGroup.setId(adGroupId);
    adGroup.setStatus(AdGroupStatus.DELETED);

    // Create operations.
    AdGroupOperation operation = new AdGroupOperation();
    operation.setOperand(adGroup);
    operation.setOperator(Operator.SET);

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

    // Delete ad group.
    AdGroupReturnValue result = adGroupService.mutate(operations);
    AdGroup testAdGroup = result.getValue()[0];

    // Exclude generated fields.
    adGroup.setCampaignName(testAdGroup.getCampaignName());
    adGroup.setCampaignId(testAdGroup.getCampaignId());
    adGroup.setName(testAdGroup.getName());
    adGroup.setBids(testAdGroup.getBids());

    TestUtils.assertDeepReflectionEquals(adGroup, testAdGroup);
  }
View Full Code Here

    textAd.setDescription2("Low-gravity fun for everyone!");
    textAd.setDisplayUrl("www.example.com");
    textAd.setUrl("http://www.example.com");

    // Create ad group ad.
    AdGroupAd ad = new AdGroupAd();
    ad.setAdGroupId(adGroupId);
    ad.setAd(textAd);

    // Create operations.
    AdGroupAdOperation textAdGroupAdOperation = new AdGroupAdOperation();
    textAdGroupAdOperation.setOperand(ad);
    textAdGroupAdOperation.setOperator(Operator.ADD);
    AdGroupAdOperation[] operations = new AdGroupAdOperation[] {textAdGroupAdOperation};

    // Add ads.
    AdGroupAdReturnValue result = service.mutate(operations);
    AdGroupAd testAd = result.getValue()[0];

    // Set the generated fields.
    ad.getAd().setApprovalStatus(testAd.getAd().getApprovalStatus());
    ad.getAd().setAdType(testAd.getAd().getAdType());
    ad.getAd().setId(testAd.getAd().getId());
    ad.setStatus(testAd.getStatus());

    TestUtils.assertDeepReflectionEquals(ad, testAd);
  }
View Full Code Here

    // Create ad with updated status.
    Ad ad = new Ad();
    ad.setId(adId);

    // Create ad with updated status
    AdGroupAd adGroupAd = new AdGroupAd();
    adGroupAd.setAdGroupId(adGroupId);
    adGroupAd.setAd(ad);
    adGroupAd.setStatus(AdGroupAdStatus.PAUSED);

    // Create operations.
    AdGroupAdOperation operation = new AdGroupAdOperation();
    operation.setOperand(adGroupAd);
    operation.setOperator(Operator.SET);

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

    // Update ad.
    AdGroupAdReturnValue result = service.mutate(operations);
    AdGroupAd testAdGroupAd = result.getValue()[0];

    assertEquals(adGroupAd.getStatus(), testAdGroupAd.getStatus());
  }
View Full Code Here

TOP

Related Classes of com.google.api.adwords.v201008.cm.AdGroup

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.