### Question:
ConnectionServiceImpl extends PentahoBase implements IConnectionService { public IDatabaseConnection getConnectionByName( String name ) throws ConnectionServiceException { return getConnectionByName( name, true ); } 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 testGetConnectionByName() throws Exception { doNothing().when( connectionServiceImpl ).ensureDataAccessPermission(); doReturn( mockDBConnection ).when( connectionServiceImpl.datasourceMgmtSvc ).getDatasourceByName( CONN_NAME ); IDatabaseConnection connection = connectionServiceImpl.getConnectionByName( CONN_NAME ); verify( connectionServiceImpl ).getConnectionByName( CONN_NAME ); assertEquals( mockDBConnection, connection ); }