Package twitter4j

Examples of twitter4j.JSONObject


    Preconditions.checkNotNull(eventName);
    Preconditions.checkNotNull(target);
    Preconditions.checkNotNull(source);
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("event", eventName);
    map.put("target", new JSONObject(target));
    map.put("source", new JSONObject(source));
    if (targetObject != null) {
      map.put("target_object", new JSONObject(targetObject));
    }
    return new JSONObject(map);
  }
View Full Code Here


    disconnectMessage = reader.readFile("disconnect-message.json");
  }

  @Test
  public void testParseStatusDelete() throws JSONException {
    JSONObject json = new JSONObject(statusDeletionNotice);
    StatusDeletionNotice delete = JSONObjectParser.parseStatusDelete(json);
    assertEquals(delete.getStatusId(), 1234);
    assertEquals(delete.getUserId(), 3);
  }
View Full Code Here

    assertEquals(delete.getUserId(), 3);
  }

  @Test
  public void testTrackLimitNotice() throws JSONException {
    JSONObject json = new JSONObject(limit);
    assertEquals(JSONObjectParser.parseTrackLimit(json), 1234);
  }
View Full Code Here

    assertEquals(JSONObjectParser.parseTrackLimit(json), 1234);
  }

  @Test
  public void testParseTestList() throws JSONException, TwitterException {
    long[] list = JSONObjectParser.parseFriendList(new JSONObject(friendsList));
    assertEquals(list.length, 4);
    assertEquals(list[0], 1497);
    assertEquals(list[1], 169686021);
    assertEquals(list[2], 790205);
    assertEquals(list[3], 15211564);
View Full Code Here

    assertEquals(list[3], 15211564);
  }

  @Test
  public void testParseSitestreamUserId() throws JSONException {
    JSONObject json = new JSONObject(sitestreamFriendsList);
    assertTrue(JSONObjectParser.hasSitestreamUser(json));
    assertEquals(JSONObjectParser.getSitestreamUser(json), 1888);
  }
View Full Code Here

    assertEquals(JSONObjectParser.getSitestreamUser(json), 1888);
  }

  @Test
  public void testParseSitestreamMessage() throws JSONException {
    JSONObject json = new JSONObject(sitestreamFriendsList);
    assertTrue(JSONObjectParser.hasSitestreamUser(json));
    long[] list = JSONObjectParser.parseFriendList(JSONObjectParser.getSitestreamMessage(json));
    assertEquals(list[0], 1);
    assertEquals(list[1], 2);
    assertEquals(list[2], 3);
View Full Code Here

  }

  @Test
  public void testMissingFields() throws JSONException {
    try {
      JSONObject json = new JSONObject("{\"limit\":{}}");
      JSONObjectParser.parseTrackLimit(json);
      fail();
    } catch (JSONException e) {
      // expectation
    }
View Full Code Here

    }
  }

  @Test
  public void testParseControlStreamMessage() throws JSONException {
    JSONObject json = new JSONObject(controlMessage);
    assertFalse(JSONObjectParser.hasSitestreamUser(json));
    assertFalse(JSONObjectParser.hasSitestreamMessage(json));
    String streamId = JSONObjectParser.getStreamId(json);
    assertEquals(streamId, "01_225167_334389048B872A533002B34D73F8C29FD09EFC50");
  }
View Full Code Here

    assertEquals(streamId, "01_225167_334389048B872A533002B34D73F8C29FD09EFC50");
  }

  @Test
  public void testParseDisconnectMessage() throws JSONException {
    JSONObject json = new JSONObject(disconnectMessage);
    assertFalse(JSONObjectParser.hasSitestreamUser(json));
    assertFalse(JSONObjectParser.hasSitestreamMessage(json));
    DisconnectMessage message = JSONObjectParser.parseDisconnectMessage(json);
    assertEquals(message.getDisconnectCode(), 5);
    assertEquals(message.getStreamName(), "somestreamname123");
View Full Code Here

import twitter4j.JSONObjectType;

public class JSONObjectParser {

  public static StatusDeletionNotice parseStatusDelete(JSONObject json) throws JSONException {
    JSONObject statusDelete = json.getJSONObject("delete").getJSONObject("status");
    final long statusId = statusDelete.getLong("id");
    final long userId = statusDelete.getLong("user_id");
    return new StatusDeletionNotice() {
      @Override
      public long getStatusId() {
        return statusId;
      }
View Full Code Here

TOP

Related Classes of twitter4j.JSONObject

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.