EmailNotificationService implements NotificationService { byte[] readBinaryFromFile(String fileName) { byte[] fileByteArray = null; URL resource = getClass().getClassLoader().getResource(fileName); if (resource != null) { try (InputStream fileStream = resource.openStream()) { fileByteArray = IOUtils.toByteArray(fileStream); } catch (IOException ex) { LOGGER.error("Could not read file: {}. Error message: {}", fileName, ex.getMessage()); } } return fileByteArray; } EmailNotificationService(EmailProvider emailProvider); @Override boolean notify(Notification notification);  }
@Test public void testReadBinaryFromFile() { EmailProvider emailProvider = mock(EmailProvider.class); EmailNotificationService svc = new EmailNotificationService(emailProvider); assertNotNull(svc.readBinaryFromFile("emails/athenz-logo-white.png")); }
@Test public void testReadBinaryFromFileNull() { EmailProvider emailProvider = mock(EmailProvider.class); EmailNotificationService svc = new EmailNotificationService(emailProvider); assertNull(svc.readBinaryFromFile("resources/non-existent")); }