Search in sources :

Example 1 with ReportTemplateTO

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());
    }
}
Also used : ReportTemplateTO(org.apache.syncope.common.lib.to.ReportTemplateTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) Test(org.junit.jupiter.api.Test)

Example 2 with ReportTemplateTO

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());
    }
}
Also used : Response(javax.ws.rs.core.Response) ReportTemplateTO(org.apache.syncope.common.lib.to.ReportTemplateTO) InputStream(java.io.InputStream) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) Test(org.junit.jupiter.api.Test)

Example 3 with ReportTemplateTO

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;
}
Also used : ReportTemplateTO(org.apache.syncope.common.lib.to.ReportTemplateTO)

Example 4 with 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);
    }
}
Also used : ReportTemplateTO(org.apache.syncope.common.lib.to.ReportTemplateTO) Test(org.junit.jupiter.api.Test)

Example 5 with ReportTemplateTO

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);
}
Also used : ReportTemplateTO(org.apache.syncope.common.lib.to.ReportTemplateTO) Test(org.junit.jupiter.api.Test)

Aggregations

ReportTemplateTO (org.apache.syncope.common.lib.to.ReportTemplateTO)10 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)4 Test (org.junit.jupiter.api.Test)4 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 MailTemplateTO (org.apache.syncope.common.lib.to.MailTemplateTO)2 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URI (java.net.URI)1 JMenuItem (javax.swing.JMenuItem)1 JPopupMenu (javax.swing.JPopupMenu)1 Response (javax.ws.rs.core.Response)1 MailTemplateService (org.apache.syncope.common.rest.api.service.MailTemplateService)1 ReportTemplateService (org.apache.syncope.common.rest.api.service.ReportTemplateService)1 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)1 Entity (org.apache.syncope.core.persistence.api.entity.Entity)1 Report (org.apache.syncope.core.persistence.api.entity.Report)1 ReportTemplate (org.apache.syncope.core.persistence.api.entity.ReportTemplate)1 AddTemplateDialog (org.apache.syncope.ide.eclipse.plugin.dialogs.AddTemplateDialog)1