Person author = new Person();
author.setFirstName("Emanuel");
author.setLastName("Giger");
author.setEmail("gigs@orc-warriors.ogrimmar.horde");
Revision oldRevision = new Revision("1.1");
oldRevision.setState("active");
ModificationReport oldReport = new ModificationReport();
oldReport.setCommitMessage("old message");
oldReport.setCreationTime(date);
oldReport.setLinesAdd(12);
oldReport.setLinesDel(14);
oldReport.setAuthor(author);
Revision currentRevision = new Revision("1.2");
currentRevision.setState("active");
currentRevision.setSource("source code of rev 1.2");
ModificationReport currentReport = new ModificationReport();
currentReport.setCommitMessage("current message");
currentReport.setCreationTime(date);
currentReport.setLinesAdd(16);
currentReport.setLinesDel(18);
currentReport.setAuthor(author);
Revision newRevision = new Revision("1.3");
newRevision.setState("active");
ModificationReport newReport = new ModificationReport();
newReport.setCommitMessage("new message");
newReport.setCreationTime(date);
newReport.setLinesAdd(22);
newReport.setLinesDel(17);
newReport.setAuthor(author);
oldRevision.setReport(oldReport);
currentRevision.setReport(currentReport);
newRevision.setReport(newReport);
currentRevision.setPreviousRevision(oldRevision);
currentRevision.setNextRevision(newRevision);
fEvolizerSession.startTransaction();
fEvolizerSession.saveObject(author);
fEvolizerSession.saveObject(oldRevision);
fEvolizerSession.saveObject(newRevision);
fEvolizerSession.saveObject(currentRevision);
fEvolizerSession.endTransaction();
fEvolizerSession.close();
fEvolizerSession = fSessionHandler.getCurrentSession(fDBUrl);
List<Revision> revResults = fEvolizerSession
.query("from Revision as b where b.number = '1.2'", Revision.class);
assertEquals(1, revResults.size());
Revision resultCurrentRevision = (Revision) revResults.get(0);
assertEquals("1.2", resultCurrentRevision.getNumber());
assertEquals("source code of rev 1.2", resultCurrentRevision.getSource());
assertEquals("1.1", resultCurrentRevision.getPreviousRevision()
.getNumber());
assertEquals("1.3", resultCurrentRevision.getNextRevision().getNumber());
ModificationReport resultReport = resultCurrentRevision.getReport();
assertEquals("current message", resultReport.getCommitMessage());
assertEquals(date, resultReport.getCreationTime());
assertEquals(16, resultReport.getLinesAdd());
assertEquals(18, resultReport.getLinesDel());
assertEquals("Emanuel", resultReport.getAuthor().getFirstName());
assertEquals("gigs@orc-warriors.ogrimmar.horde", resultReport
.getAuthor().getEmail());
resultReport = resultCurrentRevision.getPreviousRevision().getReport();
assertEquals("old message", resultReport.getCommitMessage());
assertEquals(date, resultReport.getCreationTime());
assertEquals(12, resultReport.getLinesAdd());
assertEquals(14, resultReport.getLinesDel());
assertEquals("Giger", resultReport.getAuthor().getLastName());
assertEquals("gigs@orc-warriors.ogrimmar.horde", resultReport
.getAuthor().getEmail());
resultReport = resultCurrentRevision.getNextRevision().getReport();
assertEquals("new message", resultReport.getCommitMessage());
assertEquals(date, resultReport.getCreationTime());
assertEquals(22, resultReport.getLinesAdd());
assertEquals(17, resultReport.getLinesDel());
assertEquals("Emanuel", resultReport.getAuthor().getFirstName());