|
14 | 14 | import org.telegram.telegrambots.client.okhttp.OkHttpTelegramClient; |
15 | 15 | import org.telegram.telegrambots.meta.TelegramUrl; |
16 | 16 | import org.telegram.telegrambots.meta.api.methods.botapimethods.PartialBotApiMethod; |
| 17 | +import org.telegram.telegrambots.meta.api.methods.commands.GetMyCommands; |
| 18 | +import org.telegram.telegrambots.meta.api.methods.description.GetMyDescription; |
| 19 | +import org.telegram.telegrambots.meta.api.methods.description.GetMyShortDescription; |
| 20 | +import org.telegram.telegrambots.meta.api.methods.description.SetMyDescription; |
| 21 | +import org.telegram.telegrambots.meta.api.methods.description.SetMyShortDescription; |
| 22 | +import org.telegram.telegrambots.meta.api.methods.name.GetMyName; |
| 23 | +import org.telegram.telegrambots.meta.api.methods.name.SetMyName; |
17 | 24 | import org.telegram.telegrambots.meta.api.methods.send.SendAnimation; |
18 | 25 | import org.telegram.telegrambots.meta.api.methods.send.SendAudio; |
19 | 26 | import org.telegram.telegrambots.meta.api.methods.send.SendDocument; |
|
24 | 31 | import org.telegram.telegrambots.meta.api.methods.send.SendVideoNote; |
25 | 32 | import org.telegram.telegrambots.meta.api.methods.send.SendVoice; |
26 | 33 | import org.telegram.telegrambots.meta.api.objects.InputFile; |
| 34 | +import org.telegram.telegrambots.meta.api.objects.commands.BotCommand; |
| 35 | +import org.telegram.telegrambots.meta.api.objects.description.BotDescription; |
| 36 | +import org.telegram.telegrambots.meta.api.objects.description.BotShortDescription; |
27 | 37 | import org.telegram.telegrambots.meta.api.objects.message.Message; |
| 38 | +import org.telegram.telegrambots.meta.api.objects.name.BotName; |
28 | 39 | import org.telegram.telegrambots.meta.exceptions.TelegramApiException; |
29 | 40 | import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException; |
30 | 41 |
|
31 | 42 | import java.io.File; |
32 | 43 | import java.io.Serializable; |
| 44 | +import java.util.ArrayList; |
| 45 | +import static org.junit.jupiter.api.Assertions.*; |
33 | 46 |
|
34 | 47 | import static org.junit.jupiter.api.Assertions.assertEquals; |
35 | 48 |
|
36 | | -public class TestTelegramClientIntegration { |
| 49 | +class TestTelegramClientIntegration { |
37 | 50 | private MockWebServer webServer; |
38 | 51 |
|
39 | 52 | private static final String TOKEN = "testToken"; |
@@ -168,6 +181,84 @@ void testSendAnimation() throws TelegramApiException { |
168 | 181 | assertEquals(responseMessage, parsedMessage); |
169 | 182 | } |
170 | 183 |
|
| 184 | + @Test |
| 185 | + void testGetMyName() throws TelegramApiException { |
| 186 | + var method = new GetMyName(); |
| 187 | + |
| 188 | + var expected = new BotName(TestData.BOT_USER.getFirstName()); |
| 189 | + mockMethod(method, expected); |
| 190 | + |
| 191 | + var actual = client.execute(method); |
| 192 | + assertEquals(expected, actual); |
| 193 | + } |
| 194 | + |
| 195 | + @Test |
| 196 | + void testSetMyName() throws TelegramApiException { |
| 197 | + var method = new SetMyName(); |
| 198 | + method.setName(TestData.BOT_USER.getFirstName()); |
| 199 | + |
| 200 | + mockMethod(method, Boolean.TRUE); |
| 201 | + |
| 202 | + assertTrue(client.execute(method)); |
| 203 | + } |
| 204 | + |
| 205 | + @Test |
| 206 | + void testGetMyDescription() throws TelegramApiException { |
| 207 | + var method = new GetMyDescription(); |
| 208 | + |
| 209 | + var expected = new BotDescription("description"); |
| 210 | + mockMethod(method, expected); |
| 211 | + |
| 212 | + var actual = client.execute(method); |
| 213 | + assertEquals(expected, actual); |
| 214 | + } |
| 215 | + |
| 216 | + @Test |
| 217 | + void testSetMyDescription() throws TelegramApiException { |
| 218 | + var method = new SetMyDescription(); |
| 219 | + method.setDescription("description"); |
| 220 | + |
| 221 | + mockMethod(method, Boolean.TRUE); |
| 222 | + |
| 223 | + assertTrue(client.execute(method)); |
| 224 | + } |
| 225 | + |
| 226 | + @Test |
| 227 | + void testGetMyShortDescription() throws TelegramApiException { |
| 228 | + var method = new GetMyShortDescription(); |
| 229 | + |
| 230 | + var expected = new BotShortDescription("short"); |
| 231 | + mockMethod(method, expected); |
| 232 | + |
| 233 | + var actual = client.execute(method); |
| 234 | + assertEquals(expected, actual); |
| 235 | + } |
| 236 | + |
| 237 | + @Test |
| 238 | + void testSetMyShortDescription() throws TelegramApiException { |
| 239 | + var method = new SetMyShortDescription(); |
| 240 | + method.setShortDescription("description"); |
| 241 | + |
| 242 | + mockMethod(method, Boolean.TRUE); |
| 243 | + |
| 244 | + assertTrue(client.execute(method)); |
| 245 | + } |
| 246 | + |
| 247 | + @Test |
| 248 | + void testGetMyCommands() throws TelegramApiException { |
| 249 | + var method = new GetMyCommands(); |
| 250 | + |
| 251 | + var expected = new ArrayList<BotCommand>(); |
| 252 | + expected.add(BotCommand.builder() |
| 253 | + .command("command") |
| 254 | + .description("description") |
| 255 | + .build()); |
| 256 | + mockMethod(method, expected); |
| 257 | + |
| 258 | + var actual = client.execute(method); |
| 259 | + assertEquals(expected, actual); |
| 260 | + } |
| 261 | + |
171 | 262 | @Test |
172 | 263 | void testSendMessageException() { |
173 | 264 | SendMessage method = new SendMessage("someChatId", "someText"); |
|
0 commit comments