RepositoryFileTreeAdapter extends XmlAdapter<RepositoryFileTreeDto, RepositoryFileTree> { @Override public RepositoryFileTreeDto marshal( final RepositoryFileTree v ) { RepositoryFileTreeDto treeDto = new RepositoryFileTreeDto(); RepositoryFileDto file = RepositoryFileAdapter.toFileDto( v, membersSet, exclude, includeAcls ); if ( file != null ) { treeDto.setFile( RepositoryFileAdapter.toFileDto( v, membersSet, exclude, includeAcls ) ); List<RepositoryFileTreeDto> children = null; if ( v.getChildren() != null ) { children = new ArrayList<RepositoryFileTreeDto>(); for ( RepositoryFileTree child : v.getChildren() ) { RepositoryFileTreeDto childTreeDto = marshal( child ); if ( childTreeDto != null ) { children.add( childTreeDto ); } } } treeDto.setChildren( children ); return treeDto; } else { return null; } } RepositoryFileTreeAdapter();  RepositoryFileTreeAdapter( RepositoryRequest repositoryRequest ); @Override RepositoryFileTreeDto marshal( final RepositoryFileTree v ); @Override RepositoryFileTree unmarshal( final RepositoryFileTreeDto v );  }
@Test public void testWhenChildrenIsDeleted() throws Exception { RepositoryFile mockFile = mock( RepositoryFileProxy.class ); when( mockFile.isHidden() ).thenReturn( null ); RepositoryFileTree nullValueDir = new RepositoryFileTree( mockFile, Collections.<RepositoryFileTree>emptyList() ); RepositoryFile root = new RepositoryFile.Builder( "rootDir" ).build(); ArrayList<RepositoryFileTree> children = new ArrayList<RepositoryFileTree>( 1 ); children.add( nullValueDir ); RepositoryFileTree rootDir = new RepositoryFileTree( root, children ); RepositoryFileTreeAdapter adapter = new RepositoryFileTreeAdapter(); RepositoryFileTreeDto dtoThere = adapter.marshal( rootDir ); assertTrue( dtoThere.getChildren().isEmpty() ); }