TableViewPolicy 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(TableViewManifestation.class)) { AbstractComponent targetComponent = context.getProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), AbstractComponent.class); result = !targetComponent.isLeaf() || hasFeed(targetComponent) || (targetComponent instanceof Placeholder); } return new ExecutionResult(context, result, "Requested Table View did not have children with data feeds."); }  @Override ExecutionResult execute(PolicyContext context); static TableStructure getTableStructure(AbstractComponent targetComponent); static boolean canEmbedInTable(AbstractComponent comp);  }
@Test public void testPolicyExecution() { TableViewPolicy policy = new TableViewPolicy(); PolicyContext context = new PolicyContext(); context.setProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), new ViewInfo(TableViewManifestation.class,"table", ViewType.OBJECT)); context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), leafWithFeed); Assert.assertTrue(policy.execute(context).getStatus()); context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), leaf); Assert.assertFalse(policy.execute(context).getStatus()); }