use of org.olat.course.condition.interpreter.ConditionInterpreter in project OpenOLAT by OpenOLAT.
the class ConditionTest method testUserPropertyEndswithFunction.
@Test
public void testUserPropertyEndswithFunction() throws Exception {
UserCourseEnvironment uce = getUserDemoCourseEnvironment();
ConditionInterpreter interpreter = new ConditionInterpreter(uce);
String condition = "userPropertyEndswith(\"firstName\", \"ondition\")";
boolean result = interpreter.evaluateCondition(condition);
Assert.assertTrue(condition, result);
condition = "userPropertyEndswith(\"firstName\", \"\")";
result = interpreter.evaluateCondition(condition);
Assert.assertFalse(condition, result);
condition = "userPropertyEndswith(\"firstName\")";
result = interpreter.evaluateCondition(condition);
Assert.assertFalse(condition, result);
condition = "userPropertyEndswith(\"firstName\", \"firstcondition\", \"firstcondition\")";
result = interpreter.evaluateCondition(condition);
Assert.assertFalse(condition, result);
condition = "userPropertyEndswith(\"firstName\", \"someThing\")";
result = interpreter.evaluateCondition(condition);
Assert.assertFalse(condition, result);
condition = "userPropertyEndswith(\"firstName\", \"firstconditiongugus\")";
result = interpreter.evaluateCondition(condition);
Assert.assertFalse(condition, result);
condition = "userPropertyEndswith(\"firstName\", \"gugusfirstcondition\")";
result = interpreter.evaluateCondition(condition);
Assert.assertFalse(condition, result);
condition = "userPropertyEndswith(\"lastName\", \"firstcondition\")";
result = interpreter.evaluateCondition(condition);
Assert.assertFalse(condition, result);
}
use of org.olat.course.condition.interpreter.ConditionInterpreter in project OpenOLAT by OpenOLAT.
the class ConditionTest method testIsNotInUserPropertyFunction.
@Test
public void testIsNotInUserPropertyFunction() throws Exception {
UserCourseEnvironment uce = getUserDemoCourseEnvironment();
ConditionInterpreter interpreter = new ConditionInterpreter(uce);
String condition = "isNotInUserProperty(\"firstName\", \"stcondit\")";
boolean result = interpreter.evaluateCondition(condition);
Assert.assertFalse(condition, result);
condition = "isNotInUserProperty(\"firstName\", \"\")";
result = interpreter.evaluateCondition(condition);
Assert.assertFalse(condition, result);
condition = "isNotInUserProperty(\"firstName\")";
result = interpreter.evaluateCondition(condition);
Assert.assertFalse(condition, result);
condition = "isNotInUserProperty(\"firstName\", \"firstcondition\", \"firstcondition\")";
result = interpreter.evaluateCondition(condition);
Assert.assertFalse(condition, result);
condition = "isNotInUserProperty(\"firstName\", \"someThing\")";
result = interpreter.evaluateCondition(condition);
Assert.assertTrue(condition, result);
condition = "isNotInUserProperty(\"firstName\", \"firstconditiongugus\")";
result = interpreter.evaluateCondition(condition);
Assert.assertTrue(condition, result);
condition = "isNotInUserProperty(\"firstName\", \"gugusfirstcondition\")";
result = interpreter.evaluateCondition(condition);
Assert.assertTrue(condition, result);
condition = "isNotInUserProperty(\"lastName\", \"firstcondition\")";
result = interpreter.evaluateCondition(condition);
Assert.assertTrue(condition, result);
}
use of org.olat.course.condition.interpreter.ConditionInterpreter in project OpenOLAT by OpenOLAT.
the class ConditionTest method testTrueFalse.
@Test
public void testTrueFalse() {
UserCourseEnvironment uce = getUserDemoCourseEnvironment();
ConditionInterpreter interpreter = new ConditionInterpreter(uce);
String condition = "true";
boolean result = interpreter.evaluateCondition(condition);
Assert.assertTrue(result);
condition = "TRUE";
result = interpreter.evaluateCondition(condition);
Assert.assertFalse(result);
condition = "false";
result = interpreter.evaluateCondition(condition);
Assert.assertFalse(result);
condition = "FALSE";
result = interpreter.evaluateCondition(condition);
Assert.assertFalse(result);
}
use of org.olat.course.condition.interpreter.ConditionInterpreter in project OpenOLAT by OpenOLAT.
the class ConditionTest method complexExpression.
@Test
public void complexExpression() throws Exception {
UserCourseEnvironment uce = getUserDemoCourseEnvironment();
ConditionInterpreter interpreter = new ConditionInterpreter(uce);
String condition = "(((inLearningGroup(\"Rule1Group1\") | inLearningGroup(\"Rule1Group2\"))|inLearningArea(\"Rule1Area1\")))";
boolean result = interpreter.evaluateCondition(condition);
Assert.assertFalse(result);
}
use of org.olat.course.condition.interpreter.ConditionInterpreter in project openolat by klemens.
the class ConditionTest method testTrueFalse.
@Test
public void testTrueFalse() {
UserCourseEnvironment uce = getUserDemoCourseEnvironment();
ConditionInterpreter interpreter = new ConditionInterpreter(uce);
String condition = "true";
boolean result = interpreter.evaluateCondition(condition);
Assert.assertTrue(result);
condition = "TRUE";
result = interpreter.evaluateCondition(condition);
Assert.assertFalse(result);
condition = "false";
result = interpreter.evaluateCondition(condition);
Assert.assertFalse(result);
condition = "FALSE";
result = interpreter.evaluateCondition(condition);
Assert.assertFalse(result);
}
Aggregations