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);
}
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);
}
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);
}
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());
}
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));
}
Aggregations