Пример #1
0
  @Test
  public void testGetChildrenWhenHiddenItemsAreNotShown() throws Exception {
    when(treeSettings.isShowHiddenItems()).thenReturn(false);

    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);

    projectNode.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(1, array.size());
    assertTrue(array.contains(item));
    assertFalse(array.contains(hiddenItem));
  }
Пример #2
0
  @Test
  public void testGetChildrenWhenRequestFailure() throws Exception {
    String path = "path";
    AsyncCallback asyncCallback = mock(AsyncCallback.class);

    projectNode.getChildren(path, asyncCallback);

    verify(projectServiceClient).getChildren(eq(path), asyncRequestCallbackCaptor.capture());
    AsyncRequestCallback<Array<ItemReference>> requestCallback =
        asyncRequestCallbackCaptor.getValue();
    GwtReflectionUtils.callOnFailure(requestCallback, mock(Throwable.class));

    verify(asyncCallback).onFailure(Matchers.<Throwable>anyObject());
  }