### Question:
WildflyDriverProvider implements DriverProvider { @Override public void hasStarted() throws Exception { driverMgmtClient.testConnection(); driverMgmtClient.getDeployedDrivers(); } WildflyDriverProvider(); @Inject  WildflyDriverProvider(MavenArtifactResolver artifactResolver); DriverDeploymentInfo deploy(final DriverDef driverDef); @Override DriverDeploymentInfo resync(DriverDef driverDef,
                                       DriverDeploymentInfo deploymentInfo); @Override void undeploy(final DriverDeploymentInfo deploymentInfo); @Override DriverDeploymentInfo getDeploymentInfo(final String uuid); List< DriverDef > getDeployments(); List< DriverDeploymentInfo > getDeploymentsInfo(); @Override void loadConfig(Properties properties); @Override void hasStarted(); void setDriverMgmtClient(WildflyDriverManagementClient driverMgmtClient);  }### Answer:
@Test public void testHasStartedOk() throws Exception { when(managementClient.testConnection()).thenReturn(METHOD_EXECUTION_OK); when(managementClient.getDeployedDrivers()).thenReturn(Collections.EMPTY_LIST); driverProvider.hasStarted(); verify(managementClient, times(1)).testConnection(); verify(managementClient, times(1)).getDeployedDrivers(); }
@Test public void testHasStartedWithError1() throws Exception { when(managementClient.testConnection()).thenThrow(new Exception(METHOD_EXECUTION_FAILED)); when(managementClient.getDeployedDrivers()).thenReturn(Collections.EMPTY_LIST); expectedException.expectMessage(METHOD_EXECUTION_FAILED); driverProvider.hasStarted(); verify(managementClient, times(1)).testConnection(); verify(managementClient, never()).getDeployedDrivers(); }
@Test public void testHasStartedWithError2() throws Exception { when(managementClient.testConnection()).thenReturn(METHOD_EXECUTION_OK); when(managementClient.getDeployedDrivers()).thenThrow(new Exception(METHOD_EXECUTION_FAILED)); expectedException.expectMessage(METHOD_EXECUTION_FAILED); driverProvider.hasStarted(); verify(managementClient, times(1)).testConnection(); verify(managementClient, times(1)).getDeployedDrivers(); }