FileSystemUtils { static boolean matches(Path pathFile, String contentId, FolderContentType contentType) { boolean passFilter = false; try (InputStream inputStream = Files.newInputStream(pathFile)) { FolderEntry folderEntry = readEntryFromStream(inputStream); if (Objects.equals(contentType, folderEntry.getContentType()) && StringUtils.equalsIgnoreCase(folderEntry.getContentId(), contentId)) { passFilter = true; } } catch (IOException e) { throw new TDPException(UNABLE_TO_READ_FOLDER_ENTRY, e, build().put("path", pathFile)); } return passFilter; } private  FileSystemUtils(); static String toId(FolderPath folderPath); static FolderPath fromId(String id);  }
@Test public void matches_entryMatches() throws Exception { Path testEntry = testFolder.resolve("testEntry"); String contentId = "contentId"; String folderId = "folderId"; FolderContentType contentType = FolderContentType.PREPARATION; createEntry(testEntry, contentId, folderId, contentType); assertTrue(FileSystemUtils.matches(testEntry, contentId, contentType)); }
@Test public void matches_entryDoesNotMatch() throws Exception { Path testEntry = testFolder.resolve("testEntry"); String contentId = "contentId"; String folderId = "folderId"; FolderContentType contentType = FolderContentType.PREPARATION; createEntry(testEntry, contentId, folderId, contentType); assertFalse(FileSystemUtils.matches(testEntry, "other id", contentType)); }