AdGroupAdServiceInterface adGroupAdService =
adWordsServices.get(session, AdGroupAdServiceInterface.class);
// Create text ad that violates an exemptable policy. This ad will only
// trigger an error in the production environment.
TextAd exemptableTextAd = new TextAd();
exemptableTextAd.setHeadline("Mars " + System.currentTimeMillis() + "!!!");
exemptableTextAd.setDescription1("Visit the Red Planet in style.");
exemptableTextAd.setDescription2("Low-gravity fun for everyone!");
exemptableTextAd.setDisplayUrl("www.example.com");
exemptableTextAd.setUrl("http://www.example.com/");
// Create ad group ad.
AdGroupAd exemptableAdGroupAd = new AdGroupAd();
exemptableAdGroupAd.setAdGroupId(adGroupId);
exemptableAdGroupAd.setAd(exemptableTextAd);
// Create operations.
AdGroupAdOperation exemptableOperation = new AdGroupAdOperation();
exemptableOperation.setOperand(exemptableAdGroupAd);
exemptableOperation.setOperator(Operator.ADD);
// Create text ad that violates an non-exemptable policy.
TextAd nonExemptableTextAd = new TextAd();
nonExemptableTextAd.setHeadline("Mars Cruise with too long of a headline.");
nonExemptableTextAd.setDescription1("Visit the Red Planet in style.");
nonExemptableTextAd.setDescription2("Low-gravity fun for everyone.");
nonExemptableTextAd.setDisplayUrl("www.example.com");
nonExemptableTextAd.setUrl("http://www.example.com/");
// Create ad group ad.
AdGroupAd nonExemptableAdGroupAd = new AdGroupAd();
nonExemptableAdGroupAd.setAdGroupId(adGroupId);
nonExemptableAdGroupAd.setAd(nonExemptableTextAd);