use of org.apache.syncope.common.lib.to.ReportTemplateTO in project syncope by apache.
the class ReportTemplateITCase method issueSYNCOPE866.
@Test
public void issueSYNCOPE866() {
ReportTemplateTO reportTemplateTO = new ReportTemplateTO();
reportTemplateTO.setKey("empty");
try {
reportTemplateService.create(reportTemplateTO);
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.EntityExists, e.getType());
}
}
use of org.apache.syncope.common.lib.to.ReportTemplateTO in project syncope by apache.
the class ReportTemplateITCase method crud.
@Test
public void crud() throws IOException {
final String key = getUUIDString();
// 1. create (empty) report template
ReportTemplateTO reportTemplateTO = new ReportTemplateTO();
reportTemplateTO.setKey(key);
Response response = reportTemplateService.create(reportTemplateTO);
assertEquals(201, response.getStatus());
// 2. attempt to read HTML and CSV -> fail
try {
reportTemplateService.getFormat(key, ReportTemplateFormat.HTML);
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.NotFound, e.getType());
}
try {
reportTemplateService.getFormat(key, ReportTemplateFormat.CSV);
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.NotFound, e.getType());
}
// 3. set CSV
String csvTemplate = "<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'></xsl:stylesheet>";
reportTemplateService.setFormat(key, ReportTemplateFormat.CSV, IOUtils.toInputStream(csvTemplate, StandardCharsets.UTF_8));
response = reportTemplateService.getFormat(key, ReportTemplateFormat.CSV);
assertEquals(200, response.getStatus());
assertTrue(response.getMediaType().toString().startsWith(MediaType.APPLICATION_XML));
assertTrue(response.getEntity() instanceof InputStream);
assertEquals(csvTemplate, IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8));
// 3. set HTML
String htmlTemplate = "<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'></xsl:stylesheet>";
reportTemplateService.setFormat(key, ReportTemplateFormat.HTML, IOUtils.toInputStream(htmlTemplate, StandardCharsets.UTF_8));
response = reportTemplateService.getFormat(key, ReportTemplateFormat.HTML);
assertEquals(200, response.getStatus());
assertTrue(response.getMediaType().toString().startsWith(MediaType.APPLICATION_XML));
assertTrue(response.getEntity() instanceof InputStream);
assertEquals(htmlTemplate, IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8));
// 4. remove HTML
reportTemplateService.removeFormat(key, ReportTemplateFormat.HTML);
try {
reportTemplateService.getFormat(key, ReportTemplateFormat.HTML);
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.NotFound, e.getType());
}
response = reportTemplateService.getFormat(key, ReportTemplateFormat.CSV);
assertEquals(200, response.getStatus());
assertTrue(response.getMediaType().toString().startsWith(MediaType.APPLICATION_XML));
assertTrue(response.getEntity() instanceof InputStream);
assertEquals(csvTemplate, IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8));
// 5. remove report template
reportTemplateService.delete(key);
try {
reportTemplateService.read(key);
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.NotFound, e.getType());
}
try {
reportTemplateService.getFormat(key, ReportTemplateFormat.HTML);
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.NotFound, e.getType());
}
try {
reportTemplateService.getFormat(key, ReportTemplateFormat.CSV);
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.NotFound, e.getType());
}
}
use of org.apache.syncope.common.lib.to.ReportTemplateTO in project syncope by apache.
the class ReportTemplateLogic method getReportTemplateTO.
private ReportTemplateTO getReportTemplateTO(final String key) {
ReportTemplateTO reportTemplateTO = new ReportTemplateTO();
reportTemplateTO.setKey(key);
return reportTemplateTO;
}
use of org.apache.syncope.common.lib.to.ReportTemplateTO in project syncope by apache.
the class ReportTemplateITCase method list.
@Test
public void list() {
List<ReportTemplateTO> reportTemplateTOs = reportTemplateService.list();
assertNotNull(reportTemplateTOs);
assertFalse(reportTemplateTOs.isEmpty());
for (ReportTemplateTO instance : reportTemplateTOs) {
assertNotNull(instance);
}
}
use of org.apache.syncope.common.lib.to.ReportTemplateTO in project syncope by apache.
the class ReportTemplateITCase method read.
@Test
public void read() {
ReportTemplateTO reportTemplateTO = reportTemplateService.read("sample");
assertNotNull(reportTemplateTO);
}
Aggregations