GenericTreeStructure implements TreeStructure { @Override public void getRootNodes(@NotNull AsyncCallback<List<TreeNode<?>>> callback) { if (projectNode == null) { final CurrentProject currentProject = appContext.getCurrentProject(); if (currentProject != null) { projectNode = newProjectNode(currentProject.getRootProject()); } else { callback.onFailure(new IllegalStateException("No project is opened.")); return; } } callback.onSuccess(Arrays.<TreeNode<?>>asList(projectNode)); } protected  GenericTreeStructure(NodeFactory nodeFactory, EventBus eventBus, AppContext appContext,
                                   ProjectServiceClient projectServiceClient, DtoUnmarshallerFactory dtoUnmarshallerFactory); @Override void getRootNodes(@NotNull AsyncCallback<List<TreeNode<?>>> callback); @NotNull @Override TreeSettings getSettings(); NodeFactory getNodeFactory(); @Override void getNodeByPath(@NotNull final String path, @NotNull final AsyncCallback<TreeNode<?>> callback); ProjectNode newProjectNode(@NotNull ProjectDescriptor data); FileNode newFileNode(@NotNull TreeNode parent, @NotNull ItemReference data); FolderNode newFolderNode(@NotNull TreeNode parent, @NotNull ItemReference data);  }
@Test public void rootNodeShouldBeNotAccessibleIfCurrentProjectIsNull() { when(appContext.getCurrentProject()).thenReturn(null); treeStructure.getRootNodes(callback); verify(appContext).getCurrentProject(); verify(callback).onFailure(any(IllegalStateException.class)); }