@Test public void testExecute() { Policy policy = new PlotViewPolicy(); PolicyContext context; ViewInfo plotViewInfo = new ViewInfo(PlotViewManifestation.class, "Plot", ViewType.OBJECT); context = new PolicyContext(); context.setProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), plotViewInfo); context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), leafWithAFeedComponent); Assert.assertTrue(policy.execute(context).getStatus()); context = new PolicyContext(); context.setProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), plotViewInfo); context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), leafWithOutAFeedComponent); Assert.assertFalse(policy.execute(context).getStatus()); for (AbstractComponent ac : new AbstractComponent[] { leafWithAFeedComponent, leafWithOutAFeedComponent, nonLeafComponent} ) { for (ViewType vt : ViewType.values()) { ViewInfo someViewInfo = new ViewInfo(NonPlotView.class, "NonPlot", vt); context = new PolicyContext(); context.setProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), someViewInfo); context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), ac); Assert.assertTrue(policy.execute(context).getStatus()); } } }
@Override public ExecutionResult execute(PolicyContext context) { boolean result = true; ViewInfo viewInfo = context.getProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), ViewInfo.class); if (viewInfo.getViewClass().equals(PlotViewManifestation.class)) { AbstractComponent targetComponent = context.getProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), AbstractComponent.class); if (targetComponent.isLeaf() && !hasFeed(targetComponent)) { String message = "Leaf is not a feed."; return new ExecutionResult(context, false, message); } result = !rejectCanvasView(context,targetComponent); } String message; if (result) { message = "Requested Plot View has children with data feeds."; } else { message = "Requested Plot View did not have children with data feeds."; } return new ExecutionResult(context, result, message); }
PlotViewPolicy implements Policy { @Override public ExecutionResult execute(PolicyContext context) { boolean result = true; ViewInfo viewInfo = context.getProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), ViewInfo.class); if (viewInfo.getViewClass().equals(PlotViewManifestation.class)) { AbstractComponent targetComponent = context.getProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), AbstractComponent.class); if (targetComponent.isLeaf() && !hasFeed(targetComponent)) { String message = "Leaf is not a feed."; return new ExecutionResult(context, false, message); } result = !rejectCanvasView(context,targetComponent); } String message; if (result) { message = "Requested Plot View has children with data feeds."; } else { message = "Requested Plot View did not have children with data feeds."; } return new ExecutionResult(context, result, message); } }
PlotViewPolicy implements Policy { @Override public ExecutionResult execute(PolicyContext context) { boolean result = true; ViewInfo viewInfo = context.getProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), ViewInfo.class); if (viewInfo.getViewClass().equals(PlotViewManifestation.class)) { AbstractComponent targetComponent = context.getProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), AbstractComponent.class); if (targetComponent.isLeaf() && !hasFeed(targetComponent)) { String message = "Leaf is not a feed."; return new ExecutionResult(context, false, message); } result = !rejectCanvasView(context,targetComponent); } String message; if (result) { message = "Requested Plot View has children with data feeds."; } else { message = "Requested Plot View did not have children with data feeds."; } return new ExecutionResult(context, result, message); }  }
PlotViewPolicy implements Policy { @Override public ExecutionResult execute(PolicyContext context) { boolean result = true; ViewInfo viewInfo = context.getProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), ViewInfo.class); if (viewInfo.getViewClass().equals(PlotViewManifestation.class)) { AbstractComponent targetComponent = context.getProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), AbstractComponent.class); if (targetComponent.isLeaf() && !hasFeed(targetComponent)) { String message = "Leaf is not a feed."; return new ExecutionResult(context, false, message); } result = !rejectCanvasView(context,targetComponent); } String message; if (result) { message = "Requested Plot View has children with data feeds."; } else { message = "Requested Plot View did not have children with data feeds."; } return new ExecutionResult(context, result, message); }  @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 { @Override public ExecutionResult execute(PolicyContext context) { boolean result = true; ViewInfo viewInfo = context.getProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), ViewInfo.class); if (viewInfo.getViewClass().equals(PlotViewManifestation.class)) { AbstractComponent targetComponent = context.getProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), AbstractComponent.class); if (targetComponent.isLeaf() && !hasFeed(targetComponent)) { String message = "Leaf is not a feed."; return new ExecutionResult(context, false, message); } result = !rejectCanvasView(context,targetComponent); } String message; if (result) { message = "Requested Plot View has children with data feeds."; } else { message = "Requested Plot View did not have children with data feeds."; } return new ExecutionResult(context, result, message); }  @Override ExecutionResult execute(PolicyContext context); static AbstractComponent[][] getPlotComponents(AbstractComponent targetComponent, boolean ordinalPosition); static boolean isScatterPlottable(AbstractComponent comp); static boolean isOverlaidScatterPlottable(AbstractComponent comp);  }