Search in sources :

Example 26 with Implementation

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);
}
Also used : DefaultPasswordRuleConf(org.apache.syncope.common.lib.policy.DefaultPasswordRuleConf) PasswordPolicy(org.apache.syncope.core.persistence.api.entity.policy.PasswordPolicy) Implementation(org.apache.syncope.core.persistence.api.entity.Implementation) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 27 with Implementation

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);
}
Also used : UserTO(org.apache.syncope.common.lib.to.UserTO) PullTask(org.apache.syncope.core.persistence.api.entity.task.PullTask) AnyTemplatePullTask(org.apache.syncope.core.persistence.api.entity.task.AnyTemplatePullTask) AnyTemplatePullTask(org.apache.syncope.core.persistence.api.entity.task.AnyTemplatePullTask) PullActions(org.apache.syncope.core.provisioning.api.pushpull.PullActions) ExternalResource(org.apache.syncope.core.persistence.api.entity.resource.ExternalResource) InvalidEntityException(org.apache.syncope.core.persistence.api.attrvalue.validation.InvalidEntityException) Implementation(org.apache.syncope.core.persistence.api.entity.Implementation) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 28 with Implementation

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);
}
Also used : UserReportletConf(org.apache.syncope.common.lib.report.UserReportletConf) Report(org.apache.syncope.core.persistence.api.entity.Report) Implementation(org.apache.syncope.core.persistence.api.entity.Implementation) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Aggregations

Implementation (org.apache.syncope.core.persistence.api.entity.Implementation)28 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)12 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)8 ExternalResource (org.apache.syncope.core.persistence.api.entity.resource.ExternalResource)8 PasswordPolicy (org.apache.syncope.core.persistence.api.entity.policy.PasswordPolicy)7 ImplementationDAO (org.apache.syncope.core.persistence.api.dao.ImplementationDAO)6 AbstractTest (org.apache.syncope.core.persistence.jpa.AbstractTest)6 Test (org.junit.jupiter.api.Test)6 AnyType (org.apache.syncope.core.persistence.api.entity.AnyType)5 Date (java.util.Date)4 AnyTypeDAO (org.apache.syncope.core.persistence.api.dao.AnyTypeDAO)4 EntityFactory (org.apache.syncope.core.persistence.api.entity.EntityFactory)4 AccountPolicy (org.apache.syncope.core.persistence.api.entity.policy.AccountPolicy)4 PullPolicy (org.apache.syncope.core.persistence.api.entity.policy.PullPolicy)4 PullTask (org.apache.syncope.core.persistence.api.entity.task.PullTask)4 SchedTask (org.apache.syncope.core.persistence.api.entity.task.SchedTask)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4 Autowired (org.springframework.beans.factory.annotation.Autowired)4 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)4