@Test public void testCounterError() throws IOException { final Counter errorCounter = new Counter(Counter.ERROR_COUNTER_NAME, null); final StringWriter writer = new StringWriter(); final HtmlCounterErrorReport report = new HtmlCounterErrorReport(errorCounter, writer); report.toHtml(); assertNotEmptyAndClear(writer); while (errorCounter.getErrorsCount() < Counter.MAX_ERRORS_COUNT) { errorCounter.addErrors(Collections.singletonList(new CounterError("erreur", null))); } report.toHtml(); assertNotEmptyAndClear(writer); 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); report.toHtml(); assertNotEmptyAndClear(writer); }
@Override void toHtml() throws IOException { final List<CounterError> errors = counter.getErrors(); if (errors.isEmpty()) { writeln("#Aucune_erreur#"); } else { writeErrors(errors); } }
HtmlCounterErrorReport extends HtmlAbstractReport { @Override void toHtml() throws IOException { final List<CounterError> errors = counter.getErrors(); if (errors.isEmpty()) { writeln("#Aucune_erreur#"); } else { writeErrors(errors); } } }
HtmlCounterErrorReport extends HtmlAbstractReport { @Override void toHtml() throws IOException { final List<CounterError> errors = counter.getErrors(); if (errors.isEmpty()) { writeln("#Aucune_erreur#"); } else { writeErrors(errors); } } HtmlCounterErrorReport(Counter counter, Writer writer); }
HtmlCounterErrorReport extends HtmlAbstractReport { @Override void toHtml() throws IOException { final List<CounterError> errors = counter.getErrors(); if (errors.isEmpty()) { writeln("#Aucune_erreur#"); } else { writeErrors(errors); } } HtmlCounterErrorReport(Counter counter, Writer writer); static boolean shouldDisplayUser(List<CounterError> errors); static boolean shouldDisplayHttpRequest(List<CounterError> errors); }
HtmlCounterErrorReport extends HtmlAbstractReport { @Override void toHtml() throws IOException { final List<CounterError> errors = counter.getErrors(); if (errors.isEmpty()) { writeln("#Aucune_erreur#"); } else { writeErrors(errors); } } HtmlCounterErrorReport(Counter counter, Writer writer); static boolean shouldDisplayUser(List<CounterError> errors); static boolean shouldDisplayHttpRequest(List<CounterError> errors);  }