use of org.apache.syncope.common.lib.to.ReportTO 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());
}
use of org.apache.syncope.common.lib.to.ReportTO 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);
}
use of org.apache.syncope.common.lib.to.ReportTO 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());
}
}
use of org.apache.syncope.common.lib.to.ReportTO in project syncope by apache.
the class ReportITCase method read.
@Test
public void read() {
ReportTO reportTO = reportService.read("0062ea9c-924d-4ecf-9961-4492a8cc6d1b");
assertNotNull(reportTO);
assertNotNull(reportTO.getExecutions());
assertFalse(reportTO.getExecutions().isEmpty());
}
use of org.apache.syncope.common.lib.to.ReportTO in project syncope by apache.
the class ReportITCase method execReport.
protected static String execReport(final String reportKey) {
ReportTO reportTO = reportService.read(reportKey);
assertNotNull(reportTO);
assertNotNull(reportTO.getExecutions());
int preExecSize = reportTO.getExecutions().size();
ExecTO exec = reportService.execute(new ExecuteQuery.Builder().key(reportKey).build());
assertNotNull(exec);
int i = 0;
int maxit = 50;
// wait for completion (executions incremented)
do {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
reportTO = reportService.read(reportKey);
assertNotNull(reportTO);
assertNotNull(reportTO.getExecutions());
i++;
} while (preExecSize == reportTO.getExecutions().size() && i < maxit);
if (i == maxit) {
fail("Timeout when executing report " + reportKey);
}
exec = reportTO.getExecutions().get(reportTO.getExecutions().size() - 1);
assertEquals(ReportExecStatus.SUCCESS.name(), exec.getStatus());
return exec.getKey();
}
Aggregations