@Test public void testCounterError() throws IOException { final Counter errorCounter = new Counter(Counter.ERROR_COUNTER_NAME, null); final Collector collector = new Collector("test", Collections.singletonList(errorCounter)); final JavaInformations javaInformations = new JavaInformations(null, true); final ByteArrayOutputStream output = new ByteArrayOutputStream(); final PdfReport pdfReport = new PdfReport(collector, false, Collections.singletonList(javaInformations), Period.TOUT, output); while (errorCounter.getErrorsCount() < Counter.MAX_ERRORS_COUNT) { errorCounter.addErrors(Collections.singletonList(new CounterError("erreur", null))); } pdfReport.toPdf(); assertNotEmptyAndClear(output); final HttpServletRequest httpRequest = createNiceMock(HttpServletRequest.class); expect(httpRequest.getAttribute(CounterError.REQUEST_KEY)).andReturn("/test GET"); expect(httpRequest.getRemoteUser()).andReturn("me"); replay(httpRequest); CounterError.bindRequest(httpRequest); errorCounter.addErrors(Collections.singletonList(new CounterError("with request", null))); CounterError.unbindRequest(); verify(httpRequest); final PdfReport pdfReport2 = new PdfReport(collector, false, Collections.singletonList(javaInformations), Period.TOUT, output); pdfReport2.toPdf(); assertNotEmptyAndClear(output); }
@Override void toPdf() throws DocumentException { final List<CounterError> errors = counter.getErrors(); if (errors.isEmpty()) { addToDocument(new Phrase(getString("Aucune_erreur"), normalFont)); } else { writeErrors(errors); } }
PdfCounterErrorReport extends PdfAbstractTableReport { @Override void toPdf() throws DocumentException { final List<CounterError> errors = counter.getErrors(); if (errors.isEmpty()) { addToDocument(new Phrase(getString("Aucune_erreur"), normalFont)); } else { writeErrors(errors); } } }
PdfCounterErrorReport extends PdfAbstractTableReport { @Override void toPdf() throws DocumentException { final List<CounterError> errors = counter.getErrors(); if (errors.isEmpty()) { addToDocument(new Phrase(getString("Aucune_erreur"), normalFont)); } else { writeErrors(errors); } } PdfCounterErrorReport(Counter counter, Document document); }
PdfCounterErrorReport extends PdfAbstractTableReport { @Override void toPdf() throws DocumentException { final List<CounterError> errors = counter.getErrors(); if (errors.isEmpty()) { addToDocument(new Phrase(getString("Aucune_erreur"), normalFont)); } else { writeErrors(errors); } } PdfCounterErrorReport(Counter counter, Document document);  }
PdfCounterErrorReport extends PdfAbstractTableReport { @Override void toPdf() throws DocumentException { final List<CounterError> errors = counter.getErrors(); if (errors.isEmpty()) { addToDocument(new Phrase(getString("Aucune_erreur"), normalFont)); } else { writeErrors(errors); } } PdfCounterErrorReport(Counter counter, Document document);   }