@Test public void getResourceAsUtf8String_ShouldReturnUtf8Content_WhenResourceExists() { String resource = "demo/resource"; final String content = cut.getResourceAsUtf8String(resource); assertThat(content.replaceAll("[\r\n]", "")).isEqualTo("content-withÜTF8"); }
String getResourceAsUtf8String(String name) { try (final InputStream stream = getClass().getClassLoader().getResourceAsStream(name)) { return IOUtils.toString(stream, StandardCharsets.UTF_8); } catch (IOException | NullPointerException e) { log.error("Cannot read demo resource file in classpath: {}", name, e); throw new NotGonnaHappenException("Demo file should exist and be valid in classpath: " + name); } }
DemoScenarioLoader { String getResourceAsUtf8String(String name) { try (final InputStream stream = getClass().getClassLoader().getResourceAsStream(name)) { return IOUtils.toString(stream, StandardCharsets.UTF_8); } catch (IOException | NullPointerException e) { log.error("Cannot read demo resource file in classpath: {}", name, e); throw new NotGonnaHappenException("Demo file should exist and be valid in classpath: " + name); } } }
DemoScenarioLoader { String getResourceAsUtf8String(String name) { try (final InputStream stream = getClass().getClassLoader().getResourceAsStream(name)) { return IOUtils.toString(stream, StandardCharsets.UTF_8); } catch (IOException | NullPointerException e) { log.error("Cannot read demo resource file in classpath: {}", name, e); throw new NotGonnaHappenException("Demo file should exist and be valid in classpath: " + name); } }  }
DemoScenarioLoader { String getResourceAsUtf8String(String name) { try (final InputStream stream = getClass().getClassLoader().getResourceAsStream(name)) { return IOUtils.toString(stream, StandardCharsets.UTF_8); } catch (IOException | NullPointerException e) { log.error("Cannot read demo resource file in classpath: {}", name, e); throw new NotGonnaHappenException("Demo file should exist and be valid in classpath: " + name); } }  void createScenarios(long projectId, Map<String, Long> functionalityIds); }
DemoScenarioLoader { String getResourceAsUtf8String(String name) { try (final InputStream stream = getClass().getClassLoader().getResourceAsStream(name)) { return IOUtils.toString(stream, StandardCharsets.UTF_8); } catch (IOException | NullPointerException e) { log.error("Cannot read demo resource file in classpath: {}", name, e); throw new NotGonnaHappenException("Demo file should exist and be valid in classpath: " + name); } }  void createScenarios(long projectId, Map<String, Long> functionalityIds);  }