-
Notifications
You must be signed in to change notification settings - Fork 65
/
ITwitterClientV1Test.java
134 lines (115 loc) · 4.26 KB
/
ITwitterClientV1Test.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
package io.github.redouane59.twitter.nrt;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import io.github.redouane59.RelationType;
import io.github.redouane59.twitter.TwitterClient;
import io.github.redouane59.twitter.dto.dm.deprecatedV1.DirectMessage;
import io.github.redouane59.twitter.dto.dm.deprecatedV1.DmEvent;
import io.github.redouane59.twitter.dto.others.RequestToken;
import io.github.redouane59.twitter.dto.tweet.Tweet;
import io.github.redouane59.twitter.helpers.ConverterHelper;
import java.util.List;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
@Disabled
public class ITwitterClientV1Test {
private static TwitterClient twitterClient;
@BeforeAll
public static void init() {
twitterClient = new TwitterClient();
}
@Test
public void testFriendshipByIdYes() {
String userId1 = "92073489";
String userId2 = "723996356";
RelationType result = twitterClient.getRelationType(userId1, userId2);
assertEquals(RelationType.FRIENDS, result);
}
@Test
public void testFriendshipByIdNo() {
String userId1 = "92073489";
String userId2 = "1976143068";
RelationType result = twitterClient.getRelationType(userId1, userId2);
assertNotEquals(RelationType.FRIENDS, result);
}
@Test
public void testGetRateLimitStatus() {
assertNotEquals(null, twitterClient.getRateLimitStatus());
}
@Test
public void testRelationBetweenUsersIdFriends() {
String userId1 = "92073489";
String userId2 = "723996356";
RelationType result = twitterClient.getRelationType(userId1, userId2);
assertEquals(RelationType.FRIENDS, result);
}
@Test
public void testRelationBetweenUsersIdNone() {
String userId1 = "92073489";
String userId2 = "1976143068";
RelationType result = twitterClient.getRelationType(userId1, userId2);
assertEquals(RelationType.NONE, result);
}
@Test
public void testRelationBetweenUsersIdFollowing() {
String userId1 = "92073489";
String userId2 = "126267113";
RelationType result = twitterClient.getRelationType(userId1, userId2);
assertEquals(RelationType.FOLLOWING, result);
}
@Test
public void testRelationBetweenUsersIdFollower() {
String userId1 = "92073489";
String userId2 = "1218125226095054848";
RelationType result = twitterClient.getRelationType(userId1, userId2);
assertEquals(RelationType.FOLLOWER, result);
}
@Test
public void testGetOauth1Token() {
twitterClient.getTwitterCredentials().setAccessToken("");
twitterClient.getTwitterCredentials().setAccessTokenSecret("");
RequestToken result = twitterClient.getOauth1Token("oob");
assertTrue(result.getOauthToken().length() > 1);
assertTrue(result.getOauthTokenSecret().length() > 1);
//twitterClient.getOAuth1AccessToken(result, "12345");
}
@Test
public void testSearchTweets30days() {
List<Tweet>
result =
twitterClient.searchForTweetsWithin30days("Hello World!", ConverterHelper.dayBeforeNow(25), ConverterHelper.dayBeforeNow(1), "30days");
assertTrue(result.size() > 0);
}
@Test
public void testGetFollowersIds() {
List<String> ids = twitterClient.getFollowersIds("786491");
assertNotNull(ids);
assertTrue(ids.size() > 10000);
}
@Test
public void testGetFollowingIds() {
List<String> ids = twitterClient.getFollowingIds("786491");
assertNotNull(ids);
assertTrue(ids.size() > 1000);
}
@Test
public void testGetDmListWithCountAndGetDm() {
int count = 55;
List<DirectMessage> result = twitterClient.getDmList(count);
assertNotNull(result);
assertEquals(count, result.size());
assertNotNull(result.get(0).getText());
DirectMessage dm = twitterClient.getDm(result.get(0).getId());
assertNotNull(dm);
assertNotNull(dm.getText());
}
@Test
public void testPostDM() {
DmEvent result = twitterClient.postDm("Hello world !", "1120050519182016513");
assertNotNull(result);
assertNotNull(result.getEvent().getText());
}
}