Search in sources :

Example 21 with ImplementationTO

use of org.apache.syncope.common.lib.to.ImplementationTO in project syncope by apache.

the class SchedTaskITCase method deferred.

@Test
public void deferred() {
    ImplementationTO taskJobDelegate = implementationService.read(ImplementationType.TASKJOB_DELEGATE, TestSampleJobDelegate.class.getSimpleName());
    assertNotNull(taskJobDelegate);
    SchedTaskTO task = new SchedTaskTO();
    task.setActive(true);
    task.setName("deferred");
    task.setJobDelegate(taskJobDelegate.getKey());
    Response response = taskService.create(TaskType.SCHEDULED, task);
    task = getObject(response.getLocation(), TaskService.class, SchedTaskTO.class);
    assertNotNull(task);
    Date initial = new Date();
    Date later = DateUtils.addSeconds(initial, 2);
    taskService.execute(new ExecuteQuery.Builder().key(task.getKey()).startAt(later).build());
    int i = 0;
    int maxit = 50;
    // wait for completion (executions incremented)
    do {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
        }
        task = taskService.read(TaskType.SCHEDULED, task.getKey(), true);
        assertNotNull(task);
        assertNotNull(task.getExecutions());
        i++;
    } while (task.getExecutions().isEmpty() && i < maxit);
    PagedResult<ExecTO> execs = taskService.listExecutions(new ExecQuery.Builder().key(task.getKey()).build());
    assertEquals(1, execs.getTotalCount());
    assertTrue(execs.getResult().get(0).getStart().after(initial));
    // round 1 sec for safety
    assertTrue(DateUtils.addSeconds(execs.getResult().get(0).getStart(), 1).after(later));
}
Also used : ExecTO(org.apache.syncope.common.lib.to.ExecTO) TaskService(org.apache.syncope.common.rest.api.service.TaskService) ExecQuery(org.apache.syncope.common.rest.api.beans.ExecQuery) TestSampleJobDelegate(org.apache.syncope.fit.core.reference.TestSampleJobDelegate) Date(java.util.Date) ImplementationTO(org.apache.syncope.common.lib.to.ImplementationTO) Response(javax.ws.rs.core.Response) SchedTaskTO(org.apache.syncope.common.lib.to.SchedTaskTO) Test(org.junit.jupiter.api.Test)

Example 22 with ImplementationTO

use of org.apache.syncope.common.lib.to.ImplementationTO in project syncope by apache.

the class ReportITCase method delete.

@Test
public void delete() {
    ImplementationTO reportlet1 = new ImplementationTO();
    reportlet1.setKey("UserReportletConf" + getUUIDString());
    reportlet1.setEngine(ImplementationEngine.JAVA);
    reportlet1.setType(ImplementationType.REPORTLET);
    reportlet1.setBody(POJOHelper.serialize(new UserReportletConf("first")));
    Response response = implementationService.create(reportlet1);
    reportlet1.setKey(response.getHeaderString(RESTHeaders.RESOURCE_KEY));
    ImplementationTO reportlet2 = new ImplementationTO();
    reportlet2.setKey("UserReportletConf" + getUUIDString());
    reportlet2.setEngine(ImplementationEngine.JAVA);
    reportlet2.setType(ImplementationType.REPORTLET);
    reportlet2.setBody(POJOHelper.serialize(new UserReportletConf("second")));
    response = implementationService.create(reportlet2);
    reportlet2.setKey(response.getHeaderString(RESTHeaders.RESOURCE_KEY));
    ReportTO report = new ReportTO();
    report.setName("testReportForDelete" + getUUIDString());
    report.getReportlets().add(reportlet1.getKey());
    report.getReportlets().add(reportlet2.getKey());
    report.setTemplate("sample");
    report = createReport(report);
    assertNotNull(report);
    reportService.delete(report.getKey());
    try {
        reportService.read(report.getKey());
        fail("This should not happen");
    } catch (SyncopeClientException e) {
        assertEquals(Response.Status.NOT_FOUND, e.getType().getResponseStatus());
    }
}
Also used : ImplementationTO(org.apache.syncope.common.lib.to.ImplementationTO) Response(javax.ws.rs.core.Response) UserReportletConf(org.apache.syncope.common.lib.report.UserReportletConf) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) ReportTO(org.apache.syncope.common.lib.to.ReportTO) Test(org.junit.jupiter.api.Test)

