@Test public void addInlineResource_should_do_nothing_and_not_crash_when_resource_not_found() { Map<String, Resource> inlineResources = ImmutableMap.of(); cut.addInlineResource(inlineResources, "any", "unexisting"); }
void addInlineResource(Map<String, Resource> inlineResources, String name, String path) { try (final InputStream stream = EmailService.class.getClassLoader().getResourceAsStream(path)) { if (stream == null) { log.error("Cannot find the inline resource in classpath to include it in the email: {}", path); } else { inlineResources.put(name, new ByteArrayResource(IOUtils.toByteArray(stream))); } } catch (IOException e) { log.error("Cannot include the resource in the email: {}", path, e); } }
QualityEmailService { void addInlineResource(Map<String, Resource> inlineResources, String name, String path) { try (final InputStream stream = EmailService.class.getClassLoader().getResourceAsStream(path)) { if (stream == null) { log.error("Cannot find the inline resource in classpath to include it in the email: {}", path); } else { inlineResources.put(name, new ByteArrayResource(IOUtils.toByteArray(stream))); } } catch (IOException e) { log.error("Cannot include the resource in the email: {}", path, e); } } }
QualityEmailService { void addInlineResource(Map<String, Resource> inlineResources, String name, String path) { try (final InputStream stream = EmailService.class.getClassLoader().getResourceAsStream(path)) { if (stream == null) { log.error("Cannot find the inline resource in classpath to include it in the email: {}", path); } else { inlineResources.put(name, new ByteArrayResource(IOUtils.toByteArray(stream))); } } catch (IOException e) { log.error("Cannot include the resource in the email: {}", path, e); } }  }
QualityEmailService { void addInlineResource(Map<String, Resource> inlineResources, String name, String path) { try (final InputStream stream = EmailService.class.getClassLoader().getResourceAsStream(path)) { if (stream == null) { log.error("Cannot find the inline resource in classpath to include it in the email: {}", path); } else { inlineResources.put(name, new ByteArrayResource(IOUtils.toByteArray(stream))); } } catch (IOException e) { log.error("Cannot include the resource in the email: {}", path, e); } }  @Transactional(readOnly = true, noRollbackFor = Exception.class) void sendQualityEmail(long projectId, long executionId); }
QualityEmailService { void addInlineResource(Map<String, Resource> inlineResources, String name, String path) { try (final InputStream stream = EmailService.class.getClassLoader().getResourceAsStream(path)) { if (stream == null) { log.error("Cannot find the inline resource in classpath to include it in the email: {}", path); } else { inlineResources.put(name, new ByteArrayResource(IOUtils.toByteArray(stream))); } } catch (IOException e) { log.error("Cannot include the resource in the email: {}", path, e); } }  @Transactional(readOnly = true, noRollbackFor = Exception.class) void sendQualityEmail(long projectId, long executionId);  }