### Question:
DIRepositoryLocator extends RepositoryLocator { @Override public URI getRootUri() { Repository repo = null; URI uri = null; try { repo = getRepository(); } catch ( Exception e ) { LOG.warn( Messages.getString( "WARNING.RepositoryNotFoundNoRootURI" ) ); } if ( repo != null ) { Object repositoryMeta = repo.getRepositoryMeta(); Object repositoryLocation = null; String location = null; Class[] parameters = {}; if ( repositoryMeta != null ) { Class repositoryMetaClass = repositoryMeta.getClass(); try { Method m = repositoryMetaClass.getMethod( "getRepositoryLocation", parameters ); repositoryLocation = m.invoke( repositoryMeta ); } catch ( Exception e ) { LOG.warn( Messages.getString( "WARNING.RepositoryUnknownMethodNoRootURI", repo.getClass().getName() ) ); } } if ( repositoryLocation != null ) { Class repositoryLocationClass = repositoryLocation.getClass(); try { Method m = repositoryLocationClass.getMethod( "getUrl", parameters ); location = (String) m.invoke( repositoryLocation ); } catch ( Exception e ) { LOG.warn( Messages.getString( "WARNING.ExceptionFindingLocationNoRootURI" ) ); } } if ( location != null ) { uri = URI.create( location ); } } return uri; } DIRepositoryLocator();  DIRepositoryLocator( List<IDocumentListener> documentListeners ); void setUnifiedRepository( IUnifiedRepository unifiedRepository ); void setRepository( Repository repository ); @Override URI getRootUri(); static final String LOCATOR_TYPE; }### Answer:
@Test public void testGetRootUri() throws Exception { Repository mockRepo = mock( Repository.class ); when( spyLocator.getRepository() ).thenReturn( mockRepo ); when( mockRepo.getRepositoryMeta() ).thenReturn( mock( RepositoryMeta.class ) ); spyLocator.getRootUri(); GetRepositoryLocationMethodProvider getRepositoryLocationMethodProvider = new GetRepositoryLocationMethodProvider( null ); when( mockRepo.getRepositoryMeta() ).thenReturn( getRepositoryLocationMethodProvider ); spyLocator.getRootUri(); getRepositoryLocationMethodProvider = new GetRepositoryLocationMethodProvider( new Object() ); when( mockRepo.getRepositoryMeta() ).thenReturn( getRepositoryLocationMethodProvider ); spyLocator.getRootUri(); getRepositoryLocationMethodProvider = new GetRepositoryLocationMethodProvider( new RepositoryLocationTestClass() ); when( mockRepo.getRepositoryMeta() ).thenReturn( getRepositoryLocationMethodProvider ); spyLocator.getRootUri(); }