Example 23 with ImplementationTO

use of org.apache.syncope.common.lib.to.ImplementationTO in project syncope by apache.

the class ReportITCase method update.

@Test
public void update() {
    ImplementationTO reportlet1 = new ImplementationTO();
    reportlet1.setKey("UserReportletConf" + getUUIDString());
    reportlet1.setEngine(ImplementationEngine.JAVA);
    reportlet1.setType(ImplementationType.REPORTLET);
    reportlet1.setBody(POJOHelper.serialize(new UserReportletConf("first")));
    Response response = implementationService.create(reportlet1);
    reportlet1.setKey(response.getHeaderString(RESTHeaders.RESOURCE_KEY));
    ImplementationTO reportlet2 = new ImplementationTO();
    reportlet2.setKey("UserReportletConf" + getUUIDString());
    reportlet2.setEngine(ImplementationEngine.JAVA);
    reportlet2.setType(ImplementationType.REPORTLET);
    reportlet2.setBody(POJOHelper.serialize(new UserReportletConf("second")));
    response = implementationService.create(reportlet2);
    reportlet2.setKey(response.getHeaderString(RESTHeaders.RESOURCE_KEY));
    ReportTO report = new ReportTO();
    report.setName("testReportForUpdate" + getUUIDString());
    report.getReportlets().add(reportlet1.getKey());
    report.getReportlets().add(reportlet2.getKey());
    report.setTemplate("sample");
    report = createReport(report);
    assertNotNull(report);
    assertEquals(2, report.getReportlets().size());
    ImplementationTO reportlet3 = new ImplementationTO();
    reportlet3.setKey("UserReportletConf" + getUUIDString());
    reportlet3.setEngine(ImplementationEngine.JAVA);
    reportlet3.setType(ImplementationType.REPORTLET);
    reportlet3.setBody(POJOHelper.serialize(new UserReportletConf("last")));
    response = implementationService.create(reportlet3);
    reportlet3.setKey(response.getHeaderString(RESTHeaders.RESOURCE_KEY));
    report.getReportlets().add(reportlet3.getKey());
    reportService.update(report);
    ReportTO updated = reportService.read(report.getKey());
    assertNotNull(updated);
    assertEquals(3, updated.getReportlets().size());
}
Also used : ImplementationTO(org.apache.syncope.common.lib.to.ImplementationTO) Response(javax.ws.rs.core.Response) UserReportletConf(org.apache.syncope.common.lib.report.UserReportletConf) ReportTO(org.apache.syncope.common.lib.to.ReportTO) Test(org.junit.jupiter.api.Test)

Example 24 with ImplementationTO

use of org.apache.syncope.common.lib.to.ImplementationTO in project syncope by apache.

the class ReportITCase method create.

@Test
public void create() {
    ImplementationTO reportlet1 = new ImplementationTO();
    reportlet1.setKey("UserReportletConf" + getUUIDString());
    reportlet1.setEngine(ImplementationEngine.JAVA);
    reportlet1.setType(ImplementationType.REPORTLET);
    reportlet1.setBody(POJOHelper.serialize(new UserReportletConf("first")));
    Response response = implementationService.create(reportlet1);
    reportlet1.setKey(response.getHeaderString(RESTHeaders.RESOURCE_KEY));
    ImplementationTO reportlet2 = new ImplementationTO();
    reportlet2.setKey("UserReportletConf" + getUUIDString());
    reportlet2.setEngine(ImplementationEngine.JAVA);
    reportlet2.setType(ImplementationType.REPORTLET);
    reportlet2.setBody(POJOHelper.serialize(new UserReportletConf("second")));
    response = implementationService.create(reportlet2);
    reportlet2.setKey(response.getHeaderString(RESTHeaders.RESOURCE_KEY));
    ReportTO report = new ReportTO();
    report.setName("testReportForCreate" + getUUIDString());
    report.getReportlets().add(reportlet1.getKey());
    report.getReportlets().add(reportlet2.getKey());
    report.setTemplate("sample");
    report = createReport(report);
    assertNotNull(report);
    ReportTO actual = reportService.read(report.getKey());
    assertNotNull(actual);
    assertEquals(actual, report);
}
Also used : ImplementationTO(org.apache.syncope.common.lib.to.ImplementationTO) Response(javax.ws.rs.core.Response) UserReportletConf(org.apache.syncope.common.lib.report.UserReportletConf) ReportTO(org.apache.syncope.common.lib.to.ReportTO) Test(org.junit.jupiter.api.Test)

Example 25 with ImplementationTO

use of org.apache.syncope.common.lib.to.ImplementationTO in project syncope by apache.

the class ReportITCase method auditReport.

@Test
public void auditReport() throws IOException {
    AuditLoggerName auditLoggerName = new AuditLoggerName(AuditElements.EventCategoryType.LOGIC, "UserLogic", null, "selfRead", AuditElements.Result.SUCCESS);
    try {
        LoggerTO loggerTO = new LoggerTO();
        loggerTO.setKey(auditLoggerName.toLoggerName());
        loggerTO.setLevel(LoggerLevel.DEBUG);
        loggerService.update(LoggerType.AUDIT, loggerTO);
        ImplementationTO auditReportlet = new ImplementationTO();
        auditReportlet.setKey("UserReportletConf" + getUUIDString());
        auditReportlet.setEngine(ImplementationEngine.JAVA);
        auditReportlet.setType(ImplementationType.REPORTLET);
        auditReportlet.setBody(POJOHelper.serialize(new AuditReportletConf("auditReportlet" + getUUIDString())));
        Response response = implementationService.create(auditReportlet);
        auditReportlet.setKey(response.getHeaderString(RESTHeaders.RESOURCE_KEY));
        ReportTO report = new ReportTO();
        report.setName("auditReport" + getUUIDString());
        report.setActive(true);
        report.getReportlets().add(auditReportlet.getKey());
        report.setTemplate("sample");
        report = createReport(report);
        String execKey = execReport(report.getKey());
        checkExport(execKey, ReportExecExportFormat.XML);
        report = reportService.read(report.getKey());
        assertNotNull(report.getLastExec());
    } finally {
        loggerService.delete(LoggerType.AUDIT, auditLoggerName.toLoggerName());
    }
}
Also used : LoggerTO(org.apache.syncope.common.lib.log.LoggerTO) ImplementationTO(org.apache.syncope.common.lib.to.ImplementationTO) Response(javax.ws.rs.core.Response) AuditReportletConf(org.apache.syncope.common.lib.report.AuditReportletConf) ReportTO(org.apache.syncope.common.lib.to.ReportTO) AuditLoggerName(org.apache.syncope.common.lib.types.AuditLoggerName) Test(org.junit.jupiter.api.Test)

Aggregations

ImplementationTO (org.apache.syncope.common.lib.to.ImplementationTO)30 Response (javax.ws.rs.core.Response)24 Test (org.junit.jupiter.api.Test)24 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)10 UserTO (org.apache.syncope.common.lib.to.UserTO)9 PullTaskTO (org.apache.syncope.common.lib.to.PullTaskTO)7 TaskService (org.apache.syncope.common.rest.api.service.TaskService)6 UserPatch (org.apache.syncope.common.lib.patch.UserPatch)5 ReportTO (org.apache.syncope.common.lib.to.ReportTO)5 AccountPolicyTO (org.apache.syncope.common.lib.policy.AccountPolicyTO)4 ExecTO (org.apache.syncope.common.lib.to.ExecTO)4 RealmTO (org.apache.syncope.common.lib.to.RealmTO)4 ResourceTO (org.apache.syncope.common.lib.to.ResourceTO)4 DefaultAccountRuleConf (org.apache.syncope.common.lib.policy.DefaultAccountRuleConf)3 PasswordPolicyTO (org.apache.syncope.common.lib.policy.PasswordPolicyTO)3 UserReportletConf (org.apache.syncope.common.lib.report.UserReportletConf)3 ConnObjectTO (org.apache.syncope.common.lib.to.ConnObjectTO)3 SchedTaskTO (org.apache.syncope.common.lib.to.SchedTaskTO)3 TestSampleJobDelegate (org.apache.syncope.fit.core.reference.TestSampleJobDelegate)3 JdbcTemplate (org.springframework.jdbc.core.JdbcTemplate)3