@Test void createReturnsAFileResponse() throws Exception { final CurrentPrimingFileResponseFactory factory = new CurrentPrimingFileResponseFactory(objectMapper); when(objectMapper.writeValueAsString(primedMappings)).thenReturn(serializedBody); final FileResponse got = factory.create(primedMappings); final LocalDateTime localDateTime = LocalDateTime.ofInstant(now(), ZoneId.systemDefault()); final String expectedFileName = "jzonbie-current-priming-" + localDateTime.toLocalDate(); assertThat(got.getFileName()).startsWith(expectedFileName); assertThat(got.getContents()).isEqualTo(serializedBody); }
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);  }