@Test void testGetFileContentsFromInvalidResource() { EmailException nonexistent = assertThrows(EmailException.class, () -> DEFAULT_FACTORY.getFileContents(null, "not-exist")); assertTrue(nonexistent.getCause() instanceof IllegalArgumentException); try (MockedStatic<Resources> resourcesMock = mockStatic(Resources.class)) { resourcesMock.when(() -> Resources.toString(any(), any())).thenThrow(IOException.class); EmailException exception = assertThrows(EmailException.class, () -> DEFAULT_FACTORY.getFileContents(null, "not-exist\0")); assertTrue(exception.getCause() instanceof IOException); } }
String getFileContents(@Nullable String filePath, String defaultFilePath) { if (filePath != null) { return readFileFromPath(filePath); } return readFileAsResources(defaultFilePath); }
EmailServiceFactory implements Discoverable { String getFileContents(@Nullable String filePath, String defaultFilePath) { if (filePath != null) { return readFileFromPath(filePath); } return readFileAsResources(defaultFilePath); } }
EmailServiceFactory implements Discoverable { String getFileContents(@Nullable String filePath, String defaultFilePath) { if (filePath != null) { return readFileFromPath(filePath); } return readFileAsResources(defaultFilePath); }  }
EmailServiceFactory implements Discoverable { String getFileContents(@Nullable String filePath, String defaultFilePath) { if (filePath != null) { return readFileFromPath(filePath); } return readFileAsResources(defaultFilePath); }  @JsonGetter("messageOptions") MessageOptionsConfiguration getMessageOptionsConfiguration(); String getFromAddress(); Boolean isEnabled(); abstract EmailService createEmailService(MetricRegistry metrics); abstract EmailHealthCheck createHealthCheck(); MessageOptions getMessageOptions(); }
EmailServiceFactory implements Discoverable { String getFileContents(@Nullable String filePath, String defaultFilePath) { if (filePath != null) { return readFileFromPath(filePath); } return readFileAsResources(defaultFilePath); }  @JsonGetter("messageOptions") MessageOptionsConfiguration getMessageOptionsConfiguration(); String getFromAddress(); Boolean isEnabled(); abstract EmailService createEmailService(MetricRegistry metrics); abstract EmailHealthCheck createHealthCheck(); MessageOptions getMessageOptions();  }