### Question:
UIRepositoryDirectory extends UIRepositoryObject { public void refresh() { try { kidElementCache = null; kidDirectoryCache = null; if ( this == getRootDirectory() ) { RepositoryDirectoryInterface localRoot; if ( rep instanceof RepositoryExtended ) { localRoot = ( (RepositoryExtended) rep ).loadRepositoryDirectoryTree( "/", "*.ktr|*.kjb", -1, BooleanUtils.isTrue( rep.getUserInfo().isAdmin() ), true, true ).findDirectory( rd.getObjectId() ); } else { localRoot = rep.findDirectory( rd.getObjectId() ); } rd = localRoot; fireCollectionChanged(); } else { getRootDirectory().refresh(); } } catch ( Exception e ) { e.printStackTrace(); } } UIRepositoryDirectory();  UIRepositoryDirectory( RepositoryDirectoryInterface rd, UIRepositoryDirectory uiParent, Repository rep ); UIRepositoryDirectories getChildren(); void setChildren( UIRepositoryDirectories children ); UIRepositoryObjects getRepositoryObjects(); String toString(); void setName( String name ); String getDescription(); String getLockMessage(); Date getModifiedDate(); String getModifiedUser(); RepositoryObjectType getRepositoryElementType(); @Override boolean isDeleted(); @Override String getType(); @Override String getFormatModifiedDate(); RepositoryDirectory getDirectory(); @Override String getImage(); void delete(); String checkDirNameExistsInRepo( String name ); UIRepositoryDirectory createFolder( String name ); void fireCollectionChanged(); @Override void move( UIRepositoryDirectory newParentDir ); void refresh(); @Override int getCategory(); boolean isExpanded(); void setExpanded( boolean expand ); void toggleExpanded(); UIRepositoryDirectory getParent(); String getPath(); boolean isVisible(); @Override int size(); @Override UIRepositoryObject get( int index ); @Override Iterator<UIRepositoryObject> iterator(); boolean contains( String dirName ); @Override int hashCode(); @Override boolean equals( Object obj );  }### Answer:
@Test public void testRefresh() throws Exception { RepositoryDirectory root = new RepositoryDirectory(); LongObjectId rootObjectId = new LongObjectId( 0L ); root.setObjectId( rootObjectId ); RepositoryDirectory dir = new RepositoryDirectory(); dir.setObjectId( new LongObjectId( 1L ) ); root.addSubdirectory( dir ); RepositoryExtended repo = mock( RepositoryExtended.class ); UserInfo userInfo = new UserInfo(); userInfo.setAdmin( true ); Mockito.when( repo.getUserInfo() ).thenReturn( userInfo ); RepositoryDirectory rd = Mockito.mock( RepositoryDirectory.class ); Mockito.when( rd.findDirectory( Mockito.eq( rootObjectId ) ) ) .thenReturn( Mockito.mock( RepositoryDirectory.class ) ); Mockito.when( repo.loadRepositoryDirectoryTree( "/", "*.ktr|*.kjb", -1, true, true, true ) ).thenReturn( rd ); UIRepositoryDirectory uiDir = new UIRepositoryDirectory( root, null, repo ); uiDir.refresh(); Mockito.verify( repo ).loadRepositoryDirectoryTree( "/", "*.ktr|*.kjb", -1, true, true, true ); }