use of org.apache.syncope.core.persistence.api.entity.Implementation in project syncope by apache.
the class PolicyTest method update.
@Test
public void update() {
PasswordPolicy policy = policyDAO.find("ce93fcda-dc3a-4369-a7b0-a6108c261c85");
assertNotNull(policy);
assertEquals(1, policy.getRules().size());
DefaultPasswordRuleConf ruleConf = new DefaultPasswordRuleConf();
ruleConf.setMaxLength(8);
ruleConf.setMinLength(6);
Implementation rule = entityFactory.newEntity(Implementation.class);
rule.setKey("PasswordRule" + UUID.randomUUID().toString());
rule.setEngine(ImplementationEngine.JAVA);
rule.setType(ImplementationType.PASSWORD_RULE);
rule.setBody(POJOHelper.serialize(ruleConf));
rule = implementationDAO.save(rule);
policy.add(rule);
policy = policyDAO.save(policy);
assertNotNull(policy);
rule = policy.getRules().get(1);
DefaultPasswordRuleConf actual = POJOHelper.deserialize(rule.getBody(), DefaultPasswordRuleConf.class);
assertEquals(actual.getMaxLength(), 8);
assertEquals(actual.getMinLength(), 6);
}
use of org.apache.syncope.core.persistence.api.entity.Implementation in project syncope by apache.
the class TaskTest method savePullTask.
@Test
public void savePullTask() {
ExternalResource resource = resourceDAO.find("ws-target-resource-1");
assertNotNull(resource);
AnyTemplatePullTask template = entityFactory.newEntity(AnyTemplatePullTask.class);
template.set(new UserTO());
PullTask task = entityFactory.newEntity(PullTask.class);
task.setName("savePullTask");
task.setDescription("PullTask description");
task.setActive(true);
task.setPullMode(PullMode.FULL_RECONCILIATION);
task.add(template);
task.setCronExpression("BLA BLA");
task.setMatchingRule(MatchingRule.UPDATE);
task.setUnmatchingRule(UnmatchingRule.PROVISION);
// this save() fails because of an invalid Cron Expression
InvalidEntityException exception = null;
try {
taskDAO.save(task);
} catch (InvalidEntityException e) {
exception = e;
}
assertNotNull(exception);
task.setCronExpression(null);
// this save() fails because a PullTask requires a target resource
exception = null;
try {
taskDAO.save(task);
} catch (InvalidEntityException e) {
exception = e;
}
assertNotNull(exception);
task.setResource(resource);
Implementation pullActions = entityFactory.newEntity(Implementation.class);
pullActions.setKey("PullActions" + UUID.randomUUID().toString());
pullActions.setEngine(ImplementationEngine.JAVA);
pullActions.setType(ImplementationType.PULL_ACTIONS);
pullActions.setBody(PullActions.class.getName());
pullActions = implementationDAO.save(pullActions);
task.add(pullActions);
// this save() finally works
task = taskDAO.save(task);
assertNotNull(task);
PullTask actual = taskDAO.find(task.getKey());
assertEquals(task, actual);
}
use of org.apache.syncope.core.persistence.api.entity.Implementation in project syncope by apache.
the class ReportTest method save.
@Test
public void save() {
Implementation reportlet1 = entityFactory.newEntity(Implementation.class);
reportlet1.setKey("UserReportlet" + UUID.randomUUID().toString());
reportlet1.setEngine(ImplementationEngine.JAVA);
reportlet1.setType(ImplementationType.REPORTLET);
reportlet1.setBody(POJOHelper.serialize(new UserReportletConf("first")));
reportlet1 = implementationDAO.save(reportlet1);
Implementation reportlet2 = entityFactory.newEntity(Implementation.class);
reportlet2.setKey("UserReportlet" + UUID.randomUUID().toString());
reportlet2.setEngine(ImplementationEngine.JAVA);
reportlet2.setType(ImplementationType.REPORTLET);
reportlet2.setBody(POJOHelper.serialize(new UserReportletConf("second")));
reportlet2 = implementationDAO.save(reportlet2);
int beforeCount = reportDAO.findAll().size();
Report report = entityFactory.newEntity(Report.class);
report.setName("new report");
report.setActive(true);
report.add(reportlet1);
report.add(reportlet2);
report.setTemplate(reportTemplateDAO.find("sample"));
report = reportDAO.save(report);
assertNotNull(report);
assertNotNull(report.getKey());
int afterCount = reportDAO.findAll().size();
assertEquals(afterCount, beforeCount + 1);
}
Aggregations