### Question:
WildflyClientServiceImpl implements WildflyClientService { @Override public TestConnectionResult testConnection(final String host, final int port, final int managementPort, final String user, final String password) { final TestConnectionResult result = new TestConnectionResult(); try { final String testMessage = createWFClient(host, port, managementPort, user, password).testConnection(); result.setManagementConnectionError(false); result.setManagementConnectionMessage(testMessage); } catch (Exception e) { result.setManagementConnectionError(true); result.setManagementConnectionMessage(e.getMessage()); } return result; }  @Override TestConnectionResult testConnection(final String host,
                                               final int port,
                                               final int managementPort,
                                               final String user,
                                               final String password);  }### Answer:
@Test public void testTestConnectionSuccessful() { when(wfClient.testConnection()).thenReturn(CONNECTION_SUCCESSFUL); TestConnectionResult result = wildflyClientService.testConnection(DUMMY_VALUE, DUMMY_INT_VALUE, DUMMY_INT_VALUE, DUMMY_VALUE, DUMMY_VALUE); assertFalse(result.getManagementConnectionError()); assertEquals(CONNECTION_SUCCESSFUL, result.getManagementConnectionMessage()); }
@Test public void testTestConnectionFailed() { when(wfClient.testConnection()).thenThrow(new WildflyClientException(ERROR_MESSAGE)); TestConnectionResult result = wildflyClientService.testConnection(DUMMY_VALUE, DUMMY_INT_VALUE, DUMMY_INT_VALUE, DUMMY_VALUE, DUMMY_VALUE); assertTrue(result.getManagementConnectionError()); assertEquals(ERROR_MESSAGE, result.getManagementConnectionMessage()); }