/**
* Tests a specific release
*/
@Test
public void testFileRevisions() {
VersionedFile file =
sSession.uniqueResult("from VersionedFile where path ='test_package/Base.java'", VersionedFile.class);
// Testing the tot number of revisions
assertEquals("The tested VersionedFile has the wrong number of revisions", 3, file.getRevisions().size());
// Testing first revision
Revision rev = file.getRevisions().get(0);
assertEquals(
"Wrong revision associated to VersionedFile test_package/Base.java",
"3c7a872a1cf0f1a15b17cee278b356f7113e7005",
rev.getNumber());
assertNull("Previous revision of the first ever revision is not null", rev.getPreviousRevision());
assertEquals("Wrong number of releases associated to VersionedFile test_package/Base.java", 2, rev
.getReleases().size());
Object[] rel = rev.getReleases().toArray();
assertTrue(
"Wrong releases associated to the first revision of File test_package/Base.java",
(((Release) rel[0]).getName().equals("first_tag") && ((Release) rel[1]).getName().equals("second_tag"))
|| (((Release) rel[0]).getName().equals("second_tag") && ((Release) rel[0]).getName().equals(
"first_tag")));
// Testing second revision
rev = file.getRevisions().get(1);
assertEquals(
"Wrong revision associated to VersionedFile test_package/Base.java",
"49affa954287880a1d569a39c089723523567dee",
rev.getNumber());
assertEquals(
"Broken link between the first and second releases of VersionedFile test_package/Base.java",
rev,
file.getRevisions().get(0).getNextRevision());
assertEquals(
"Broken link between the second and the first releases of VersionedFile test_package/Base.java",
file.getRevisions().get(0),
rev.getPreviousRevision());
rel = rev.getReleases().toArray();
assertTrue(
"Wrong releases associated to the second revision of File test_package/Base.java",
(((Release) rel[0]).getName().equals("first_tag") && ((Release) rel[1]).getName().equals("second_tag"))
|| (((Release) rel[0]).getName().equals("second_tag") && ((Release) rel[0]).getName().equals(
"first_tag")));
// Testing third revision
rev = file.getRevisions().get(2);
assertEquals(
"Wrong revision associated to VersionedFile test_package/Base.java",
"6c92c63b36973d991ca84d8ce6e8a74f8c45cec3",
rev.getNumber());
assertEquals(
"Broken link between the second and third releases of VersionedFile test_package/Base.java",
rev,
file.getRevisions().get(1).getNextRevision());
assertEquals("Broken link between the thrid and second releases of VersionedFile test_package/Base.java", file
.getRevisions().get(1), rev.getPreviousRevision());
rel = rev.getReleases().toArray();
assertTrue(
"Wrong releases associated to the third revision of File test_package/Base.java",
(((Release) rel[0]).getName().equals("first_tag") && ((Release) rel[1]).getName().equals("second_tag"))