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

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


     */
    @Test
    public void testDeleteBranch() throws Exception{

        Transaction t = sModelMapper.createTransaction(new Date(19847));
        Branch newBranch =
            sModelMapper.createBranch(
                    new Date(4562),
                    t,
                    "branch 2 creation",
                    sAuthorName,
                    "branch_2",
                    null,
                    "/branch2Path",
                    "/rootDir",
                    2,
                    5);

        sModelMapper.deleteBranch(5, sAuthorName, newBranch.getName());

        // Check the deleted branch was removed from to the related field
        Field branchesField = SVNModelMapper.class.getDeclaredField("fBranches");
        branchesField.setAccessible(true);
        HashMap<String, Branch> branches = (HashMap<String, Branch>) branchesField.get(sModelMapper);
View Full Code Here


        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",
                sAuthorName,
                "branch3",
                null,
                "/branch3",
                "/rootDir",
                2,
                11);
        // Check the Files and Dirs were saved in the right private field
        Field dirsField = SVNModelMapper.class.getDeclaredField("fDirectories");
        dirsField.setAccessible(true);
        HashMap<String, Directory> dirs = (HashMap<String, Directory>) dirsField.get(sModelMapper);
        assertTrue(dirs.containsKey("/branch3/dir"));

        Field filesField = SVNModelMapper.class.getDeclaredField("fFiles");
        filesField.setAccessible(true);
        HashMap<String, SVNVersionedFile> files = (HashMap<String, SVNVersionedFile>) filesField.get(sModelMapper);
        assertTrue(files.containsKey("/branch3/dir/file.txt"));
       
        boolean found = false;
        for (Revision r : newBranch.getRevisions()) {
            if (r.getFile().getPath().compareTo("/branch3/dir/file.txt") == 0) {
                found = true;
            }
        }
        assertTrue("The test file was not linked to the associated test release", found);
       
        sModelMapper.removeFromBranch(newBranch, "/branch3/dir/file.txt");
        assertTrue(dirs.containsKey("/branch3/dir"));
        assertTrue(files.containsKey("/branch3/dir/file2.txt"));
        assertFalse(files.containsKey("/branch3/dir/file.txt"));
       
        found = false;
        for (Revision r : newBranch.getRevisions()) {
            if (r.getFile().getPath().compareTo("/branch3/dir/file.txt") == 0) {
                found = true;
            }
        }
        assertFalse("The deleted test file is still linked to the associated test release", found);
View Full Code Here

     * @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,
                "branch4",
                null,
                "/branch4",
                "/rootDir",
                2,
                14);
       
        sModelMapper.replaceInBranch(
                newBranch,
                newTrans,
                new Date(1576763378),
                "Test branch creation message",
                sAuthorName,
                "/branch4/dir",
                "/rootDir2/dir",
                2,
                8);
       
        Field filesField = SVNModelMapper.class.getDeclaredField("fFiles");
        filesField.setAccessible(true);
        HashMap<String, SVNVersionedFile> files = (HashMap<String, SVNVersionedFile>) filesField.get(sModelMapper);
        assertTrue(files.containsKey("/branch4/dir/file.txt"));
       
        boolean found = false;
        for (Revision rev : newBranch.getRevisions()) {
            if (rev.getFile().getPath().compareTo("/branch4/dir/file3.txt") == 0) {
                found = true;
            }
        }
        assertTrue("The replacement of the replace operation was not found", found);
View Full Code Here

    private void addRevisionsToBranches() {
        for (Revision revision : fCurrentRevisions) {
            String revisionNumber = revision.getNumber();

            String branchRevision = revisionNumber.substring(0, revisionNumber.lastIndexOf('.'));
            Branch branch = fTmpBranches.get(branchRevision);
            if (branch != null) {
                branch.addRevision(revision);
            }
        }
    }
