/** * Evaluates a named rule * * @param name the rule name * @return the RuleExpressionResult * @throws WorkflowException */ public RuleExpressionResult invokeRule(String name) throws WorkflowException { org.kuali.rice.kew.api.rule.Rule rbv = KewApiServiceLocator.getRuleService().getRuleByName(name); if (rbv == null) throw new WorkflowRuntimeException("Could not find rule named \"" + name + "\""); Rule r = new RuleImpl(rbv); return r.evaluate(r, context); }
/** Test deserialized Not. */ public void test5() throws IOException, ClassNotFoundException { Stack stack = new Stack(); stack.push(LevelEqualsRule.getRule("INFO")); Rule rule = (Rule) SerializationTestHelper.serializeClone(NotRule.getRule(stack)); assertEquals(0, stack.size()); Calendar cal = new GregorianCalendar(2008, 04, 21, 00, 45, 44); LoggingEvent event = new LoggingEvent( "org.apache.log4j.Logger", Logger.getRootLogger(), cal.getTimeInMillis(), Level.INFO, "Hello, World", null); assertFalse(rule.evaluate(event, null)); }
/** Test Not of Level when Level does not match. */ public void test4() { Stack stack = new Stack(); stack.push(LevelEqualsRule.getRule("INFO")); Rule rule = NotRule.getRule(stack); assertEquals(0, stack.size()); Calendar cal = new GregorianCalendar(2008, 04, 21, 00, 45, 44); LoggingEvent event = new LoggingEvent( "org.apache.log4j.Logger", Logger.getRootLogger(), cal.getTimeInMillis(), Level.WARN, "Hello, World", null); assertTrue(rule.evaluate(event, null)); }