Skip to content

Commit

Permalink
checkstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
Siedlerchr committed Dec 5, 2022
1 parent dc302d3 commit c32e10f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
7 changes: 0 additions & 7 deletions src/main/java/org/jabref/logic/exporter/TemplateExporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,28 +154,21 @@ private Reader getReader(String filename) throws IOException {
} else {
dir = LAYOUT_PREFIX + (directory == null ? "" : directory + '/');
}

// Attempt to get a Reader for the file path given, either by
// loading it as a resource (from within JAR), or as a normal file. If
// unsuccessful (e.g. file not found), an IOException is thrown.
String name = dir + filename;
// Try loading as a resource first. This works for files inside the JAR:


// If that did not work, try loading as a normal file URL:
try {
Path reso = Path.of(TemplateExporter.class.getResource(name).toURI());

if (reso == null) {
reso = Path.of(name);

}
return Files.newBufferedReader(reso, StandardCharsets.UTF_8);

} catch (FileNotFoundException | URISyntaxException ex) {
throw new IOException("Cannot find layout file: '" + name + "'.");
}

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ private void readTermsList(Path path) {
}
try (Stream<String> lines = Files.lines(path, StandardCharsets.UTF_8)) {
this.terms.addAll(lines.map(this::setDescription).filter(line -> line != null).collect(Collectors.toList()));

} catch (IOException e) {
LOGGER.warn("Could not read terms from file {}", path, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ void testAddNewTermListNewListInList(@TempDir Path tempDir) {
ProtectedTermsLoader localLoader = new ProtectedTermsLoader(
new ProtectedTermsPreferences(Collections.emptyList(), Collections.emptyList(),
ProtectedTermsLoader.getInternalLists(), Collections.emptyList()));
ProtectedTermsList newList = localLoader.addNewProtectedTermsList("My new list",
tempDir.resolve("MyNewList.terms").toAbsolutePath().toString());
ProtectedTermsList newList = localLoader.addNewProtectedTermsList("My new list", tempDir.resolve("MyNewList.terms").toAbsolutePath().toString());
assertTrue(localLoader.getProtectedTermsLists().contains(newList));
}

Expand All @@ -186,8 +185,7 @@ void testRemoveTermListReduceTheCount(@TempDir Path tempDir) {
ProtectedTermsLoader localLoader = new ProtectedTermsLoader(
new ProtectedTermsPreferences(Collections.emptyList(), Collections.emptyList(),
ProtectedTermsLoader.getInternalLists(), Collections.emptyList()));
ProtectedTermsList newList = localLoader.addNewProtectedTermsList("My new list",
tempDir.resolve("MyNewList.terms").toAbsolutePath().toString());
ProtectedTermsList newList = localLoader.addNewProtectedTermsList("My new list", tempDir.resolve("MyNewList.terms").toAbsolutePath().toString());
localLoader.removeProtectedTermsList(newList);
assertEquals(ProtectedTermsLoader.getInternalLists().size(), localLoader.getProtectedTermsLists().size());
}
Expand All @@ -197,8 +195,7 @@ void testAddNewTermListSetsCorrectDescription(@TempDir Path tempDir) {
ProtectedTermsLoader localLoader = new ProtectedTermsLoader(
new ProtectedTermsPreferences(Collections.emptyList(), Collections.emptyList(),
ProtectedTermsLoader.getInternalLists(), Collections.emptyList()));
ProtectedTermsList newList = localLoader.addNewProtectedTermsList("My new list",
tempDir.resolve("MyNewList.terms").toAbsolutePath().toString());
ProtectedTermsList newList = localLoader.addNewProtectedTermsList("My new list", tempDir.resolve("MyNewList.terms").toAbsolutePath().toString());
assertEquals("My new list", newList.getDescription());
}
}

0 comments on commit c32e10f

Please sign in to comment.