Refine search
public Pattern getPattern(int index, String type) throws ClassNotFoundException { return new Pattern(index, new ClassObjectType(typeResolver.resolveType(type))); }
protected BetaNodeFieldConstraint getConstraint(String identifier, Operator operator, String fieldName, Class clazz) { ClassFieldAccessorStore store = new ClassFieldAccessorStore(); store.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) ); store.setEagerWire( true ); InternalReadAccessor extractor = store.getReader( clazz, fieldName ); Declaration declaration = new Declaration( identifier, extractor, new Pattern( 0, new ClassObjectType( clazz ) ) ); String expression = fieldName + " " + operator.getOperatorString() + " " + declaration.getIdentifier(); return new MvelConstraintTestUtil(expression, declaration, extractor); }
protected BetaNodeFieldConstraint getConstraint(String identifier, Operator operator, String fieldName, Class clazz) { ClassFieldAccessorStore store = new ClassFieldAccessorStore(); store.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) ); store.setEagerWire( true ); InternalReadAccessor extractor = store.getReader( clazz, fieldName ); Declaration declaration = new Declaration( identifier, extractor, new Pattern( 0, new ClassObjectType( clazz ) ) ); String expression = fieldName + " " + operator.getOperatorString() + " " + identifier; return new MvelConstraintTestUtil(expression, operator.getOperatorString(), declaration, extractor); }
protected BetaNodeFieldConstraint getConstraint(String identifier, Operator operator, String fieldName, Class clazz) { ClassFieldAccessorStore store = new ClassFieldAccessorStore(); store.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) ); store.setEagerWire( true ); InternalReadAccessor extractor = store.getReader( clazz, fieldName ); Declaration declaration = new Declaration( identifier, extractor, new Pattern( 0, new ClassObjectType( clazz ) ) ); String expression = fieldName + " " + operator.getOperatorString() + " " + declaration.getIdentifier(); return new MvelConstraintTestUtil(expression, declaration, extractor); }
@Test public void testAddRuleWithPatterns() { final RuleImpl rule = new RuleImpl( "only patterns" ); final Pattern c1 = new Pattern( 0, new ClassObjectType( String.class ) ); final Pattern c2 = new Pattern( 1, new ClassObjectType( String.class ) ); final Pattern c3 = new Pattern( 2, new ClassObjectType( String.class ) );
@Test public void testGetFieldValue() { final InternalReadAccessor extractor = store.getReader( Cheese.class, "type" ); final Pattern pattern = new Pattern( 5, new ClassObjectType( Cheese.class ) ); // Bind the extractor to a decleration // Declarations know the pattern they derive their value from final Declaration declaration = new Declaration( "typeOfCheese", extractor, pattern ); // Create some facts final Cheese cheddar = new Cheese( "cheddar", 5 ); // Check we can extract Declarations correctly assertEquals( "cheddar", declaration.getValue( null, cheddar ) ); }
@Test public void testCloneable() { final ObjectType type = new ClassObjectType( String.class ); final Pattern a = new Pattern( 0, type, "a" ); final Pattern b = new Pattern( 1, type, "b" ); final Pattern c = new Pattern( 2, type, "c" ); final Pattern d = new Pattern( 3, type, "d" ); final Pattern e = new Pattern( 4, type, "e" ); final Pattern f = new Pattern( 5, type, "f" ); final Pattern g = new Pattern( 6, type, "g" ); final Pattern h = new Pattern( 7, type, "h" );
@Before public void setUp() throws Exception { final ObjectType list1ObjectType = new ClassObjectType( String.class ); final ObjectType list2ObjectType = new ClassObjectType( String.class ); final Pattern list1Pattern = new Pattern( 0, list1ObjectType, "s1" ); final Pattern list2Pattern = new Pattern( 1, list2ObjectType, "s2" );
@Test public void testDeclarationsObjectType() throws Exception { final ObjectType type = new ClassObjectType( Cheese.class ); final Pattern col = new Pattern( 0, type, "foo" ); final Declaration dec = col.getDeclaration(); final InternalReadAccessor ext = dec.getExtractor(); assertEquals( Cheese.class, ext.getExtractToClass() ); final Cheese stilton = new Cheese( "stilton", 42 ); assertEquals( stilton, dec.getValue( null, stilton ) ); }
ClassNotFoundException, InvalidPatternException { final ObjectType type = new ClassObjectType( String.class ); final Pattern a = new Pattern( 0, type, "a" ); final Pattern b = new Pattern( 1, type, "b" ); final Pattern c = new Pattern( 2, type, "c" ); final Pattern d = new Pattern( 3, type, "d" ); final Pattern e = new Pattern( 4, type, "e" ); final Pattern f = new Pattern( 5, type, "f" ); final Pattern g = new Pattern( 6, type, "g" ); final Pattern h = new Pattern( 7, type, "h" );
@Test public void testEliminateEmptyBranchesAndDuplications() throws InvalidRuleException { final ObjectType type = new ClassObjectType( String.class ); final Pattern a = new Pattern( 0, type, "a" ); final Pattern b = new Pattern( 1, type, "b" ); final Pattern c = new Pattern( 2, type, "c" ); final Pattern d = new Pattern( 3, type, "d" );
@Test public void testDeclarationOrdering() { final GroupElement and1 = GroupElementFactory.newAndInstance(); final Pattern pattern1 = new Pattern( 0, new ClassObjectType( Person.class), "x" ); and1.addChild( pattern1 ); final Pattern pattern2 = new Pattern( 2, new ClassObjectType( Person.class), "y" ); and1.addChild( pattern2 ); and2.addChild( and1 ); final Pattern pattern3 = new Pattern( 3, new ClassObjectType( Person.class), "x" );
@Test public void testEmptyIterator() { final InternalReadAccessor extractor = store.getReader( Cheese.class, "type" ); final Pattern pattern = new Pattern( 0, new ClassObjectType( Cheese.class ) ); final Declaration declaration = new Declaration( "typeOfCheese", extractor, pattern ); final FieldIndex fieldIndex = new FieldIndex( extractor, declaration, MvelConstraint.INDEX_EVALUATOR ); final TupleIndexHashTable map = new TupleIndexHashTable( new FieldIndex[]{fieldIndex}, false ); final Cheese stilton = new Cheese( "stilton", 55 ); final InternalFactHandle stiltonHandle = new DefaultFactHandle( 2, stilton ); assertNull( map.getFirst( new LeftTupleImpl( stiltonHandle, null, true ) ) ); }
final ObjectType type = new ClassObjectType( String.class ); final Pattern a = new Pattern( 0, type, "a" ); final Pattern b = new Pattern( 1, type, "b" ); final Pattern c = new Pattern( 2, type, "c" );
ClassNotFoundException, InvalidPatternException { final ObjectType type = new ClassObjectType( String.class ); final Pattern a = new Pattern( 0, type, "a" ); final Pattern b = new Pattern( 1, type, "b" ); final Pattern c = new Pattern( 2, type, "c" ); final Pattern d = new Pattern( 3, type, "d" ); final Pattern e = new Pattern( 4, type, "e" ); final Pattern g = new Pattern( 5, type, "g" ); final Pattern h = new Pattern( 6, type, "h" ); final Pattern i = new Pattern( 7, type, "i" );
@Test public void testDeclaration() { final InternalReadAccessor extractor = store.getReader( Cheese.class, "type" ); final Pattern pattern = new Pattern( 5, new ClassObjectType( Cheese.class ) ); // Bind the extractor to a decleration // Declarations know the pattern they derive their value from final Declaration declaration = new Declaration( "typeOfCheese", extractor, pattern ); assertEquals( "typeOfCheese", declaration.getIdentifier() ); assertSame( String.class, declaration.getDeclarationClass() ); assertSame( extractor, declaration.getExtractor() ); assertEquals( 5, declaration.getPattern().getOffset() ); }
final ObjectType type = new ClassObjectType( String.class ); final Pattern a = new Pattern( 0, type, "a" ); final Pattern b = new Pattern( 1, type, "b" );
new ClassObjectType(leftType), buildContext); new ClassObjectType(rightType), buildContext); Pattern pattern = new Pattern(0, new ClassObjectType(leftType));
final ObjectType type = new ClassObjectType( String.class ); final Pattern a = new Pattern( 0, type, "a" ); final Pattern b = new Pattern( 1, type, "b" );
final ObjectType type = new ClassObjectType( String.class ); final Pattern a = new Pattern( 0, type, "a" ); final Pattern b = new Pattern( 1, type, "b" );