### Question:
JsonPrintNameFileReader implements PrintNameFileReader { @Override public PrintNameFile readPrintName(File file, IItemType itemType) throws IOException { try (InputStream stream = new FileInputStream(file)) { String content = IOUtils.toString(stream); ItemReference itemReference = gson.fromJson(content, ItemReference.class); return new PrintNameFile(file, itemReference.printName, itemReference.repositoryId, itemType); } }  @Override PrintNameFile readPrintName(File file, IItemType itemType);  }### Answer:
@SuppressWarnings("ResultOfMethodCallIgnored") @Test public void closesFileAfterReading() throws Exception { File testFile = folder.newFile(); FileUtils.writeStringToFile(testFile, "{repositoryId: x, printName: y}"); IItemType itemType = mock(IItemType.class); new JsonPrintNameFileReader().readPrintName(testFile, itemType); testFile.delete(); assertThat(testFile.exists(), is(false)); }