@Test void createThrowsExceptionIfObjectMapperThrowsException() throws Exception { final CurrentPrimingFileResponseFactory factory = new CurrentPrimingFileResponseFactory(objectMapper); when(objectMapper.writeValueAsString(primedMappings)).thenThrow(new RuntimeException("blah")); assertThatThrownBy(() -> factory.create(primedMappings)) .hasMessageContaining("Failed") .hasCauseInstanceOf(RuntimeException.class); }
public FileResponse create(List<PrimedMapping> primedMappings) { try { final String fileName = createFileName(); final String fileContents = objectMapper.writeValueAsString(primedMappings); return new FileResponse(fileName, fileContents); } catch (Exception e) { throw new RuntimeException("Failed to serialize current priming", e); } }
CurrentPrimingFileResponseFactory { public FileResponse create(List<PrimedMapping> primedMappings) { try { final String fileName = createFileName(); final String fileContents = objectMapper.writeValueAsString(primedMappings); return new FileResponse(fileName, fileContents); } catch (Exception e) { throw new RuntimeException("Failed to serialize current priming", e); } } }
CurrentPrimingFileResponseFactory { public FileResponse create(List<PrimedMapping> primedMappings) { try { final String fileName = createFileName(); final String fileContents = objectMapper.writeValueAsString(primedMappings); return new FileResponse(fileName, fileContents); } catch (Exception e) { throw new RuntimeException("Failed to serialize current priming", e); } } CurrentPrimingFileResponseFactory(ObjectMapper objectMapper); }
CurrentPrimingFileResponseFactory { public FileResponse create(List<PrimedMapping> primedMappings) { try { final String fileName = createFileName(); final String fileContents = objectMapper.writeValueAsString(primedMappings); return new FileResponse(fileName, fileContents); } catch (Exception e) { throw new RuntimeException("Failed to serialize current priming", e); } } CurrentPrimingFileResponseFactory(ObjectMapper objectMapper); FileResponse create(List<PrimedMapping> primedMappings); }
CurrentPrimingFileResponseFactory { public FileResponse create(List<PrimedMapping> primedMappings) { try { final String fileName = createFileName(); final String fileContents = objectMapper.writeValueAsString(primedMappings); return new FileResponse(fileName, fileContents); } catch (Exception e) { throw new RuntimeException("Failed to serialize current priming", e); } } CurrentPrimingFileResponseFactory(ObjectMapper objectMapper); FileResponse create(List<PrimedMapping> primedMappings);  }