@Test public void testRejectCanvasView() throws Exception { (new PolicyManagerAccess()).setPolicyManager(mockPolicyManager); AbstractComponent comp = Mockito.mock(AbstractComponent.class); PlotViewPolicy policy = new PlotViewPolicy(); PolicyContext context = new PolicyContext(); context.setProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), new ViewInfo(PlotViewManifestation.class,"",ViewType.CENTER)); Method m = policy.getClass().getDeclaredMethod("rejectCanvasView", PolicyContext.class, AbstractComponent.class); m.setAccessible(true); Mockito.when(comp.isLeaf()).thenReturn(false); Assert.assertEquals(m.invoke(policy, context, comp), Boolean.FALSE, "direct access to plot view role should always be true"); context.setProperty(PolicyContext.PropertyName.VIEW_TYPE.getName(), ViewType.CENTER); Assert.assertEquals(m.invoke(policy, context, comp), Boolean.TRUE, "collections must not support canvas view roles"); Mockito.when(comp.isLeaf()).thenReturn(true); Assert.assertEquals(m.invoke(policy, context, comp), Boolean.FALSE, "leafs must support canvas view roles"); }
private boolean rejectCanvasView(PolicyContext context, AbstractComponent component) { return ViewType.CENTER.equals(context.getProperty(PolicyContext.PropertyName.VIEW_TYPE.getName())) && !component.isLeaf(); }
PlotViewPolicy implements Policy { private boolean rejectCanvasView(PolicyContext context, AbstractComponent component) { return ViewType.CENTER.equals(context.getProperty(PolicyContext.PropertyName.VIEW_TYPE.getName())) && !component.isLeaf(); } }
PlotViewPolicy implements Policy { private boolean rejectCanvasView(PolicyContext context, AbstractComponent component) { return ViewType.CENTER.equals(context.getProperty(PolicyContext.PropertyName.VIEW_TYPE.getName())) && !component.isLeaf(); }  }
PlotViewPolicy implements Policy { private boolean rejectCanvasView(PolicyContext context, AbstractComponent component) { return ViewType.CENTER.equals(context.getProperty(PolicyContext.PropertyName.VIEW_TYPE.getName())) && !component.isLeaf(); }  @Override ExecutionResult execute(PolicyContext context); static AbstractComponent[][] getPlotComponents(AbstractComponent targetComponent, boolean ordinalPosition); static boolean isScatterPlottable(AbstractComponent comp); static boolean isOverlaidScatterPlottable(AbstractComponent comp); }
PlotViewPolicy implements Policy { private boolean rejectCanvasView(PolicyContext context, AbstractComponent component) { return ViewType.CENTER.equals(context.getProperty(PolicyContext.PropertyName.VIEW_TYPE.getName())) && !component.isLeaf(); }  @Override ExecutionResult execute(PolicyContext context); static AbstractComponent[][] getPlotComponents(AbstractComponent targetComponent, boolean ordinalPosition); static boolean isScatterPlottable(AbstractComponent comp); static boolean isOverlaidScatterPlottable(AbstractComponent comp);  }