FileVersionComparator versionComparator = new FileVersionComparator(config.getLocalDir(), config.getChunker().getChecksumAlgorithm());
FileVersion fileVersion = new FileVersion();
fileVersion.setVersion(3L);
fileVersion.setChecksum(new FileChecksum(new byte[] { 0x11, 0x22, 0x33 }));
fileVersion.setLastModified(new Date(123456789));
fileVersion.setPath("folder/file");
fileVersion.setSize(999*1024L);
fileVersion.setLinkTarget(null);
fileVersion.setStatus(FileStatus.CHANGED);
fileVersion.setType(FileType.FILE);
if (EnvironmentUtil.isWindows()) {
fileVersion.setDosAttributes("rha-");
}
else if (EnvironmentUtil.isUnixLikeOperatingSystem()) {
fileVersion.setPosixPermissions("rw-rw-r-x");
}
// Run
FileProperties fileProperties = versionComparator.captureFileProperties(fileVersion);
// Test
assertEquals(new FileChecksum(new byte[] { 0x11, 0x22, 0x33 }), fileProperties.getChecksum());
assertEquals(123456789, fileProperties.getLastModified());
assertEquals("folder/file", fileProperties.getRelativePath());
assertEquals(999*1024, fileProperties.getSize());
assertNull(fileProperties.getLinkTarget());
assertTrue(fileProperties.exists());