@Test public void IncorrectServer_Send() throws MalformedRecipientException { when(mockService.send("xxx", "Message")).thenThrow(new MalformedRecipientException()); int result = msg.sendMessage("xxx", "Message"); assertEquals(2, result); verify(mockService).send("xxx", "Message"); }
@Test public void CorrectServerAndMessage_SendingError() throws MalformedRecipientException { when(mockService.send("inf.ug.edu.pl", "Message")).thenReturn(SendingStatus.SENDING_ERROR); int result = msg.sendMessage("inf.ug.edu.pl", "Message"); assertEquals(1, result); verify(mockService).send("inf.ug.edu.pl", "Message"); }
@Test public void NullServer_CheckConnection() { when(mockService.checkConnection(null)).thenReturn(ConnectionStatus.FAILURE); int result = msg.testConnection(null); assertEquals(1, result); verify(mockService).checkConnection(null); }
@Test public void IncorrectServer_CheckConnection() { when(mockService.checkConnection("inf.ug.edu.com")).thenReturn(ConnectionStatus.FAILURE); int result = msg.testConnection("inf.ug.edu.com"); assertEquals(1, result); verify(mockService).checkConnection("inf.ug.edu.com"); }
@Test public void CorrectServer_CheckConnection() { when(mockService.checkConnection("inf.ug.edu.pl")).thenReturn(ConnectionStatus.SUCCESS); int result = msg.testConnection("inf.ug.edu.pl"); assertEquals(0, result); verify(mockService).checkConnection("inf.ug.edu.pl"); }
@Test public void NullServerAndMessage_Send() throws MalformedRecipientException { when(mockService.send(null, null)).thenThrow(new MalformedRecipientException()); int result = msg.sendMessage(null, null); assertEquals(2, result); verify(mockService).send(null, null); }