コード例 #1
0
 @Test
 public void updateStatus() {
   mockServer
       .expect(requestTo("https://api.twitter.com/1.1/statuses/update.json"))
       .andExpect(method(POST))
       .andExpect(content().string("status=Test+Message"))
       .andRespond(withSuccess(jsonResource("status"), APPLICATION_JSON));
   Tweet tweet = twitter.timelineOperations().updateStatus("Test Message");
   assertSingleTweet(tweet);
   mockServer.verify();
 }
コード例 #2
0
  @Test
  public void getStatus() {
    mockServer
        .expect(
            requestTo("https://api.twitter.com/1.1/statuses/show/12345.json?include_entities=true"))
        .andExpect(method(GET))
        .andRespond(withSuccess(jsonResource("status"), APPLICATION_JSON));

    Tweet tweet = twitter.timelineOperations().getStatus(12345);
    assertSingleTweet(tweet);
  }
コード例 #3
0
 @Test
 public void updateStatus_withImage() {
   mockServer
       .expect(requestTo("https://api.twitter.com/1.1/statuses/update_with_media.json"))
       .andExpect(method(POST))
       .andRespond(withSuccess(jsonResource("status"), APPLICATION_JSON));
   // TODO: Match body content to ensure fields and photo are included
   Resource photo = getUploadResource("photo.jpg", "PHOTO DATA");
   Tweet tweet = twitter.timelineOperations().updateStatus("Test Message", photo);
   assertSingleTweet(tweet);
   mockServer.verify();
 }
コード例 #4
0
  @Test
  public void updateStatus_withLocation() {
    mockServer
        .expect(requestTo("https://api.twitter.com/1.1/statuses/update.json"))
        .andExpect(method(POST))
        .andExpect(content().string("status=Test+Message&lat=123.1&long=-111.2"))
        .andRespond(withSuccess(jsonResource("status"), APPLICATION_JSON));

    StatusDetails details = new StatusDetails();
    details.setLocation(123.1f, -111.2f);
    Tweet tweet = twitter.timelineOperations().updateStatus("Test Message", details);
    assertSingleTweet(tweet);
    mockServer.verify();
  }
コード例 #5
0
  @Test
  public void updateStatus_withInReplyToStatus() {
    mockServer
        .expect(requestTo("https://api.twitter.com/1.1/statuses/update.json"))
        .andExpect(method(POST))
        .andExpect(
            content()
                .string("status=Test+Message+in+reply+to+%40someone&in_reply_to_status_id=123456"))
        .andRespond(withSuccess(jsonResource("status"), APPLICATION_JSON));

    StatusDetails details = new StatusDetails();
    details.setInReplyToStatusId(123456);
    Tweet tweet =
        twitter.timelineOperations().updateStatus("Test Message in reply to @someone", details);
    assertSingleTweet(tweet);
    mockServer.verify();
  }