Skip to content

Commit d1a40b2

Browse files
committed
add client integration test
1 parent 021a5bf commit d1a40b2

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

line-bot-api-client/src/test/java/com/linecorp/bot/client/LineMessagingClientImplIntegrationTest.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@
1616

1717
package com.linecorp.bot.client;
1818

19+
import static java.util.Collections.singleton;
20+
1921
import java.io.IOException;
2022
import java.net.URL;
2123
import java.util.Map;
24+
import java.util.concurrent.Callable;
2225

2326
import org.junit.Assume;
2427
import org.junit.Before;
@@ -27,6 +30,10 @@
2730

2831
import com.fasterxml.jackson.databind.ObjectMapper;
2932

33+
import com.linecorp.bot.model.Broadcast;
34+
import com.linecorp.bot.model.Multicast;
35+
import com.linecorp.bot.model.PushMessage;
36+
import com.linecorp.bot.model.message.TextMessage;
3037
import com.linecorp.bot.model.response.GetNumberOfFollowersResponse;
3138
import com.linecorp.bot.model.response.GetNumberOfMessageDeliveriesResponse;
3239
import com.linecorp.bot.model.response.NumberOfMessagesResponse;
@@ -42,6 +49,7 @@
4249
public class LineMessagingClientImplIntegrationTest {
4350
public static final URL TEST_RESOURCE = ClassLoader.getSystemResource("integration_test_settings.yml");
4451
private LineMessagingClient target;
52+
private String userId;
4553

4654
@Before
4755
public void setUp() throws IOException {
@@ -54,6 +62,44 @@ public void setUp() throws IOException {
5462
.builder((String) map.get("token"))
5563
.apiEndPoint((String) map.get("endpoint"))
5664
.build();
65+
66+
userId = (String) map.get("userId");
67+
}
68+
69+
private static void testApiCall(Callable<Object> f) throws Exception {
70+
final Object response = f.call();
71+
log.info(response.toString());
72+
}
73+
74+
@Test
75+
public void broadcast() throws Exception {
76+
testApiCall(
77+
() -> target.broadcast(new Broadcast(new TextMessage("Broadcast"), true)).get()
78+
);
79+
testApiCall(
80+
() -> target.broadcast(new Broadcast(new TextMessage("Broadcast"))).get()
81+
);
82+
}
83+
84+
@Test
85+
public void multicast() throws Exception {
86+
testApiCall(
87+
() -> target.multicast(new Multicast(singleton(userId), new TextMessage("Multicast"), true))
88+
.get()
89+
);
90+
testApiCall(
91+
() -> target.multicast(new Multicast(singleton(userId), new TextMessage("Multicast"))).get()
92+
);
93+
}
94+
95+
@Test
96+
public void pushMessage() throws Exception {
97+
testApiCall(
98+
() -> target.pushMessage(new PushMessage(userId, new TextMessage("Push"), true)).get()
99+
);
100+
testApiCall(
101+
() -> target.pushMessage(new PushMessage(userId, new TextMessage("Push"))).get()
102+
);
57103
}
58104

59105
@Test

0 commit comments

Comments
 (0)