### Question:
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);  }### Answer:
@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"); }
@Test public void addInlineResource_should_add_the_found_resource() { Map<String, Resource> inlineResources = new HashMap<>(); cut.addInlineResource(inlineResources, "name.txt", "templates/some.txt"); assertThat(inlineResources).containsOnlyKeys("name.txt"); assertThat(((ByteArrayResource) inlineResources.get("name.txt")).getByteArray()).isNotEmpty(); }