use of org.olat.modules.reminder.model.ReminderRuleImpl in project openolat by klemens.
the class ReminderRuleEngineTest method getRules.
private List<ReminderRule> getRules(RepositoryEntryRoleRuleSPI.Roles option) {
ReminderRuleImpl rule = new ReminderRuleImpl();
rule.setType(RepositoryEntryRoleRuleSPI.class.getSimpleName());
rule.setOperator("=");
rule.setRightOperand(option.name());
List<ReminderRule> rules = new ArrayList<>(1);
rules.add(rule);
return rules;
}
use of org.olat.modules.reminder.model.ReminderRuleImpl in project openolat by klemens.
the class ReminderRuleEngineTest method getInitialAttemptsRules.
private List<ReminderRule> getInitialAttemptsRules(int value, String unit, String nodeIdent) {
ReminderRuleImpl rule = new ReminderRuleImpl();
rule.setType(InitialAttemptsRuleSPI.class.getSimpleName());
rule.setLeftOperand(nodeIdent);
rule.setOperator(">");
rule.setRightOperand(Integer.toString(value));
rule.setRightUnit(unit);
List<ReminderRule> rules = new ArrayList<>(1);
rules.add(rule);
return rules;
}
use of org.olat.modules.reminder.model.ReminderRuleImpl in project openolat by klemens.
the class ReminderRuleEngineTest method userPropertyRules.
@Test
public void userPropertyRules() {
Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("rule-1");
Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("rule-2");
Identity id3 = JunitTestHelper.createAndPersistIdentityAsRndUser("rule-3");
RepositoryEntry re = JunitTestHelper.createAndPersistRepositoryEntry();
repositoryEntryRelationDao.addRole(id1, re, GroupRoles.owner.name());
repositoryEntryRelationDao.addRole(id2, re, GroupRoles.coach.name());
repositoryEntryRelationDao.addRole(id3, re, GroupRoles.participant.name());
dbInstance.commit();
id1.getUser().setProperty(UserConstants.FIRSTNAME, "Aoi");
id1.getUser().setProperty(UserConstants.LASTNAME, "Volks");
userManager.updateUserFromIdentity(id1);
id2.getUser().setProperty(UserConstants.FIRSTNAME, "Yukino");
id2.getUser().setProperty(UserConstants.LASTNAME, "Volks");
userManager.updateUserFromIdentity(id2);
id3.getUser().setProperty(UserConstants.FIRSTNAME, "Ryomou");
id3.getUser().setProperty(UserConstants.LASTNAME, "Shimei");
userManager.updateUserFromIdentity(id3);
dbInstance.commit();
// check user properties rules
{
List<ReminderRule> rules = getRules(UserConstants.LASTNAME, "Volks");
List<Identity> all = ruleEngine.getIdentities(re, null, rules, true);
Assert.assertEquals(2, all.size());
Assert.assertTrue(all.contains(id1));
Assert.assertTrue(all.contains(id2));
}
// check user properties rules with role
{
List<ReminderRule> rules = getRules(UserConstants.LASTNAME, "Volks");
ReminderRuleImpl rule = new ReminderRuleImpl();
rule.setType(RepositoryEntryRoleRuleSPI.class.getSimpleName());
rule.setOperator("=");
rule.setRightOperand(RepositoryEntryRoleRuleSPI.Roles.owner.name());
rules.add(rule);
List<Identity> all = ruleEngine.getIdentities(re, null, rules, true);
Assert.assertEquals(1, all.size());
Assert.assertTrue(all.contains(id1));
}
// check with 2 rules
{
List<ReminderRule> rules = getRules(UserConstants.LASTNAME, "Volks");
ReminderRuleImpl rule = new ReminderRuleImpl();
rule.setType(UserPropertyRuleSPI.class.getSimpleName());
rule.setLeftOperand(UserConstants.FIRSTNAME);
rule.setOperator("=");
rule.setRightOperand("Yukino");
rules.add(rule);
List<Identity> all = ruleEngine.getIdentities(re, null, rules, true);
Assert.assertEquals(1, all.size());
Assert.assertTrue(all.contains(id2));
}
}
use of org.olat.modules.reminder.model.ReminderRuleImpl in project openolat by klemens.
the class ReminderRuleEngineTest method getFilterThrowsException.
@Test
public void getFilterThrowsException() {
ReminderRuleImpl rule = new ReminderRuleImpl();
rule.setType(ScoreRuleSPI.class.getSimpleName());
rule.setRightOperand("no integer");
ruleEngine.filterByRule(null, null, rule);
}
use of org.olat.modules.reminder.model.ReminderRuleImpl in project openolat by klemens.
the class ReminderRuleEngineTest method getRules.
private List<ReminderRule> getRules(String propertyName, String value) {
ReminderRuleImpl rule = new ReminderRuleImpl();
rule.setType(UserPropertyRuleSPI.class.getSimpleName());
rule.setLeftOperand(propertyName);
rule.setOperator("=");
rule.setRightOperand(value);
List<ReminderRule> rules = new ArrayList<>(1);
rules.add(rule);
return rules;
}
Aggregations