@Test public void testGetChildrenWhenHiddenItemsAreShown() throws Exception { when(treeSettings.isShowHiddenItems()).thenReturn(true); String path = "path"; AsyncCallback asyncCallback = mock(AsyncCallback.class); Array<ItemReference> children = Collections.createArray(); ItemReference item = mock(ItemReference.class); when(item.getName()).thenReturn("item"); ItemReference hiddenItem = mock(ItemReference.class); when(hiddenItem.getName()).thenReturn(".item"); children.add(item); children.add(hiddenItem); folderNode.getChildren(path, asyncCallback); verify(projectServiceClient).getChildren(eq(path), asyncRequestCallbackCaptor.capture()); AsyncRequestCallback<Array<ItemReference>> requestCallback = asyncRequestCallbackCaptor.getValue(); GwtReflectionUtils.callOnSuccess(requestCallback, children); verify(asyncCallback).onSuccess(arrayCaptor.capture()); Array<ItemReference> array = arrayCaptor.getValue(); assertEquals(children.size(), array.size()); assertTrue(array.contains(item)); assertTrue(array.contains(hiddenItem)); }
protected void getChildren(String path, final AsyncCallback<Array<ItemReference>> callback) { final Array<ItemReference> children = Collections.createArray(); final Unmarshallable<Array<ItemReference>> unmarshaller = dtoUnmarshallerFactory.newArrayUnmarshaller(ItemReference.class); projectServiceClient.getChildren(path, new AsyncRequestCallback<Array<ItemReference>>(unmarshaller) { @Override protected void onSuccess(Array<ItemReference> result) { final boolean isShowHiddenItems = getTreeStructure().getSettings().isShowHiddenItems(); for (ItemReference item : result.asIterable()) { if (!isShowHiddenItems && item.getName().startsWith(".")) { continue; } children.add(item); } callback.onSuccess(children); } @Override protected void onFailure(Throwable exception) { callback.onFailure(exception); } }); }
FolderNode extends ItemNode { protected void getChildren(String path, final AsyncCallback<Array<ItemReference>> callback) { final Array<ItemReference> children = Collections.createArray(); final Unmarshallable<Array<ItemReference>> unmarshaller = dtoUnmarshallerFactory.newArrayUnmarshaller(ItemReference.class); projectServiceClient.getChildren(path, new AsyncRequestCallback<Array<ItemReference>>(unmarshaller) { @Override protected void onSuccess(Array<ItemReference> result) { final boolean isShowHiddenItems = getTreeStructure().getSettings().isShowHiddenItems(); for (ItemReference item : result.asIterable()) { if (!isShowHiddenItems && item.getName().startsWith(".")) { continue; } children.add(item); } callback.onSuccess(children); } @Override protected void onFailure(Throwable exception) { callback.onFailure(exception); } }); } }
FolderNode extends ItemNode { protected void getChildren(String path, final AsyncCallback<Array<ItemReference>> callback) { final Array<ItemReference> children = Collections.createArray(); final Unmarshallable<Array<ItemReference>> unmarshaller = dtoUnmarshallerFactory.newArrayUnmarshaller(ItemReference.class); projectServiceClient.getChildren(path, new AsyncRequestCallback<Array<ItemReference>>(unmarshaller) { @Override protected void onSuccess(Array<ItemReference> result) { final boolean isShowHiddenItems = getTreeStructure().getSettings().isShowHiddenItems(); for (ItemReference item : result.asIterable()) { if (!isShowHiddenItems && item.getName().startsWith(".")) { continue; } children.add(item); } callback.onSuccess(children); } @Override protected void onFailure(Throwable exception) { callback.onFailure(exception); } }); } @Inject  FolderNode(@Assisted TreeNode<?> parent,
                      @Assisted ItemReference data,
                      @Assisted GenericTreeStructure treeStructure,
                      EventBus eventBus,
                      ProjectServiceClient projectServiceClient,
                      DtoUnmarshallerFactory dtoUnmarshallerFactory); }
FolderNode extends ItemNode { protected void getChildren(String path, final AsyncCallback<Array<ItemReference>> callback) { final Array<ItemReference> children = Collections.createArray(); final Unmarshallable<Array<ItemReference>> unmarshaller = dtoUnmarshallerFactory.newArrayUnmarshaller(ItemReference.class); projectServiceClient.getChildren(path, new AsyncRequestCallback<Array<ItemReference>>(unmarshaller) { @Override protected void onSuccess(Array<ItemReference> result) { final boolean isShowHiddenItems = getTreeStructure().getSettings().isShowHiddenItems(); for (ItemReference item : result.asIterable()) { if (!isShowHiddenItems && item.getName().startsWith(".")) { continue; } children.add(item); } callback.onSuccess(children); } @Override protected void onFailure(Throwable exception) { callback.onFailure(exception); } }); } @Inject  FolderNode(@Assisted TreeNode<?> parent,
                      @Assisted ItemReference data,
                      @Assisted GenericTreeStructure treeStructure,
                      EventBus eventBus,
                      ProjectServiceClient projectServiceClient,
                      DtoUnmarshallerFactory dtoUnmarshallerFactory); @Override boolean isLeaf(); @Override void refreshChildren(final AsyncCallback<TreeNode<?>> callback); @Nonnull @Override GenericTreeStructure getTreeStructure(); @Override boolean canContainsFolder(); }
FolderNode extends ItemNode { protected void getChildren(String path, final AsyncCallback<Array<ItemReference>> callback) { final Array<ItemReference> children = Collections.createArray(); final Unmarshallable<Array<ItemReference>> unmarshaller = dtoUnmarshallerFactory.newArrayUnmarshaller(ItemReference.class); projectServiceClient.getChildren(path, new AsyncRequestCallback<Array<ItemReference>>(unmarshaller) { @Override protected void onSuccess(Array<ItemReference> result) { final boolean isShowHiddenItems = getTreeStructure().getSettings().isShowHiddenItems(); for (ItemReference item : result.asIterable()) { if (!isShowHiddenItems && item.getName().startsWith(".")) { continue; } children.add(item); } callback.onSuccess(children); } @Override protected void onFailure(Throwable exception) { callback.onFailure(exception); } }); } @Inject  FolderNode(@Assisted TreeNode<?> parent,
                      @Assisted ItemReference data,
                      @Assisted GenericTreeStructure treeStructure,
                      EventBus eventBus,
                      ProjectServiceClient projectServiceClient,
                      DtoUnmarshallerFactory dtoUnmarshallerFactory); @Override boolean isLeaf(); @Override void refreshChildren(final AsyncCallback<TreeNode<?>> callback); @Nonnull @Override GenericTreeStructure getTreeStructure(); @Override boolean canContainsFolder();  }