AbilityBot extends BaseAbilityBot implements LongPollingBot { @Override public void onUpdateReceived(Update update) { super.onUpdateReceived(update); } protected  AbilityBot(String botToken, String botUsername, DBContext db, AbilityToggle toggle, DefaultBotOptions botOptions); protected  AbilityBot(String botToken, String botUsername, AbilityToggle toggle, DefaultBotOptions options); protected  AbilityBot(String botToken, String botUsername, DBContext db, AbilityToggle toggle); protected  AbilityBot(String botToken, String botUsername, DBContext db, DefaultBotOptions options); protected  AbilityBot(String botToken, String botUsername, DefaultBotOptions botOptions); protected  AbilityBot(String botToken, String botUsername, AbilityToggle toggle); protected  AbilityBot(String botToken, String botUsername, DBContext db); protected  AbilityBot(String botToken, String botUsername); @Override void onUpdateReceived(Update update); @Override void clearWebhook();  }
@Test void sendsInputArgsViolation() { Update update = mockFullUpdate(bot, USER, "/count 1 2 3"); bot.onUpdateReceived(update); verify(silent, times(1)).send(format("Sorry, this feature requires %d additional inputs.", 4), USER.getId()); }
@Test void canProcessUpdatesWithoutUserInfo() { Update update = mock(Update.class); when(update.hasPoll()).thenReturn(true); bot.onUpdateReceived(update); }
@Test void canReportUpdatedStatistics() { Update upd1 = mockFullUpdate(bot, CREATOR, "/count 1 2 3 4"); bot.onUpdateReceived(upd1); Update upd2 = mockFullUpdate(bot, CREATOR, "must reply"); bot.onUpdateReceived(upd2); Mockito.reset(silent); Update statUpd = mockFullUpdate(bot, CREATOR, "/stats"); bot.onUpdateReceived(statUpd); verify(silent, times(1)).send("count: 1\nmustreply: 1", CREATOR.getId()); }
@Test void canProcessChannelPosts() { Update update = mock(Update.class); Message message = mock(Message.class); when(message.getChatId()).thenReturn(1L); when(update.getChannelPost()).thenReturn(message); when(update.hasChannelPost()).thenReturn(true); bot.onUpdateReceived(update); String expected = "test channel post"; verify(silent, times(1)).send(expected, 1); }
@Test void sendsPrivacyViolation() { Update update = mockFullUpdate(bot, USER, "/admin"); bot.onUpdateReceived(update); verify(silent, times(1)).send("Sorry, you don't have the required access level to do that.", USER.getId()); }
@Test void sendsLocalityViolation() { Update update = mockFullUpdate(bot, USER, "/group"); bot.onUpdateReceived(update); verify(silent, times(1)).send(format("Sorry, %s-only feature.", "group"), USER.getId()); }