BuildScriptTreeStructureProvider implements TreeStructureProvider { @NotNull @Override public Collection<AbstractTreeNode<?>> modify(@NotNull AbstractTreeNode<?> parent, @NotNull Collection<AbstractTreeNode<?>> children, @Nullable ViewSettings settings) { if (parent instanceof AndroidBuildScriptsGroupNode) { return children; } return myRealTreeStructureProvider.modify(parent, children, settings); } BuildScriptTreeStructureProvider(@NotNull TreeStructureProvider provider); @NotNull @Override Collection<AbstractTreeNode<?>> modify(@NotNull AbstractTreeNode<?> parent,
                                             @NotNull Collection<AbstractTreeNode<?>> children,
                                             @Nullable ViewSettings settings); @Nullable @Override Object getData(@NotNull Collection<AbstractTreeNode<?>> selected, @NotNull String dataName); @Override String toString();  }
@Test public void modifyAndroidBuildScriptsGroupNode() { TreeStructureProvider mockProvider = mock(TreeStructureProvider.class); AbstractTreeNode mockParent = mock(AndroidBuildScriptsGroupNode.class); BuildScriptTreeStructureProvider provider = new BuildScriptTreeStructureProvider(mockProvider); List<AbstractTreeNode<?>> children = createChildren(); Collection<AbstractTreeNode<?>> result = provider.modify(mockParent, children, null); verifyZeroInteractions(mockProvider); assertSameElements(result, children); }
@Test public void modifyAbstractTreeNode() { TreeStructureProvider mockProvider = mock(TreeStructureProvider.class); AbstractTreeNode mockParent = mock(AbstractTreeNode.class); BuildScriptTreeStructureProvider provider = new BuildScriptTreeStructureProvider(mockProvider); List<AbstractTreeNode<?>> children = createChildren(); List<AbstractTreeNode<?>> modified = createChildren(); doReturn(modified).when(mockProvider).modify(mockParent, children, null); Collection<AbstractTreeNode<?>> result = provider.modify(mockParent, children, null); verify(mockProvider).modify(mockParent, children, null); assertSameElements(result, modified); }