### Question:
ConnectionServiceImpl extends PentahoBase implements IConnectionService { public IDatabaseConnection getConnectionById( String id ) throws ConnectionServiceException { ensureDataAccessPermission(); try { IDatabaseConnection connection = datasourceMgmtSvc.getDatasourceById( id ); if ( connection == null ) { throw new ConnectionServiceException( Response.SC_NOT_FOUND, Messages.getErrorString( "ConnectionServiceImpl.ERROR_0003_UNABLE_TO_GET_CONNECTION", id ) ); } else { return connection; } } catch ( DatasourceMgmtServiceException dme ) { String message = Messages.getErrorString( "ConnectionServiceImpl.ERROR_0003_UNABLE_TO_GET_CONNECTION", dme.getLocalizedMessage() ); logger.error( message ); throw new ConnectionServiceException( message, dme ); } } ConnectionServiceImpl(); Log getLogger(); boolean hasDataAccessPermission(); void ensureDataAccessPermission(); List<IDatabaseConnection> getConnections(); List<IDatabaseConnection> getConnections( boolean hidePassword ); IDatabaseConnection getConnectionByName( String name ); IDatabaseConnection getConnectionByName( String name, boolean doUnsanitize ); IDatabaseConnection getConnectionById( String id ); boolean addConnection( IDatabaseConnection connection ); boolean updateConnection( IDatabaseConnection connection ); boolean deleteConnection( IDatabaseConnection connection ); boolean deleteConnection( String name ); boolean testConnection( IDatabaseConnection connection ); boolean isConnectionExist( String connectionName );  }### Answer:
@Test public void testGetConnectionById() throws Exception { doNothing().when( connectionServiceImpl ).ensureDataAccessPermission(); doReturn( mockDBConnection ).when( connectionServiceImpl.datasourceMgmtSvc ).getDatasourceById( CONN_ID ); IDatabaseConnection connection = connectionServiceImpl.getConnectionById( CONN_ID ); verify( connectionServiceImpl ).getConnectionById( CONN_ID ); assertEquals( mockDBConnection, connection ); }