Search in sources :

Example 1 with ReportInfoBuilder

use of com.autentia.tnt.report.ReportInfo.ReportInfoBuilder in project TNTConcept by autentia.

the class ReportInfoTest method builderInShouldSetReportFormat.

@Test
public void builderInShouldSetReportFormat() {
    ReportInfoBuilder builder = new ReportInfoBuilder();
    builder.in(ReportFormat.PDF);
    ReportInfo result = builder.build();
    assertEquals(ReportFormat.PDF, result.format);
}
Also used : ReportInfoBuilder(com.autentia.tnt.report.ReportInfo.ReportInfoBuilder) Test(org.junit.Test)

Example 2 with ReportInfoBuilder

use of com.autentia.tnt.report.ReportInfo.ReportInfoBuilder in project TNTConcept by autentia.

the class ReportInfoTest method builderWithCategoryShouldSetReportCategory.

@Test
public void builderWithCategoryShouldSetReportCategory() {
    ReportInfoBuilder builder = new ReportInfoBuilder();
    builder.withCategory(TEST_REPORT_CATEGORY);
    ReportInfo result = builder.build();
    assertEquals(TEST_REPORT_CATEGORY, result.category);
}
Also used : ReportInfoBuilder(com.autentia.tnt.report.ReportInfo.ReportInfoBuilder) Test(org.junit.Test)

Example 3 with ReportInfoBuilder

use of com.autentia.tnt.report.ReportInfo.ReportInfoBuilder in project TNTConcept by autentia.

the class ReportInfoTest method builderNameShouldSetReportName.

@Test
public void builderNameShouldSetReportName() {
    ReportInfoBuilder builder = new ReportInfoBuilder();
    builder.name(TEST_REPORT_NAME);
    ReportInfo result = builder.build();
    assertEquals(TEST_REPORT_NAME, result.name);
}
Also used : ReportInfoBuilder(com.autentia.tnt.report.ReportInfo.ReportInfoBuilder) Test(org.junit.Test)

Example 4 with ReportInfoBuilder

use of com.autentia.tnt.report.ReportInfo.ReportInfoBuilder in project TNTConcept by autentia.

the class ReportServlet method generateReport.

private void generateReport(HttpServletRequest request, HttpServletResponse response, String reportName, String ext, String reportCategory) throws IOException {
    ReportInfoBuilder builder = new ReportInfoBuilder();
    builder.name(reportName).in(ReportFormat.valueOf(ext)).withCategory(reportCategory);
    Enumeration e = request.getParameterNames();
    while (e.hasMoreElements()) {
        String arg = (String) e.nextElement();
        final String value = request.getParameter(arg);
        builder.andParameter(arg, value);
    }
    ReportGeneratorStandardImpl generator = new ReportGeneratorStandardImpl();
    try {
        generator.generate(builder.build(), response.getOutputStream());
    } catch (ReportException e1) {
        log.error(e1);
        response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e1.getMessage());
    }
    response.setContentType(ReportFormat.valueOf(ext).getResponseType());
}
Also used : Enumeration(java.util.Enumeration) ReportGeneratorStandardImpl(com.autentia.tnt.report.ReportGeneratorStandardImpl) ReportInfoBuilder(com.autentia.tnt.report.ReportInfo.ReportInfoBuilder) ReportException(com.autentia.tnt.error.ReportException)

Example 5 with ReportInfoBuilder

use of com.autentia.tnt.report.ReportInfo.ReportInfoBuilder in project TNTConcept by autentia.

the class ReportInfoTest method builderAndParameterShouldAddAKeyValueElementToParameters.

@Test
public void builderAndParameterShouldAddAKeyValueElementToParameters() {
    ReportInfoBuilder builder = new ReportInfoBuilder();
    builder.andParameter(TEST_REPORT_KEY, TEST_REPORT_VALUE);
    ReportInfo result = builder.build();
    assertEquals(TEST_REPORT_VALUE, result.parameters.get(TEST_REPORT_KEY));
}
Also used : ReportInfoBuilder(com.autentia.tnt.report.ReportInfo.ReportInfoBuilder) Test(org.junit.Test)

Aggregations

ReportInfoBuilder (com.autentia.tnt.report.ReportInfo.ReportInfoBuilder)5 Test (org.junit.Test)4 ReportException (com.autentia.tnt.error.ReportException)1 ReportGeneratorStandardImpl (com.autentia.tnt.report.ReportGeneratorStandardImpl)1 Enumeration (java.util.Enumeration)1