### Question:
SecureExceptionHandlerImpl implements SecureExceptionHandler { @Override public ErrorDescriptor handleException(Throwable t) { return handleException(t, new ErrorDescriptor(), null); }  void setMessageSource(MessageSource messageSource); void setExceptionOutputManager(ExceptionOutputManager exceptionOutputManager); @Override ErrorDescriptor handleException(Throwable t); @Override ErrorDescriptor handleException(Throwable t, ErrorDescriptor errorInfo); @Override ErrorDescriptor handleException(Throwable t, ErrorDescriptor errorInfo, Locale locale); static final String ERROR_UID; }### Answer:
@Test public void shouldReturnProperErrorDescriptorForJasperadminUserWhenErrorOccurred() { final Exception exception = new JSException("jsexception.report.resource.already.exists.no.overwrite", new JRException("1")); doReturn(true).when(outputManagerMock).isExceptionMessageAllowed(); doReturn(true).when(outputManagerMock).isStackTraceAllowed(); doReturn(false).when(outputManagerMock).isUIDOutputOn(); ErrorDescriptor descriptor = exceptionHandler.handleException(exception, new ErrorDescriptor().setMessage(SERVER_ERROR_MESSAGE), Locale.JAPAN); assertEquals(descriptor.getMessage(), SERVER_ERROR_MESSAGE); String[] params = descriptor.getParameters(); assertSame(params.length, 1); }
@Test public void shouldReturnProperErrorDescriptorForJoeuserWhenErrorOccurred() { final Exception exception = new JSException("jsexception.report.resource.already.exists.no.overwrite", new JRException("1")); doReturn(true).when(outputManagerMock).isExceptionMessageAllowed(); doReturn(false).when(outputManagerMock).isStackTraceAllowed(); doReturn(true).when(outputManagerMock).isUIDOutputOn(); doReturn("Error UID").when(messageSourceMock).getMessage( ArgumentMatchers.eq("error.uid.message"), ArgumentMatchers.nullable(Object[].class), ArgumentMatchers.nullable(Locale.class) ); ErrorDescriptor retrievedDescriptor = exceptionHandler.handleException(exception, new ErrorDescriptor().setMessage(SERVER_ERROR_MESSAGE), Locale.JAPAN); assertNotNull(retrievedDescriptor.getErrorUid()); assertEquals(retrievedDescriptor.getMessage(), String.format( "%s (Error UID: %s)", SERVER_ERROR_MESSAGE, retrievedDescriptor.getErrorUid() )); }