public void testProjectRename() throws Exception {
FreeStyleProject upstream = createFreeStyleProjectWithFingerprints(singleContents, singleFiles);
FreeStyleProject downstream = createFreeStyleProjectWithFingerprints(singleContents, singleFiles);
FreeStyleBuild upstreamBuild = assertBuildStatusSuccess(upstream.scheduleBuild2(0).get());
FreeStyleBuild downstreamBuild = assertBuildStatusSuccess(downstream.scheduleBuild2(0).get());
String oldUpstreamName = upstream.getName();
String oldDownstreamName = downstream.getName();
// Verify that owner entry in fingerprint record is changed
// after source project is renamed
upstream.renameTo(renamedProject1);
Fingerprinter.FingerprintAction action = upstreamBuild.getAction(Fingerprinter.FingerprintAction.class);
assertNotNull(action);
Collection<Fingerprint> fingerprints = action.getFingerprints().values();
for (Fingerprint f: fingerprints) {
assertTrue(f.getOriginal().is(upstream));
assertTrue(f.getOriginal().getName().equals(renamedProject1));
assertFalse(f.getOriginal().getName().equals(oldUpstreamName));
}
action = downstreamBuild.getAction(Fingerprinter.FingerprintAction.class);
assertNotNull(action);
fingerprints = action.getFingerprints().values();
for (Fingerprint f: fingerprints) {
assertTrue(f.getOriginal().is(upstream));
assertTrue(f.getOriginal().getName().equals(renamedProject1));
assertFalse(f.getOriginal().getName().equals(oldUpstreamName));
}
// Verify that usage entry in fingerprint record is changed after
// sink project is renamed
downstream.renameTo(renamedProject2);
upstream.renameTo(renamedProject1);
action = upstreamBuild.getAction(Fingerprinter.FingerprintAction.class);
assertNotNull(action);
fingerprints = action.getFingerprints().values();
for (Fingerprint f: fingerprints) {
List<String> jobs = f.getJobs();
assertTrue(jobs.contains(renamedProject2));
assertFalse(jobs.contains(oldDownstreamName));
}
action = downstreamBuild.getAction(Fingerprinter.FingerprintAction.class);
assertNotNull(action);
fingerprints = action.getFingerprints().values();
for (Fingerprint f: fingerprints) {
List<String> jobs = f.getJobs();