coverageChangeSet);
}
@Test
public void includeModifiedFileInDriftChangeSet() throws Exception {
DriftDefinition def = driftDefinition("file-modified-drift-test", resourceDir.getAbsolutePath());
File confDir = mkdir(resourceDir, "conf");
File server1Conf = createRandomFile(confDir, "server-1.conf");
String oldHash = sha256(server1Conf);
ChangeSetWriter writer = changeSetMgr.getChangeSetWriter(resourceId(), createHeaders(def, COVERAGE));
writer.write(addedFileEntry("conf/server-1.conf", oldHash, server1Conf.lastModified(), server1Conf.length()));
writer.close();
// create some drift
server1Conf.delete();
server1Conf = createRandomFile(confDir, "server-1.conf", 48);
String newHash = sha256(server1Conf);
scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), def));
detector.run();
File driftChangeSet = changeSet(def.getName(), DRIFT);
List<FileEntry> driftEntries = asList(changedFileEntry("conf/server-1.conf", oldHash, newHash, server1Conf
.lastModified(), server1Conf.length()));
// verify that the drift change set was generated
assertTrue(driftChangeSet.exists(), "Expected to find drift change set " + driftChangeSet.getPath());
assertHeaderEquals(driftChangeSet, createHeaders(def, DRIFT, 1));
assertFileEntriesMatch("The drift change set does not match the expected values", driftEntries, driftChangeSet);
File coverageChangeSet = changeSet(def.getName(), COVERAGE);
List<FileEntry> coverageEntries = asList(changedFileEntry("conf/server-1.conf", oldHash, newHash, server1Conf
.lastModified(), server1Conf.length()));
// verify that the coverage change set was updated
assertHeaderEquals(coverageChangeSet, createHeaders(def, COVERAGE, 1));