// - history 1, version 1
FileVersion fileVersion1 = TestDatabaseUtil.createFileVersion("samechecksum1.jpg");
fileVersion1.setChecksum(new FileChecksum(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }));
FileHistoryId idFile1 = FileHistoryId.parseFileId("1111111111111111");
PartialFileHistory fileHistory1 = new PartialFileHistory(idFile1);
fileHistory1.addFileVersion(fileVersion1);
databaseVersion1.addFileHistory(fileHistory1);
database.addDatabaseVersion(databaseVersion1);
assertNotNull(database.getFileHistories(new FileChecksum(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 })));
assertEquals(1, database.getFileHistories(new FileChecksum(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 })).size());
// Round 2: Add two other versions with same checksum to new database version
DatabaseVersion databaseVersion2 = TestDatabaseUtil.createDatabaseVersion(databaseVersion1);
// - history 1, version 2
FileVersion fileVersion11 = TestDatabaseUtil.createFileVersion("samechecksum2-renamed.jpg", fileVersion1);
fileVersion11.setChecksum(new FileChecksum(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 })); // same checksum!
fileVersion11.setStatus(FileStatus.RENAMED);
FileHistoryId idFile11 = FileHistoryId.parseFileId("1111111111111111");
PartialFileHistory fileHistory11 = new PartialFileHistory(idFile11); // same ID as above
fileHistory11.addFileVersion(fileVersion11);
databaseVersion2.addFileHistory(fileHistory11);
// - history 2, version 1
FileVersion fileVersion2 = TestDatabaseUtil.createFileVersion("samechecksum2.jpg");
fileVersion2.setChecksum(new FileChecksum(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 })); // same checksum!
FileHistoryId idFile2 = FileHistoryId.parseFileId("1111111122222222"); // different ID
PartialFileHistory fileHistory2 = new PartialFileHistory(idFile2);
fileHistory2.addFileVersion(fileVersion2);
databaseVersion2.addFileHistory(fileHistory2);
// - history 3, version 1
FileVersion fileVersion3 = TestDatabaseUtil.createFileVersion("samechecksum3.jpg");
fileVersion3.setChecksum(new FileChecksum(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 })); // same checksum!
FileHistoryId idFile3 = FileHistoryId.parseFileId("aaaaaaaa22222222"); // different ID
PartialFileHistory fileHistory3 = new PartialFileHistory(idFile3); // different ID
fileHistory3.addFileVersion(fileVersion3);
databaseVersion2.addFileHistory(fileHistory3);
database.addDatabaseVersion(databaseVersion2);
assertNotNull(database.getFileHistories(new FileChecksum(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 })));