示例#1
0
  // 翻页:自由方式(FreeStyle)
  @Test
  public void getOutboxDirectMessages() {
    List<DirectMessage> listMessage = null;
    Paging<DirectMessage> paging = new Paging<DirectMessage>();

    try {
      listMessage = weibo.getOutboxDirectMessages(paging);
    } catch (Exception e) {
      e.printStackTrace();
    }

    assertTrue(ListUtil.isNotEmpty(listMessage));

    assertTrue(ListUtil.isNotEmpty(listMessage));

    Method method = null;
    try {
      method = Weibo.class.getMethod("getOutboxDirectMessages", Paging.class);
    } catch (SecurityException e1) {
      e1.printStackTrace();
      assertTrue(false);
    } catch (NoSuchMethodException e1) {
      e1.printStackTrace();
      assertTrue(false);
    }

    // 测试上翻
    PagingTest.pageUp(listMessage, weibo, method);

    // 测试下翻
    PagingTest.pageDown(listMessage, weibo, method);

    // 测试中间展开
    PagingTest.pageExpand(listMessage, weibo, method);
  }
示例#2
0
  @Test
  public void destroyOutboxDirectMessage() {
    try {
      Paging<User> paging = new Paging<User>();
      List<User> listUser = weibo.getFollowers(paging);
      assertTrue(ListUtil.isNotEmpty(listUser));

      User user = listUser.get(0);
      assertNotNull(user);

      String text = "测试删除私信接口:destroyOutboxDirectMessage,莫慌," + System.currentTimeMillis();
      DirectMessage message = weibo.sendDirectMessage(user.getDisplayName(), text);
      assertNotNull(message);
      assertTrue(StringUtil.isNotEmpty(message.getId()));

      TestUtil.sleep();

      DirectMessage deletedMessage = weibo.destroyOutboxDirectMessage(message.getId());
      assertNotNull(deletedMessage);
      assertTrue(StringUtil.isNotEmpty(deletedMessage.getId()));
    } catch (LibException e) {
      e.printStackTrace();
      assertTrue(false);
    }
  }
示例#3
0
  @Test
  public void destroyInboxDirectMessage() {
    try {
      Paging<DirectMessage> paging = new Paging<DirectMessage>();
      List<DirectMessage> listMessage = weibo.getInboxDirectMessages(paging);
      assertTrue(ListUtil.isNotEmpty(listMessage));
      DirectMessage message = listMessage.get(0);
      assertNotNull(message);

      TestUtil.sleep();

      DirectMessage deletedMessage = weibo.destroyInboxDirectMessage(message.getId());
      assertNotNull(deletedMessage);
      assertTrue(StringUtil.isNotEmpty(deletedMessage.getId()));
    } catch (Exception e) {
      e.printStackTrace();
      assertTrue(false);
    }
  }
示例#4
0
  public static LocalStatus createDividerStatus(List<Status> statusList, LocalAccount account) {
    if (ListUtil.isEmpty(statusList) || account == null) {
      return null;
    }

    Status status = statusList.get(statusList.size() - 1);
    StringBuffer newId = new StringBuffer(status.getStatusId());
    char c = newId.charAt(newId.length() - 1);
    byte b = (byte) ((int) c - 1);
    newId.setCharAt(newId.length() - 1, (char) b);

    LocalStatus dividerStatus = new LocalStatus();
    dividerStatus.setStatusId(newId.toString());
    dividerStatus.setAccountId(account.getAccountId());
    dividerStatus.setServiceProvider(account.getServiceProvider());
    Date createdAt = new Date(status.getCreatedAt().getTime() - 1);
    dividerStatus.setCreatedAt(createdAt);
    dividerStatus.setDivider(true);
    dividerStatus.setText("divider");

    return dividerStatus;
  }