View Full Code Here

            String releaseOrBranchTag = sn.getReleaseOrBranchTag();
            String revisionOrBranchNumber = sn.getRevisionOrBranchNumber();
            // branch
            if (isBranchTag(revisionOrBranchNumber)) {
                String branchNumber = convertMagicBranch(revisionOrBranchNumber);
                Branch branch;
                // new Branch
                if (!fAllocatedBranches.containsKey(releaseOrBranchTag)) {
                    branch = new Branch(releaseOrBranchTag);
                    fAllocatedBranches.put(releaseOrBranchTag, branch);
                    // branch was already allocated
                } else {
                    branch = fAllocatedBranches.get(releaseOrBranchTag);
                }
View Full Code Here

            assertTrue("Imported SVN branch " + br.getName() + " does not really exists", branchNames.contains(br
                    .getName()));
            assertFalse("Branch " + br.getName() + " was imported twice", foundBranches.contains(br.getName()));
            foundBranches.add(br.getName());
        }
        Branch branch = getBranch("branch_1");

        Set<Revision> revisions = branch.getRevisions();
        int versionsCount = 0;
        int deletionsCount = 0;
        int movesFromCount = 0;
        for (Revision ver : revisions) {
            if (ver.getState() != null && ver.getState().compareTo("DELETED") == 0) {
                assertNull("The FileVersion has a newer version, even though it is marked as deleted", ver
                        .getNextRevision());
                deletionsCount++;
            } else if (ver.getState() != null && ver.getState().compareTo("MOVED") == 0) {
                assertNotNull("File " + ver.getFile()
                        + " was moved but it was not linked to the new file created from it", ((SVNVersionedFile) ver.getFile())
                        .getCopiedTo());
                assertEquals(
                        "CopiedTo and CopiedFrom don't match",
                        ((SVNVersionedFile) ((SVNVersionedFile) ver.getFile()).getCopiedTo()).getCopiedFrom(),
                        ver.getFile());
                movesFromCount++;
            } else {
                versionsCount++;
            }
        }
        assertEquals("Wrong number of FileVersions for branch " + branch.getName(), 6, versionsCount);
    }
View Full Code Here

     */
    @Test
    public void testBranches() {
        Collection<Branch> branches = getBranches();
        assertEquals("The number of found branches are not what expected", branches.size(), 1);
        Branch branch = branches.iterator().next();
        assertEquals("Branch name is not what it's supposed to be", "meterware", branch.getName());
        assertEquals("Wrong number of FileVersions for branch " + branch.getName(), 15, branch.getRevisions().size());
    }
View Full Code Here

    assertEquals(3, loadedFile.getRevisions().size());
  }

  @Test
  public void testBranchMapping() throws EvolizerException {
    Branch branch = new Branch("branchName");
    Branch firstChildBranch = new Branch("childBranch");
    Branch secondChildBranch = new Branch("childBranch");

    Set<Branch> branchChildren = new HashSet<Branch>();
    branchChildren.add(firstChildBranch);
    branchChildren.add(secondChildBranch);

    branch.setChildren(branchChildren);

    fEvolizerSession.startTransaction();
    fEvolizerSession.saveObject(branch);
    fEvolizerSession.endTransaction();

    fEvolizerSession.close();
    fEvolizerSession = fSessionHandler.getCurrentSession(fDBUrl);

    List<Branch> branchResults = fEvolizerSession.query("from Branch", Branch.class);

    assertEquals(2, branchResults.size());

    Branch branchResult = branchResults.get(0);
    assertEquals(null, branchResult.getParent());
    assertEquals("branchName", branchResult.getName());
    assertEquals(1, branchResult.getChildren().size());

    for (Iterator<Branch> iter = branchResult.getChildren().iterator(); iter
        .hasNext();) {
      Branch childBranch = iter.next();
      assertEquals("childBranch", childBranch.getName());
      assertEquals(new Long(1), childBranch.getParent().getId());
    }
  }
