public void testAttaches() throws Exception { // Should attach to anything as long as the fields exists EventType parentType = SupportEventTypeFactory.createBeanType(SupportBean.class); factory.setViewParameters( viewFactoryContext, TestViewSupport.toExprListBean(new Object[] {"intBoxed"})); factory.attach(parentType, SupportStatementContextFactory.makeContext(), null, null); }
private void tryParameter(Object[] params, String[] fieldNames) throws Exception { GroupByViewFactory factory = new GroupByViewFactory(); factory.setViewParameters(viewFactoryContext, TestViewSupport.toExprListBean(params)); factory.attach( SupportEventTypeFactory.createBeanType(SupportBean.class), SupportStatementContextFactory.makeContext(), null, null); GroupByView view = (GroupByView) factory.makeView(SupportStatementContextFactory.makeContext()); assertEquals(fieldNames[0], view.getCriteriaExpressions()[0].toExpressionString()); }
public void testCanReuse() throws Exception { factory.setViewParameters( viewFactoryContext, TestViewSupport.toExprListBean(new Object[] {"string", "longPrimitive"})); factory.attach( SupportEventTypeFactory.createBeanType(SupportBean.class), SupportStatementContextFactory.makeContext(), null, null); assertFalse(factory.canReuse(new FirstElementView())); assertFalse( factory.canReuse( new GroupByViewImpl( SupportStatementContextFactory.makeContext(), SupportExprNodeFactory.makeIdentNodesBean("string"), null))); assertTrue( factory.canReuse( new GroupByViewImpl( SupportStatementContextFactory.makeContext(), SupportExprNodeFactory.makeIdentNodesBean("string", "longPrimitive"), null))); factory.setViewParameters( viewFactoryContext, TestViewSupport.toExprListBean( new Object[] {SupportExprNodeFactory.makeIdentNodesBean("string", "longPrimitive")})); assertFalse( factory.canReuse( new GroupByViewImpl( SupportStatementContextFactory.makeContext(), SupportExprNodeFactory.makeIdentNodesBean("string"), null))); assertTrue( factory.canReuse( new GroupByViewImpl( SupportStatementContextFactory.makeContext(), SupportExprNodeFactory.makeIdentNodesBean("string", "longPrimitive"), null))); }
private void tryInvalidParameter(Object[] params) throws Exception { try { GroupByViewFactory factory = new GroupByViewFactory(); factory.setViewParameters(viewFactoryContext, TestViewSupport.toExprListBean(params)); factory.attach( SupportEventTypeFactory.createBeanType(SupportBean.class), SupportStatementContextFactory.makeContext(), null, null); fail(); } catch (ViewParameterException ex) { // expected } }
private void tryParameter(Object[] param) throws Exception { SizeViewFactory factory = new SizeViewFactory(); factory.setViewParameters( SupportStatementContextFactory.makeViewContext(), TestViewSupport.toExprListBean(param)); assertTrue(factory.makeView(SupportStatementContextFactory.makeContext()) instanceof SizeView); }