// Add new files
List<File> originalFiles = TestFileUtil.createRandomFilesInDirectory(config.getLocalDir(), 500*1024, 3);
// Status
ChangeSet changeSet = (new StatusOperation(config).execute()).getChangeSet();
assertEquals(changeSet.getNewFiles().size(), originalFiles.size());
assertEquals(changeSet.getChangedFiles().size(), 0);
assertEquals(changeSet.getDeletedFiles().size(), 0);
// Up
new UpOperation(config).execute();
// Status
changeSet = (new StatusOperation(config).execute()).getChangeSet();
assertEquals(changeSet.getNewFiles().size(), 0);
assertEquals(changeSet.getChangedFiles().size(), 0);
assertEquals(changeSet.getDeletedFiles().size(), 0);
// Change all files, run 'status'
Thread.sleep(2000); // TODO [low] StatusOperation relies on file modified time and size, any other methods?
for (File file : originalFiles) {
TestFileUtil.changeRandomPartOfBinaryFile(file);
}
changeSet = (new StatusOperation(config).execute()).getChangeSet();
assertEquals(changeSet.getNewFiles().size(), 0);
assertEquals(changeSet.getChangedFiles().size(), originalFiles.size());
assertEquals(changeSet.getDeletedFiles().size(), 0);
// Up
new UpOperation(config).execute();
// Delete all files, run 'status' again
for (File file : originalFiles) {
TestFileUtil.deleteFile(file);
}
changeSet = (new StatusOperation(config).execute()).getChangeSet();
assertEquals(changeSet.getNewFiles().size(), 0);
assertEquals(changeSet.getChangedFiles().size(), 0);
assertEquals(changeSet.getDeletedFiles().size(), originalFiles.size());
// Cleanup
TestConfigUtil.deleteTestLocalConfigAndData(config);
}