View Full Code Here

    assertFalse(f3.equals(f1));
  }
 
  @Test
  public void testBranchEqualsAndHashCode(){
    Branch b1 = new Branch("myName");
    assertEquals(false, b1.equals(null));
    assertEquals(false, b1.equals(new Object()));
    Branch b2 = new Branch("myName");
    assertEquals(true, b1.equals(b2));
    assertEquals(true, b1.hashCode()==b2.hashCode());
    Branch p1 = new Branch("parent");
    b1.setParent(p1);
    assertEquals(false, b1.equals(b2));
    b2.setParent(p1);
    assertEquals(true, b1.equals(b2));
    assertEquals(true, b1.hashCode()==b2.hashCode());
   
    b1.setName("myName2");
    assertEquals(false, b1.equals(b2));
    b1.setName("myName");
    Branch c1 = new Branch("child1");
    b1.addChild(c1);
    assertEquals(false, b1.equals(b2));
    b2.addChild(c1);
    assertEquals(true, b1.equals(b2));
   
View Full Code Here

            parentTag = tagPath.getCopyPath().substring(tagPath.getCopyPath().lastIndexOf("/") + 1);
        }
        // Create the ChangeSet related to the branch creation
        Transaction changeSet = fModelMapper.createTransaction(logEntry.getDate());
        // Here I don't check whether the logEntryPath points to a directory as It should already be done in isBranch.
        Branch branch =
                fModelMapper.createBranch(
                        logEntry.getDate(),
                        changeSet,
                        logEntry.getMessage(),
                        logEntry.getAuthor(),
                        tag,
                        parentTag,
                        tagPath.getPath(),
                        tagPath.getCopyPath(),
                        tagPath.getCopyRevision(),
                        logEntry.getRevision());

        // I iterate over remaining log entry paths, as there might be some adds or deletes
        sortedPaths.remove(tagPath.getPath());
        ArrayList<SVNLogEntryPath> delete = new ArrayList<SVNLogEntryPath>();
        TreeMap<String, SVNLogEntryPath> add = new TreeMap<String, SVNLogEntryPath>();
        TreeMap<String, SVNLogEntryPath> replace = new TreeMap<String, SVNLogEntryPath>();
        ArrayList<SVNLogEntryPath> alreadyAdded = new ArrayList<SVNLogEntryPath>();
        for (SVNLogEntryPath logEntryPath : sortedPaths.values()) {
            if (logEntryPath.getType() == SVNLogEntryPath.TYPE_DELETED) {
                delete.add(logEntryPath);
            } else if (logEntryPath.getType() == SVNLogEntryPath.TYPE_ADDED) {
                add.put(logEntryPath.getPath().replace(tagPath.getPath(), ""), logEntryPath);
            } else if (logEntryPath.getType() == SVNLogEntryPath.TYPE_REPLACED) {
                replace.put(logEntryPath.getPath().replace(tagPath.getPath(), ""), logEntryPath);
            }
        }
        for (SVNLogEntryPath replaceEntry : replace.values()) {
            for (SVNLogEntryPath addEntry : add.values()) {
                if (replaceEntry.getPath().contains(addEntry.getPath())) {
                    if (!alreadyAdded.contains(addEntry)) {
                        alreadyAdded.add(addEntry);
                        addToBranch(addEntry, logEntry, branch, changeSet);
                    }
                }
            }
            // do the replace
            fModelMapper.replaceInBranch(
                    branch,
                    changeSet,
                    logEntry.getDate(),
                    logEntry.getMessage(),
                    logEntry.getAuthor(),
                    replaceEntry.getPath(),
                    replaceEntry.getCopyPath(),
                    replaceEntry.getCopyRevision(),
                    logEntry.getRevision());
        }

        for (SVNLogEntryPath addEntry : add.values()) {
            if (!alreadyAdded.contains(addEntry)) {
                addToBranch(addEntry, logEntry, branch, changeSet);
            }
        }

        // At last I take care of deletes, after I did all the replacement and additions in the current log
        for (SVNLogEntryPath deletedEntry : delete) {
            LOGGER.debug(NLS.bind(ImporterMessages.EvolizerSVNImporter_deleteFromBranch, deletedEntry.getPath(), branch
                    .getName()));
            fModelMapper.removeFromBranch(branch, deletedEntry.getPath());
        }
        ArrayList<String> toDelete = new ArrayList<String>();
        for (SVNLogEntryPath deleteEntry : delete) {
            toDelete.add(deleteEntry.getPath());
        }
        fModelMapper.finalizeTransaction(changeSet, toDelete);
        LOGGER.debug(NLS.bind(ImporterMessages.EvolizerSVNImporter_createdBranch, branch.getName()));
    }
View Full Code Here

TOP

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

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.