@Test(expected = GeneratorException.class)
public void testIOExceptionOnWrite() throws GeneratorException, IOException {

    Mockito.doThrow(new IOException()).when(mockWriter).writeValue(mockFile, mockModel);
    Mockito.when(mockDir.exists()).thenReturn(true);
    underTest.generate();
    Mockito.verify(mockWriter).writeValue(mockFile, mockModel);
}