Package org.evolizer.versioncontrol.cvs.model.entities

Examples of org.evolizer.versioncontrol.cvs.model.entities.Transaction


     * Testing that a {@link File} is correctly removed from a {@link Branch}.
     * @throws Exception
     */
    @Test
    public void testRemoveFromBranch() throws Exception {
        Transaction t = sModelMapper.createTransaction(new Date(97897899));
        ModificationReport m = sModelMapper.createModificationReport(new Date(155323), "another message", sAuthorName);
        SVNVersionedFile f = sModelMapper.createFile("/rootDir/dir/file2.txt");
        sModelMapper.createRevision(2, f, t, m, null, false, "These are the new contents");
        sModelMapper.finalizeTransaction(t, new ArrayList<String>());
       
        Transaction newTrans = sModelMapper.createTransaction(new Date(1576763378));
               
        Branch newBranch = sModelMapper.createBranch(
                new Date(1576763378),
                newTrans,
                "Test branch creation message",
View Full Code Here


     * Testing that that a {@link File} is correctly replaced in a {@link Branch}.
     * @throws Exception
     */
    @Test
    public void testReplaceInBranch() throws Exception {
        Transaction newTrans = sModelMapper.createTransaction(new Date(1599997378));
        Branch newBranch = sModelMapper.createBranch(
                new Date(1576763378),
                newTrans,
                "Test branch creation message",
                sAuthorName,
View Full Code Here

     *            in the commit)
     * @throws GitImporterException
     *             if problems arise while parsing the commit date
     */
    public void createTransaction(Commit commit, Map<String, String> filesContent) throws GitImporterException {
        Transaction currTrans;
        if (fTransactions.containsKey(commit.getSha())) {
            LOGGER
                    .debug("This commit was already extracted for a previous release, so, I'll just attach its related FileVersions to the current release");
            currTrans = fTransactions.get(commit.getSha());
            for (Revision rev : currTrans.getInvolvedRevisions()) {
                fCurrRelease.addRevision(rev);
                rev.addRelease(fCurrRelease);
            }
        } else {
            if (commit.getFiles() != null) {
                currTrans = new Transaction();
                fTransactions.put(commit.getSha(), currTrans);
                try {
                    currTrans.setStarted(this.translateDateString(commit.getDateString()));
                    currTrans.setFinished(this.translateDateString(commit.getDateString()));
                } catch (ParseException e) {
                    throw new GitImporterException("Error while parsing a commit date:\n" + e.getMessage());
                }
                // List<String> res = commit.getMergeDetails();

                for (CommitFile commitFile : commit.getFiles()) {
                    LOGGER.debug("found file " + commitFile.getName());
                    // Check if the file in this commit has already been found in an earlier commit
                    VersionedFile file = this.createFile(commitFile.getName());
                    Revision revision = new Revision(commit.getSha());
                    revision.setFile(file);
                    if (filesContent != null && !filesContent.isEmpty()) {
                        String source = filesContent.get(commitFile.getName());
                        if (source != null) {
                            revision.setSource(source);
                        }
                    }
                    revision.setState(commitFile.getChangeType());
                    Person author = this.createPerson(commit.getAuthor());
                    this.createModificationReport(commitFile, commit, revision, author);

                    // Getting the committer role and adding this new revision to it
                    for (Role r : author.getRoles()) {
                        if (r instanceof CommitterRole) {
                            ((CommitterRole) r).addRevision(revision);
                            break;
                        }
                    }

                    Revision latestRevision = file.getLatestRevision();
                    if (latestRevision != null) {
                        latestRevision.setNextRevision(revision);
                        revision.setPreviousRevision(latestRevision);
                    }
                    file.addRevision(revision);
                    revision.addRelease(fCurrRelease);
                    fCurrRelease.addRevision(revision);
                    currTrans.addRevision(revision);
                    LOGGER.debug("Created Revision " + revision.getNumber() + " for file " + file.getName()
                            + " in release " + fCurrRelease.getName());
                }
            } else {
                LOGGER.info("Commit " + commit.getSha() + " was empty so I'm skipping it");
View Full Code Here

     
      List<Transaction> transactions = s.query("from Transaction as ta order by ta.started", Transaction.class);
     
      assertEquals(5, transactions.size());
     
      Transaction ta1 = transactions.get(0);
      Set<Revision> revisions = ta1.getInvolvedRevisions();
      assertTrue(revisions.contains(rev1));
      assertFalse(revisions.contains(rev2));
      assertFalse(revisions.contains(rev3));
      assertFalse(revisions.contains(rev4));
      assertFalse(revisions.contains(rev5));
     
      Transaction ta2 = transactions.get(1);
      revisions = ta2.getInvolvedRevisions();
      assertFalse(revisions.contains(rev1));
      assertTrue(revisions.contains(rev2));
      assertFalse(revisions.contains(rev3));
      assertFalse(revisions.contains(rev4));
      assertFalse(revisions.contains(rev5));
     
      Transaction ta3 = transactions.get(2);
      revisions = ta3.getInvolvedRevisions();
      assertFalse(revisions.contains(rev1));
      assertFalse(revisions.contains(rev2));
      assertTrue(revisions.contains(rev3));
      assertFalse(revisions.contains(rev4));
      assertFalse(revisions.contains(rev5));
     
      Transaction ta4 = transactions.get(3);
      revisions = ta4.getInvolvedRevisions();
      assertFalse(revisions.contains(rev1));
      assertFalse(revisions.contains(rev2));
      assertFalse(revisions.contains(rev3));
      assertTrue(revisions.contains(rev4));
      assertFalse(revisions.contains(rev5));
     
      Transaction ta5 = transactions.get(4);
      revisions = ta5.getInvolvedRevisions();
      assertFalse(revisions.contains(rev1));
      assertFalse(revisions.contains(rev2));
      assertFalse(revisions.contains(rev3));
      assertFalse(revisions.contains(rev4));
      assertTrue(revisions.contains(rev5))
View Full Code Here

    }
  }
 
  @Test
  public void testTransactionMapping() throws ParseException, EvolizerException{
    Transaction transaction = new Transaction();
    SimpleDateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
    Date date = df.parse("2006/01/02 01:02:03");
    transaction.setStarted(date);
    transaction.setFinished(date);
    Revision rev = new Revision("1.1");
    transaction.addRevision(rev);
   
    ModificationReport modReport = new ModificationReport();
    modReport.setAuthor(new Person());
    rev.setReport(modReport);
   
    fEvolizerSession.startTransaction();
    fEvolizerSession.saveObject(modReport.getAuthor());
    fEvolizerSession.saveObject(rev);
    fEvolizerSession.saveObject(transaction);
    fEvolizerSession.endTransaction();
    fEvolizerSession.close();
   
    fEvolizerSession = fSessionHandler.getCurrentSession(fDBUrl);
   
    List<Transaction> transactionResults = fEvolizerSession.query("from Transaction", Transaction.class);
    assertEquals(1, transactionResults.size());
   
    Transaction transactionResult = (Transaction) transactionResults.get(0);
    assertEquals(date, transactionResult.getStarted());
    assertEquals(date, transactionResult.getFinished());
    assertEquals(1, transactionResult.getInvolvedRevisions().size());
   
    Revision resultInvolvedRevision = transactionResult.getInvolvedRevisions().iterator().next();
    assertEquals("1.1", resultInvolvedRevision.getNumber());
  }
View Full Code Here

     
      List<Transaction> transactions = s.query("from Transaction as ta order by ta.started", Transaction.class);
     
      assertEquals(3, transactions.size());
     
      Transaction ta1 = transactions.get(0);
      Set<Revision> revisions = ta1.getInvolvedRevisions();
      assertTrue(revisions.contains(rev1));
      assertTrue(revisions.contains(rev2));
      assertFalse(revisions.contains(rev3));
      assertFalse(revisions.contains(rev4));
      assertFalse(revisions.contains(rev5));
     
      Transaction ta2 = transactions.get(1);
      revisions = ta2.getInvolvedRevisions();
      assertFalse(revisions.contains(rev1));
      assertFalse(revisions.contains(rev2));
      assertTrue(revisions.contains(rev3));
      assertTrue(revisions.contains(rev4));
      assertFalse(revisions.contains(rev5));
     
      Transaction ta3 = transactions.get(2);
      revisions = ta3.getInvolvedRevisions();
      assertFalse(revisions.contains(rev1));
      assertFalse(revisions.contains(rev2));
      assertFalse(revisions.contains(rev3));
      assertFalse(revisions.contains(rev4));
      assertTrue(revisions.contains(rev5));
View Full Code Here

  }
 
  @Test
  public void testTransactionEqualsAndHashCode(){
    Date date = new Date();
    Transaction t1 = new Transaction();
    Transaction t2 = new Transaction();
    t1.setStarted(date);
    t1.setFinished(date);
   
    t2.setStarted(date);
    t2.setFinished(date);
   
    assertFalse(t1.equals(null));
    assertFalse(t1.equals(new Object()));
    assertTrue(t1.equals(t1));
    assertTrue(t1.equals(t2));
    assertTrue(t1.hashCode()==t2.hashCode());
   
   
    t1.setStarted(null);
    assertFalse(t1.equals(t2));
  }
View Full Code Here

      TransactionReconstructor.calculateCouplings(s, 121000, 120000, null);
     
      List<Transaction> transactions = s.query("from Transaction as ta order by ta.started", Transaction.class);
      assertEquals(2, transactions.size());
     
      Transaction ta1 = transactions.get(0);
      Set<Revision> revisions = ta1.getInvolvedRevisions();
      assertTrue(revisions.contains(rev1));
      assertTrue(revisions.contains(rev2));
      assertTrue(revisions.contains(rev3));
      assertFalse(revisions.contains(rev4));
      assertFalse(revisions.contains(rev5));
     
      Transaction ta2 = transactions.get(1);
      revisions = ta2.getInvolvedRevisions();
      assertFalse(revisions.contains(rev1));
      assertFalse(revisions.contains(rev2));
      assertFalse(revisions.contains(rev3));
      assertTrue(revisions.contains(rev4));
      assertTrue(revisions.contains(rev5));
View Full Code Here

     * @throws ParseException
     *             If problems arise.
     */
    @Test
    public void testChangeSet() throws ParseException {
        Transaction cs = getTransaction("2000-10-31 20:54:15");
        assertNotNull("No transaction done at date 2000-10-31 20:54:15 +0100 was found", cs);
        assertEquals("Wrong author for transaction 2000-10-31 20:54:15 +0100", "russgold", cs.getInvolvedRevisions()
                .iterator().next().getAuthor().getFirstName());
        ArrayList<String> modified = new ArrayList<String>();
        ArrayList<String> added = new ArrayList<String>();

        modified.add("/trunk/httpunit/doc/release_notes.txt");
        modified.add("/trunk/httpunit/src/com/meterware/httpunit/GetMethodWebRequest.java");
        modified.add("/trunk/httpunit/src/com/meterware/httpunit/ParsedHTML.java");
        modified.add("/trunk/httpunit/src/com/meterware/httpunit/PostMethodWebRequest.java");
        modified.add("/trunk/httpunit/src/com/meterware/httpunit/WebForm.java");
        modified.add("/trunk/httpunit/src/com/meterware/httpunit/WebRequest.java");
        modified.add("/trunk/httpunit/src/com/meterware/httpunit/WebResponse.java");
        modified.add("/trunk/httpunit/src/com/meterware/httpunit/WebTable.java");
        modified.add("/trunk/httpunit/test/com/meterware/httpunit/FormParametersTest.java");
        modified.add("/trunk/httpunit/test/com/meterware/httpunit/FormSubmitTest.java");
        modified.add("/trunk/httpunit/test/com/meterware/httpunit/HtmlTablesTest.java");
        modified.add("/trunk/httpunit/test/com/meterware/httpunit/WebFormTest.java");

        added.add("/trunk/httpunit/src/com/meterware/httpunit/SubmitButton.java");

        assertEquals("Erroneous number of involved file versions for ChangeSet at date " + cs.getStarted(), modified
                .size()
                + added.size(), cs.getInvolvedRevisions().size());
        for (Revision ver : cs.getInvolvedRevisions()) {
            String fileVersionId = ver.getFile().getPath() + ":" + ver.getNumber();
            assertEquals(
                    "FileVersion " + fileVersionId + " has not the number of associated to the change set",
                    "67",
                    ver.getNumber());
View Full Code Here

     *
     * @throws ParseException If problems arise.
     */
    @Test
    public void testChangeSet() throws ParseException {
        Transaction cs = getTransaction("2009-10-09 13:57:57 +0200");
        if (cs != null) {
            ArrayList<String> modified = new ArrayList<String>();
            ArrayList<String> added = new ArrayList<String>();
            ArrayList<String> moved = new ArrayList<String>();
            modified.add("/importer_test/trunk/project/.DS_Store");
            modified.add("/importer_test/trunk/project/TestFolder1/TestFile4.txt");
            modified.add("/importer_test/trunk/project/TestFolder1/TestFile5.txt");
            added.add("/importer_test/trunk/project/TestFolder1/TestFile6.txt");
            added.add("/importer_test/trunk/project/TestFolder2/TestFile1.txt");
            moved.add("/importer_test/trunk/project/TestFolder1/TestFile1.txt");
            assertEquals(
                    "Erroneous number of involved file versions for ChangeSet at date " + cs.getStarted(),
                    modified.size() + added.size() + moved.size(),
                    cs.getInvolvedRevisions().size());
            for (Revision ver : cs.getInvolvedRevisions()) {
                String fileVersionId = ver.getFile().getPath() + ":" + ver.getNumber();
                assertEquals(
                        "FileVersion " + fileVersionId + " has not the number of associated to the change set",
                        "20", ver.getNumber());
                assertEquals(
                        "ChangeSet and FileVersion is not symmetrical for FileVersion " + fileVersionId,
                        cs.getId(),
                        ((SVNRevision) ver).getChangeSet().getId());
                assertNotNull("FileVersion " + fileVersionId + " is not associated to any file", ver.getFile());
                if (modified.contains(ver.getFile().getPath())) {
                    assertNotNull("FileVersion " + fileVersionId
                            + " represents a modification, but it's not linked to a previous version", ver
View Full Code Here

TOP

Related Classes of org.evolizer.versioncontrol.cvs.model.entities.Transaction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.