PlotViewPolicy implements Policy { static boolean isCompoundComponentWithCompoundChildrenThatRequirePlots(AbstractComponent component) { if (component.isLeaf() || isCompoundComponentWithAtLeastOneChildThatIsALeafAndThatRequiresAPlot(component)) { return false; } for (AbstractComponent childComponent : component.getComponents()) { if (!childComponent.isLeaf() && isCompoundComponentWithAtLeastOneChildThatIsALeafAndThatRequiresAPlot(childComponent)) { return true; } } return false; }  @Override ExecutionResult execute(PolicyContext context); static AbstractComponent[][] getPlotComponents(AbstractComponent targetComponent, boolean ordinalPosition); static boolean isScatterPlottable(AbstractComponent comp); static boolean isOverlaidScatterPlottable(AbstractComponent comp);  }
@Test public void testIsCompoundComponentWithCompoundChildrenThatRequirePlots() { Assert.assertFalse(PlotViewPolicy.isCompoundComponentWithCompoundChildrenThatRequirePlots(leafWithAFeedComponent)); Assert.assertFalse(PlotViewPolicy.isCompoundComponentWithCompoundChildrenThatRequirePlots(leafWithOutAFeedComponent)); List<AbstractComponent> childComponents = new ArrayList<AbstractComponent>(); childComponents.add(childCompoundComponent1); childComponents.add(childCompoundComponent2); Mockito.when(compoundComponent.getComponents()).thenReturn(childComponents); Mockito.when(compoundComponent.isLeaf()).thenReturn(false); List<AbstractComponent> childCompound1Children = new ArrayList<AbstractComponent>(); List<AbstractComponent> childCompound2Children = new ArrayList<AbstractComponent>(); childCompound1Children.add(leafWithAFeedComponent); childCompound2Children.add(leafWithOutAFeedComponent); Mockito.when(childCompoundComponent1.getComponents()).thenReturn(childCompound1Children); Mockito.when(childCompoundComponent2.getComponents()).thenReturn(childCompound2Children); Mockito.when(childCompoundComponent1.isLeaf()).thenReturn(false); Mockito.when(childCompoundComponent2.isLeaf()).thenReturn(false); Assert.assertTrue(PlotViewPolicy.isCompoundComponentWithCompoundChildrenThatRequirePlots(compoundComponent)); Mockito.when(childCompoundComponent1.getComponents()).thenReturn(childCompound2Children); Assert.assertFalse(PlotViewPolicy.isCompoundComponentWithCompoundChildrenThatRequirePlots(compoundComponent)); }