Advertisement
MyMindWorld

Untitled

Feb 20th, 2021
627
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 1.53 KB | None | 0 0
  1. @Nested
  2.     inner class WhenServerIsRunning {
  3.  
  4.         private val callBackMessage = callBackMessage(allowedUserMarshall, "Hello", data = "Any")
  5.  
  6.         @BeforeEach
  7.         fun setup() {
  8.             Mockito.doNothing().`when`(adminService).denyNotPrivilegedAndNotifyAdmin(allowedUserJockey.user, "Hello")
  9.             Mockito.doReturn(true).`when`(consoleService).isServerRunning()
  10.         }
  11.  
  12.         @AfterEach
  13.         fun resetCalls() {
  14.             Mockito.clearInvocations(bot, adminService, consoleService)
  15.         }
  16.  
  17.  
  18.         @Test
  19.         fun `should not start server`() {
  20.             assertThrows<IllegalStateException> {
  21.                 botCommandsService.startServer(callBackMessage)
  22.             }
  23.  
  24.             Mockito.verify(consoleService, Mockito.never()).startServer()
  25.  
  26.             Mockito.verify(bot, Mockito.times(1)).answerCallbackQuery(
  27.                 callbackQueryId = callBackMessage.id,
  28.                 showAlert = true,
  29.                 text = Messages.serverAlreadyRunning()
  30.             )
  31.         }
  32.  
  33.         @Test
  34.         fun `should not update server`() {
  35.             assertThrows<IllegalStateException> {
  36.                 botCommandsService.updateServer(callBackMessage)
  37.             }
  38.  
  39.             Mockito.verify(consoleService, Mockito.never()).updateServer()
  40.  
  41.             Mockito.verify(bot, Mockito.times(1)).answerCallbackQuery(
  42.                 callbackQueryId = callBackMessage.id,
  43.                 showAlert = true,
  44.                 text = Messages.serverAlreadyRunning()
  45.             )
  46.         }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement