Search in sources :

Example 1 with UserReportletConf

use of org.apache.syncope.common.lib.report.UserReportletConf 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 2 with UserReportletConf

use of org.apache.syncope.common.lib.report.UserReportletConf 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 3 with UserReportletConf

use of org.apache.syncope.common.lib.report.UserReportletConf 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 4 with UserReportletConf

use of org.apache.syncope.common.lib.report.UserReportletConf 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

UserReportletConf (org.apache.syncope.common.lib.report.UserReportletConf)4 Test (org.junit.jupiter.api.Test)4 Response (javax.ws.rs.core.Response)3 ImplementationTO (org.apache.syncope.common.lib.to.ImplementationTO)3 ReportTO (org.apache.syncope.common.lib.to.ReportTO)3 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)1 Implementation (org.apache.syncope.core.persistence.api.entity.Implementation)1 Report (org.apache.syncope.core.persistence.api.entity.Report)1 AbstractTest (org.apache.syncope.core.persistence.jpa.AbstractTest)1