FileExplorerViewImpl extends Composite implements FileExplorerView { boolean needsLoading(final FSTreeItem item) { return item.getUserObject() instanceof Path && item.getFSType() == FSTreeItem.FSType.FOLDER && item.getChildCount() == 1 && constants.Loading().equals(item.getChild(0).getText()); } FileExplorerViewImpl();   FileExplorerViewImpl(final Tree<FSTreeItem> tree); void init(final FileExplorerPresenter presenter); @Override void reset(); @Override void removeRepository(final Repository repo); @Override void addNewRepository(final Repository repository,
                                 final String branchName);  }
@Test public void checkItemsAreNotLazyLoaded() { item = newTreeItem(new TreeItemData(FSTreeItem.FSType.ITEM, "file", mock(Path.class))); assertFalse(view.needsLoading(item)); }
@Test public void checkFoldersWithNoChildrenAreNotLazyLoaded() { item = newTreeItem(new TreeItemData(FSTreeItem.FSType.FOLDER, "folder", mock(Path.class))); assertFalse(view.needsLoading(item)); }
@Test public void checkFoldersWithExistingChildrenAreNotLazyLoaded() { item = newTreeItem(new TreeItemData(FSTreeItem.FSType.FOLDER, "folder", mock(Path.class)), new TreeItemData(FSTreeItem.FSType.ITEM, "file1", mock(Path.class)), new TreeItemData(FSTreeItem.FSType.ITEM, "file2", mock(Path.class))); assertFalse(view.needsLoading(item)); }
@Test public void checkFoldersWithLazyFlagAreLazyLoaded() { item = spy(newTreeItem(new TreeItemData(FSTreeItem.FSType.FOLDER, "folder", mock(Path.class)), new TreeItemData(FSTreeItem.FSType.ITEM, CommonConstants.INSTANCE.Loading(), mock(Path.class)))); final FSTreeItem child = mock(FSTreeItem.class); when(item.getChild(eq(0))).thenReturn(child); when(child.getText()).thenReturn(CommonConstants.INSTANCE.Loading()); assertTrue(view.needsLoading(item)); }