Package com.google.api.ads.adwords.jaxws.v201309.rm

Examples of com.google.api.ads.adwords.jaxws.v201309.rm.BasicUserList


    DateTime end = new DateTime(2013, 3, 26, 0, 0, 0, 0);
    String formatStart = dateFormat.format(start.toDate());
    String formatEnd = dateFormat.format(end.toDate());

    builder = builder.forDateRange(start, end);
    Selector selector = builder.build();

    Assert.assertEquals(selector.getDateRange().getMin(), formatStart);
    Assert.assertEquals(selector.getDateRange().getMax(), formatEnd);
  }
View Full Code Here


  @Test
  public void testPagingAndLimits() {
    SelectorBuilder builder = new SelectorBuilder();

    builder = builder.offset(10);
    Selector selector = builder.build();

    Assert.assertNotNull(selector.getPaging());
    Assert.assertNotNull(selector.getPaging().getStartIndex());
    Assert.assertNull(selector.getPaging().getNumberResults());
    Assert.assertEquals(selector.getPaging().getStartIndex().intValue(), 10);

    selector = builder.offset(10).limit(20).build();

    Assert.assertNotNull(selector.getPaging());
    Assert.assertNotNull(selector.getPaging().getStartIndex());
    Assert.assertNotNull(selector.getPaging().getNumberResults());
    Assert.assertEquals(selector.getPaging().getStartIndex().intValue(), 10);
    Assert.assertEquals(selector.getPaging().getNumberResults().intValue(), 20);

    selector = builder.offset(10).limit(20).increaseOffsetBy(5).build();

    Assert.assertNotNull(selector.getPaging());
    Assert.assertNotNull(selector.getPaging().getStartIndex());
    Assert.assertNotNull(selector.getPaging().getNumberResults());
    Assert.assertEquals(selector.getPaging().getStartIndex().intValue(), 15);
    Assert.assertEquals(selector.getPaging().getNumberResults().intValue(), 20);

    selector = builder.offset(10).limit(20).removeLimitAndOffset().build();

    Assert.assertNull(selector.getPaging());

    selector = builder.offset(10).limit(20).removeLimitAndOffset().offset(55).limit(4).build();

    Assert.assertNotNull(selector.getPaging());
    Assert.assertNotNull(selector.getPaging().getStartIndex());
    Assert.assertNotNull(selector.getPaging().getNumberResults());
    Assert.assertEquals(selector.getPaging().getStartIndex().intValue(), 55);
    Assert.assertEquals(selector.getPaging().getNumberResults().intValue(), 4);

  }
View Full Code Here

   * Tests that the built selectors don't share internal Paging state.
   */
  @Test
  public void testUniqueInternalPagingState() {
    SelectorBuilder builder = new SelectorBuilder();
    Selector selectorOne = builder.fields("Id").offset(10).build();
    Selector selectorTwo = builder.fields("Status").offset(345).build();

    Assert.assertEquals(10, selectorOne.getPaging().getStartIndex().intValue());
    Assert.assertEquals(345, selectorTwo.getPaging().getStartIndex().intValue());
  }
View Full Code Here

   * Tests that the built selectors don't share internal OrderBy state.
   */
  @Test
  public void testUniqueInternalOrderByState() {
    SelectorBuilder builder = new SelectorBuilder();
    Selector selectorOne = builder.orderAscBy("Id").build();
    Selector selectorTwo = builder.build();

    OrderBy orderTwo = selectorTwo.getOrdering().get(0);
    orderTwo.setField("Status");

    Assert.assertEquals("Id", selectorOne.getOrdering().get(0).getField());
    Assert.assertEquals("Status", selectorTwo.getOrdering().get(0).getField());
  }
View Full Code Here

   * Tests that the built selectors don't share internal Predicate state.
   */
  @Test
  public void testUniqueInternalPredicateState() {
    SelectorBuilder builder = new SelectorBuilder();
    Selector selectorOne = builder.by("Id", "test").build();
    Selector selectorTwo = builder.build();

    Predicate predicateTwo = selectorTwo.getPredicates().get(0);
    predicateTwo.setField("Status");

    Assert.assertEquals("Id", selectorOne.getPredicates().get(0).getField());
    Assert.assertEquals("Status", selectorTwo.getPredicates().get(0).getField());
  }
View Full Code Here

    DateTime startOne = new DateTime(2013, 1, 1, 0, 0, 0, 0);
    DateTime endOne = new DateTime(2013, 1, 31, 0, 0, 0, 0);
    DateTime startTwo = new DateTime(2013, 2, 1, 0, 0, 0, 0);
    DateTime endTwo = new DateTime(2013, 2, 28, 0, 0, 0, 0);

    Selector selectorOne = builder.forDateRange(startOne, endOne).build();
    Selector selectorTwo = builder.forDateRange(startTwo, endTwo).build();

    Assert.assertEquals(dateFormat.format(startOne.toDate()), selectorOne.getDateRange().getMin());
    Assert.assertEquals(dateFormat.format(endOne.toDate()), selectorOne.getDateRange().getMax());
    Assert.assertEquals(dateFormat.format(startTwo.toDate()), selectorTwo.getDateRange().getMin());
    Assert.assertEquals(dateFormat.format(endTwo.toDate()), selectorTwo.getDateRange().getMax());
  }
