GenericTreeStructure implements TreeStructure { public FileNode newFileNode(@NotNull TreeNode parent, @NotNull ItemReference data) { if (!"file".equals(data.getType())) { throw new IllegalArgumentException("The associated ItemReference type must be - file."); } return getNodeFactory().newFileNode(parent, data, this); } 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 testNewFileNode() throws Exception { TreeNode parent = mock(TreeNode.class); ItemReference data = mock(ItemReference.class); when(data.getType()).thenReturn("file"); treeStructure.newFileNode(parent, data); verify(nodeFactory).newFileNode(eq(parent), eq(data), eq(treeStructure)); }