@Test
public void testWriteWhenBufferedWriterThrowsIOExceptionShouldLogError() throws IOException {

    //GIVEN
    Whitebox.setInternalState(underTest, "logger", logger);
    IOException e = new IOException();
    doReturn(OUTPUT_FILE).when(underTest).getOutputFileName(MESSAGE_ID, true);
    given(bufferedWriterFactory.createBufferedWriter(OUTPUT_FILE, OUTPUT_BUFFER_SIZE)).willThrow(e);
    given(response.getWilmaMessageLoggerId()).willReturn(MESSAGE_ID);
    //WHEN
    underTest.write(response, true);
    //THEN
    verify(logger).error(COULD_NOT_WRITE_MESSAGE_ERROR, e);
}