@Test public void testDeleteConnectionConn() throws Exception { doNothing().when(connectionServiceImpl).ensureDataAccessPermission(); doNothing().when(connectionServiceImpl.datasourceMgmtSvc).deleteDatasourceByName(CONN_NAME); assertTrue(connectionServiceImpl.deleteConnection(mockDBConnection)); verify(datasourceService).clearDataSource(CONN_NAME); }
private void testDeleteConnectionErrorConn(Exception ex) throws Exception { doNothing().when(connectionServiceImpl).ensureDataAccessPermission(); doThrow(ex).when(connectionServiceImpl.datasourceMgmtSvc).deleteDatasourceByName(CONN_NAME); try { connectionServiceImpl.deleteConnection(mockDBConnection); fail(); // This line should never be reached } catch (ConnectionServiceException e) { // Expected exception } }