View Full Code Here

      // Create conversion type (tag).
      UserListConversionType conversionType = new UserListConversionType();
      conversionType.setName("Mars cruise customers #" + System.currentTimeMillis());

      // Create remarketing user list.
      BasicUserList userList = new BasicUserList();
      userList.setName("Mars cruise customers #" + System.currentTimeMillis());
      userList.setDescription("A list of mars cruise customers in the last year");
      userList.setMembershipLifeSpan(365L);
      userList.setConversionTypes(new UserListConversionType[] {conversionType});

      // Create operations.
      UserListOperation operation = new UserListOperation();
      operation.setOperand(userList);
      operation.setOperator(Operator.ADD);

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

      // Add user list.
      UserListReturnValue result = adwordsUserListService.mutate(operations);

      // Display results.
      if (result != null && result.getValue() != null) {
        // Capture the ID(s) of the conversion.
        List<String> conversionIds = new ArrayList<String>();
        for (UserList userListResult : result.getValue()) {
          if (userListResult instanceof BasicUserList) {
            BasicUserList remarketingAdwordsUserList = (BasicUserList) userListResult;
            for (UserListConversionType userListConversionType :
                remarketingAdwordsUserList.getConversionTypes()) {
              conversionIds.add(userListConversionType.getId().toString());
            }
          }
        }

        // Create predicate and selector.
        Predicate predicate = new Predicate();
        predicate.setField("Id");
        predicate.setOperator(PredicateOperator.IN);
        predicate.setValues(conversionIds.toArray(new String[0]));
        Selector selector = new Selector();
        selector.setFields(new String[] {"Id"});
        selector.setPredicates(new Predicate[] {predicate});

        // Get all conversion trackers.
        Map<Long, AdWordsConversionTracker> conversionTrackers =
            new HashMap<Long, AdWordsConversionTracker>();
        ConversionTrackerPage page = conversionTrackerService.get(selector);
        if (page != null && page.getEntries() != null) {
          for (ConversionTracker conversionTracker : page.getEntries()) {
            conversionTrackers.put(conversionTracker.getId(),
                (AdWordsConversionTracker) conversionTracker);
          }
        }

        // Display user lists.
        for (UserList userListResult : result.getValue()) {
          System.out.printf("User list with name '%s' and id '%d' was added.\n",
              userListResult.getName(), userListResult.getId());

          // Display user list associated conversion code snippets.
          if (userListResult instanceof BasicUserList) {
            BasicUserList remarketingAdwordsUserList = (BasicUserList) userListResult;
            for (UserListConversionType userListConversionType :
              ((BasicUserList) userListResult).getConversionTypes()) {
              System.out.printf("Conversion type code snippet associated to the list:\n%s\n",
                  conversionTrackers.get(userListConversionType.getId()).getSnippet());
            }
View Full Code Here

      // Create conversion type (tag).
      UserListConversionType conversionType = new UserListConversionType();
      conversionType.setName("Mars cruise customers #" + System.currentTimeMillis());

      // Create remarketing user list.
      BasicUserList userList = new BasicUserList();
      userList.setName("Mars cruise customers #" + System.currentTimeMillis());
      userList.setDescription("A list of mars cruise customers in the last year");
      userList.setMembershipLifeSpan(365L);
      userList.setConversionTypes(new UserListConversionType[] {conversionType});

      // Create operations.
      UserListOperation operation = new UserListOperation();
      operation.setOperand(userList);
      operation.setOperator(Operator.ADD);

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

      // Add user list.
      UserListReturnValue result = adwordsUserListService.mutate(operations);

      // Display results.
      if (result != null && result.getValue() != null) {
        // Capture the ID(s) of the conversion.
        List<String> conversionIds = new ArrayList<String>();
        for (UserList userListResult : result.getValue()) {
          if (userListResult instanceof BasicUserList) {
            BasicUserList remarketingAdwordsUserList = (BasicUserList) userListResult;
            for (UserListConversionType userListConversionType :
                remarketingAdwordsUserList.getConversionTypes()) {
              conversionIds.add(userListConversionType.getId().toString());
            }
          }
        }

        // Create predicate and selector.
        Predicate predicate = new Predicate();
        predicate.setField("Id");
        predicate.setOperator(PredicateOperator.IN);
        predicate.setValues(conversionIds.toArray(new String[0]));
        Selector selector = new Selector();
        selector.setFields(new String[] {"Id"});
        selector.setPredicates(new Predicate[] {predicate});

        // Get all conversion trackers.
        Map<Long, AdWordsConversionTracker> conversionTrackers =
            new HashMap<Long, AdWordsConversionTracker>();
        ConversionTrackerPage page = conversionTrackerService.get(selector);
        if (page != null && page.getEntries() != null) {
          for (ConversionTracker conversionTracker : page.getEntries()) {
            conversionTrackers.put(conversionTracker.getId(),
                (AdWordsConversionTracker) conversionTracker);
          }
        }

        // Display user lists.
        for (UserList userListResult : result.getValue()) {
          System.out.printf("User list with name '%s' and id '%d' was added.\n",
              userListResult.getName(), userListResult.getId());

          // Display user list associated conversion code snippets.
          if (userListResult instanceof BasicUserList) {
            BasicUserList remarketingAdwordsUserList = (BasicUserList) userListResult;
            for (UserListConversionType userListConversionType :
              ((BasicUserList) userListResult).getConversionTypes()) {
              System.out.printf("Conversion type code snippet associated to the list:\n%s\n",
                  conversionTrackers.get(userListConversionType.getId()).getSnippet());
            }
View Full Code Here

TOP

Related Classes of com.google.api.ads.adwords.jaxws.v201309.rm.BasicUserList

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.