@Test
public void testGenerateResponseShouldReturnStackTraceAsResourceAndSetErrorResponseWhenResponseFormattingFailed() throws Exception {

    //GIVEN
    ParameterList params = new ParameterList();
    responseFormatterDescriptors.add(responseFormatterDescriptor);
    mockTemplateResource();
    given(responseFormatterDescriptor.getResponseFormatter()).willReturn(responseFormatter);
    given(responseFormatterDescriptor.getParams()).willReturn(params);
    given(responseFormatter.formatResponse(wilmaRequest, response, templateResource, params)).willThrow(
            new ResponseFormattingFailedException("Response formatting failed....", new ResponseFormattingFailedException("")));
    //WHEN
    underTest.generateResponse(request, response);
    //THEN
    verify(stackTraceConverter).getStackTraceAsString(Matchers.any(ResponseFormattingFailedException.class));
    verify(headerConfigurer).setErrorResponseContentTypeAndStatus(response);
}