@Test
public void writeErrorResponse() {

  String stackTrace = "error stack trace";
  Exception e = mock(Exception.class);
  prepareErrorStackTrace(e, stackTrace);
  String expectedMessage = createExpectedErrorMessage(stackTrace);
  testSubject.writeErrorResponse(e);
  String writtenMessage = stringWriter.toString();
  Assert.assertEquals(writtenMessage, expectedMessage);
}