Package org.evolizer.versioncontrol.svn.model.entities

Examples of org.evolizer.versioncontrol.svn.model.entities.SVNRelease


     * @throws Exception
     */
    @Test
    public void testFinalizeRelease() throws Exception{
        sModelMapper.finalizeRelease(sRel);
        SVNRelease rel = sSession.uniqueResult("from SVNRelease where name = 'releaseTag'" , SVNRelease.class);
        assertEquals("The number of revisions for the fetched test release is not what expected", 1, rel.getRevisions().size());
        assertTrue(rel.getRevisions().iterator().next().getFile().getPath().compareTo("/rootDir/dir/file.txt") == 0);

        //Testing also that the directories and files that were created for the release are removed from the SVNModelMapper
        Field dirsField = SVNModelMapper.class.getDeclaredField("fDirectories");
        dirsField.setAccessible(true);
        HashMap<String, Directory> dirs = (HashMap<String, Directory>) dirsField.get(sModelMapper);
View Full Code Here


     */
    @Test
    public void testConvertReleaseToBranch() throws Exception{
        //First I need to create a release to then convert to a branch
        Transaction newTrans = sModelMapper.createTransaction(new Date(1576563999));        
        SVNRelease newRel =
            sModelMapper.createRelease(
                    new Date(1576563999),
                    newTrans,
                    "Test release creation message",
                    sAuthorName,
                    "/releaseTag3",
                    "/rootDir",
                    1,
                    20);      
        sModelMapper.finalizeRelease(newRel);
        sModelMapper.convertReleaseToBranch(newRel.getName());
       
        assertTrue(sSession.query("from SVNRelease where name = '" + newRel.getName() + "'", SVNRelease.class).isEmpty());
       
        List<SVNRevision> revs = sSession.query("from Revision", SVNRevision.class);
        for (SVNRevision r : revs) {
            for (Release rel : r.getReleases()) {
                assertTrue("revision " +r.getFile().getPath() + ":" + r.getNumber() + "has still a reference to the converted release", rel.getName().compareTo(newRel.getName()) != 0);
            }
        }
        // Check the branch was created and was added to the related field
        Field branchesField = SVNModelMapper.class.getDeclaredField("fBranches");
        branchesField.setAccessible(true);
        HashMap<String, Branch> branches = (HashMap<String, Branch>) branchesField.get(sModelMapper);
        assertTrue("The converted branch does not exist", branches.keySet().contains(newRel.getName()));
    }
View Full Code Here

        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));
        SVNRelease newRel =
            sModelMapper.createRelease(
                    new Date(1576763378),
                    newTrans,
                    "Test release creation message",
                    sAuthorName,
                    "/releaseTag3",
                    "/rootDir",
                    2,
                    7);
       
        // 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("/releaseTag3/dir"));

        Field filesField = SVNModelMapper.class.getDeclaredField("fFiles");
        filesField.setAccessible(true);
        HashMap<String, SVNVersionedFile> files = (HashMap<String, SVNVersionedFile>) filesField.get(sModelMapper);
        assertTrue(files.containsKey("/releaseTag3/dir/file.txt"));
       
        boolean found = false;
        for (Revision r : newRel.getReleaseRevisions()) {
            if (r.getFile().getPath().compareTo("/releaseTag3/dir/file.txt") == 0) {
                found = true;
            }
        }
        assertTrue("The test file was not linked to the associated test release", found);
       
        sModelMapper.removeFromRelease(newRel, "/releaseTag3/dir/file.txt");
        assertTrue(dirs.containsKey("/releaseTag3/dir"));
        assertTrue(files.containsKey("/releaseTag3/dir/file2.txt"));
        assertFalse(files.containsKey("/releaseTag3/dir/file.txt"));
       
        found = false;
        for (Revision r : newRel.getReleaseRevisions()) {
            if (r.getFile().getPath().compareTo("/releaseTag3/dir/file.txt") == 0) {
                found = true;
            }
        }
        assertFalse("The deleted test file is still linked to the associated test release", found);
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(1599997378));
        SVNRelease newRel =
            sModelMapper.createRelease(
                    new Date(1576763378),
                    newTrans,
                    "Test release creation message",
                    sAuthorName,
                    "/releaseTag4",
                    "/rootDir",
                    2,
                    8);
       
        sModelMapper.replaceInRelease(
                newRel,
                newTrans,
                new Date(1576763378),
                "Test release creation message",
                sAuthorName,
                "/releaseTag4/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("/releaseTag4/dir/file3.txt"));
       
        boolean found = false;
        for (Revision rev : newRel.getReleaseRevisions()) {
            if (rev.getFile().getPath().compareTo("/releaseTag4/dir/file3.txt") == 0) {
                found = true;
            }
        }
        assertTrue("The replacement of the replace operation was not found", found);
View Full Code Here

     * @throws ParseException
     *             If problems arise.
     */
    @Test
    public void testRelease() throws ParseException {
        SVNRelease rel = getRelease("httpunit_1_2_2");
        assertEquals("Release " + rel.getName() + " was not created with its real date", sDateFormat.parse(
        "2001-02-21 20:01:07 +0100").toString(), rel.getTimeStamp().toString());Set<Revision> revisions = ((SVNRelease) rel).getReleaseRevisions();
        int versionsCount = 0;
        for (Revision tempVer : revisions) {
            Revision ver = ((SVNRevision) tempVer).getAncestor();
            if (ver.getState() == null) {
                versionsCount++;
            }
        }
        assertEquals("Wrong number of FileVersions for release " + rel.getName(), 71, versionsCount);

        // /tags/httpunit_1_2_2/httpunit/src/com/meterware/httpunit/WebResponse.java
        int totFilesTested = 0;
        for (Revision currRev : revisions) {

            // Testing a normal file
            if (currRev.getFile().getPath().compareTo(
                    "/tags/httpunit_1_2_2/httpunit/src/com/meterware/httpunit/WebResponse.java") == 0) {

                totFilesTested++;
                assertEquals("Wrong File Version", "93", currRev.getNumber());
                SVNRevision ancestor = ((SVNRevision) currRev).getAncestor();
                assertEquals("Wrong ancestor", "/trunk/httpunit/src/com/meterware/httpunit/WebResponse.java", ancestor
                        .getFile().getPath());

                ArrayList<String> versionNums = new ArrayList<String>();
                versionNums.add("85");
                versionNums.add("83");
                versionNums.add("82");
                versionNums.add("79");
                versionNums.add("77");
                versionNums.add("75");
                versionNums.add("72");
                versionNums.add("69");
                versionNums.add("67");
                versionNums.add("60");
                versionNums.add("59");
                versionNums.add("58");
                versionNums.add("56");
                versionNums.add("54");
                versionNums.add("51");
                versionNums.add("48");
                versionNums.add("42");
                versionNums.add("40");
                versionNums.add("38");
                versionNums.add("37");
                versionNums.add("32");
                versionNums.add("29");
                versionNums.add("26");
                versionNums.add("22");
                versionNums.add("21");
                versionNums.add("18");
                versionNums.add("9");
                versionNums.add("8");
                versionNums.add("2");

                for (String version : versionNums) {
                    assertTrue("Wrong version number for file " + ancestor.getFile().getPath(), version
                            .compareTo(ancestor.getNumber()) == 0);

                    if (version.compareTo("37") == 0) {
                        assertTrue("Wrong commit message for version " + version
                                + " of file /trunk/httpunit/src/com/meterware/httpunit/WebResponse.java for release "
                                + rel.getName(), ancestor.getReport().getCommitMessage().contains(
                                "Added getTitle, getURLString"));
                        assertTrue(
                                "Wrong commit author for version "
                                        + version
                                        + " of file /trunk/httpunit/src/com/meterware/httpunit/WebResponse.java for release "
                                        + rel.getName(),
                                ancestor.getReport().getAuthor().getFirstName().compareTo("russgold") == 0);

                        for (Role r : ancestor.getReport().getAuthor().getRoles()) {
                            if (r instanceof CommitterRole) {
                                assertTrue("Author of " + ancestor.getFile().getName() + ":" + ancestor.getNumber()
                                        + " doesn't have it in its artifacts", ((CommitterRole) r).getArtifacts()
                                        .contains(ancestor));
                                break;
                            }
                        }
                        assertTrue("Wrong commit date for version " + version
                                + " of file /trunk/httpunit/src/com/meterware/httpunit/WebResponse.java for release "
                                + rel.getName(), sDateFormat.parse("2000-09-11 16:23:48 +0200").equals(
                                        ancestor.getReport().getCreationTime()));
                    }
                    if (ancestor.getPreviousRevision() != null) {
                        assertEquals("Next and PreviousVersion of two successive FileVersions don't match for release "
                                + rel.getName(), ancestor.getPreviousRevision().getNextRevision().getId(), ancestor.getId());
                    }
                    if (ancestor.getPreviousRevision() != null) {
                        ancestor = sSession.load(SVNRevision.class, ancestor
                                .getPreviousRevision().getId());
                    }

                }
            } else if (currRev.getFile().getPath().compareTo("/tags/httpunit_1_2_2/httpunit/examples/NearWords.java") == 0) {
                totFilesTested++;
                assertTrue("Wrong ancestor for moved file " + currRev.getFile().getPath() + " for release "
                        + rel.getName(), ((SVNRevision) currRev).getAncestor().getFile().getPath().compareTo(
                        "/branches/meterware/httpunit/examples/NearWords.java") == 0);
                assertEquals("Wrong revision number for the ancestor of file " + currRev.getFile().getPath()
                        + " for release " + rel.getName(), "3", ((SVNRevision) currRev).getAncestor().getNumber());
                assertTrue("Wrong commit message for the ancestor of file " + currRev.getFile().getPath()
                        + " for release " + rel.getName(), ((SVNRevision) currRev).getAncestor().getReport()
                        .getCommitMessage().compareTo(
                                "This commit was manufactured by cvs2svn to create branch 'meterware'.") == 0);
            }
        }
        assertEquals(
                "Didn't test all the versions I was supposed to test, I might have not found some of them for release "
                        + rel.getName(),
                2,
                totFilesTested);
    }
View Full Code Here

     *
     * @throws ParseException If problems arise.
     */
    @Test
    public void testRelease() throws ParseException {
        SVNRelease rel = getRelease("project_0_2");
        assertEquals("Release " + rel.getName() + " was not created with its real date",
        "Fri Oct 09 13:42:55 CEST 2009", rel.getTimeStamp().toString());
        Set<Revision> revisions = ((SVNRelease) rel).getReleaseRevisions();
        int versionsCount = 0;
        for (Revision tempVer : revisions) {
            Revision ver = ((SVNRevision) tempVer).getAncestor();
            if (ver.getState() == null) {
                versionsCount++;
            }
        }
        assertEquals("Wrong number of FileVersions for release " + rel.getName(), 6, versionsCount);
        String normFileName = "/importer_test/tags/project_0_2/TestFolder1/TestFile4.txt";
        String normFileAncestorName = "/importer_test/trunk/project/TestFolder1/TestFile4.txt";
        int totFilesTested = 0;
        for (Revision currRev : revisions) {

            if (currRev.getFile().getPath().compareTo(normFileName) == 0) {

               
                assertEquals("Wrong File Version", "15", currRev.getNumber());
                SVNRevision ancestor = ((SVNRevision) currRev).getAncestor();
                assertEquals("Wrong ancestor", normFileAncestorName, ancestor.getFile().getPath());

                ArrayList<String> versionNums = new ArrayList<String>();
                versionNums.add("13");
                versionNums.add("9");
                versionNums.add("8");
                versionNums.add("6");
                versionNums.add("5");
                versionNums.add("3");

                for (String version : versionNums) {
                    assertTrue("Wrong version number for file " + ancestor.getFile().getPath(), version.compareTo(ancestor.getNumber()) == 0);

                    if (version.compareTo("13") == 0) {
                        totFilesTested++;
                        assertTrue("Wrong commit message for version " + version + " of file " + normFileAncestorName + " for release "
                                + rel.getName(), ancestor.getReport().getCommitMessage().contains("modified all files"));
                        assertTrue("Wrong commit author for version " + version + " of file " + normFileAncestorName + " for release "
                                + rel.getName(), ancestor.getReport().getAuthor().getFirstName().compareTo("Giacomo") == 0);

                        for (Role r : ancestor.getReport().getAuthor().getRoles()) {
                            if (r instanceof CommitterRole) {
                                assertTrue("Author of " + ancestor.getFile().getName() + ":" + ancestor.getNumber() + " doesn't have it in its artifacts", ((CommitterRole) r).getArtifacts().contains(ancestor));
                                break;
                            }
                        }
                        assertTrue("Wrong commit date for version " + version + " of file " + normFileAncestorName + " for release "
                                + rel.getName(), "Fri Oct 09 13:40:12 CEST 2009".equals(ancestor.getReport().getCreationTime().toString()));
                    } else if (version.compareTo("3") == 0) {
                        totFilesTested++;
                        assertTrue("Wrong commit message for version " + version + " of file " + normFileAncestorName + " for release "
                                + rel.getName(), ancestor.getReport().getCommitMessage().contains(""));
                        assertTrue("Wrong commit author for version " + version + " of file " + normFileAncestorName + " for release "
                                + rel.getName(), ancestor.getReport().getAuthor().getFirstName().compareTo("Giacomo") == 0);

                        for (Role r : ancestor.getReport().getAuthor().getRoles()) {
                            if (r instanceof CommitterRole) {
                                assertTrue("Author of " + ancestor.getFile().getName() + ":" + ancestor.getNumber() + " doesn't have it in its artifacts", ((CommitterRole) r).getArtifacts().contains(ancestor));
                                break;
                            }
                        }
                        assertTrue("Wrong commit date for version " + version + " of file " + normFileAncestorName + " for release "
                                + rel.getName(), ancestor.getReport().getCreationTime().toString().equals("Fri Oct 09 11:41:31 CEST 2009"));
                     // assert ancestor has no more previous versions
                        assertNull("The number of versions for " + normFileAncestorName + " is more then expected", ancestor.getPreviousRevision());
                       
                    }
                    if (ancestor.getPreviousRevision() != null) {
                        assertEquals(
                                "Next and PreviousVersion of two successive FileVersions don't match for release "
                                + rel.getName(),
                                ancestor.getPreviousRevision().getNextRevision().getId(),
                                ancestor.getId());
                    }
                    if (ancestor.getPreviousRevision() != null) {
                        ancestor = sSession.load(SVNRevision.class, ancestor
                            .getPreviousRevision().getId());
                        }

                }
                break;
            }
        }
        assertEquals(
                "Didn't test all the versions I was supposed to test, I might have not found some of them for release "
                        + rel.getName(),
                2,
                totFilesTested);
    }
View Full Code Here

        TreeMap<String, SVNLogEntryPath> sortedPaths = new TreeMap<String, SVNLogEntryPath>(logEntry.getChangedPaths());
        Transaction changeSet = fModelMapper.createTransaction(logEntry.getDate());
        // I get the first logEntryPath, the one containing the creation of the tag folder and I create a release with
        // that
        SVNLogEntryPath tagPath = sortedPaths.values().iterator().next();
        SVNRelease release =
                fModelMapper.createRelease(
                        logEntry.getDate(),
                        changeSet,
                        logEntry.getMessage(),
                        logEntry.getAuthor(),
                        tagPath.getPath(),
                        tagPath.getCopyPath(),
                        tagPath.getCopyRevision(),
                        logEntry.getRevision());

        // I iterate over remaining log entry paths
        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>();

        // I get all the single log entry paths and classify them as delete, add or replace
        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);
            }
        }

        /*
         * I iterate over the replaces of the log entry
         * Since they are stored in a TreeMap, they are sorted by their names ==> which also means by their path length.
         * In this way if there are chains of recursive replacements inside some directories,
         * I will always replace the father before the child, thus always having consistent data!
         */
        for (SVNLogEntryPath replaceEntry : replace.values()) {
            // for each replace I check whether there is any parent directory involved in an ADD operation.
            // If so I first take care of those related ADD operations
            for (SVNLogEntryPath addEntry : add.values()) {
                if (replaceEntry.getPath().contains(addEntry.getPath())) {
                    /*
                     * I also keep track of the ADDs that I already took care of, as
                     * multiple replacements might share a common directory that has been added and thus
                     * I need to be sure that I add it to the release only once!
                     */
                    if (!alreadyAdded.contains(addEntry)) {
                        alreadyAdded.add(addEntry);
                        // add to release
                        addToRelease(addEntry, logEntry, release, changeSet);
                    }
                }
            }
            // eventually I do the replace
            fModelMapper.replaceInRelease(
                    release,
                    changeSet,
                    logEntry.getDate(),
                    logEntry.getMessage(),
                    logEntry.getAuthor(),
                    replaceEntry.getPath(),
                    replaceEntry.getCopyPath(),
                    replaceEntry.getCopyRevision(),
                    logEntry.getRevision());
        }

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

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

            String fromPath,
            long copyRevisionNum,
            long revisionNum) {

        // Creates the release
        SVNRelease release = new SVNRelease(getFolderName(toPath));
        LOGGER.debug(NLS.bind(MapperMessages.SVNModelMapper_createdRelease, release.getName()));
        release.setUrl(toPath);
        release.setTimeStamp(date);
        // Connect the Release to its SVNRevisions
        connectRevisionToBranchOrRelease(
                date,
                changeSet,
                message,
View Full Code Here

     *            The name of the release to be converted.
     * @see org.evolizer.versioncontrol.svn.model.entities.SVNRelease
     * @see org.evolizer.versioncontrol.cvs.model.entities.Branch
     */
    public void convertReleaseToBranch(String releaseName) {
        SVNRelease release =
                fPersistenceProvider.uniqueResult(
                        "from SVNRelease as r where r.name = '" + releaseName + "'",
                        SVNRelease.class);
        Branch branch = new Branch(releaseName);

        // Remove the release reference from all the existing revisions
        for (Revision version : release.getRevisions()) {
            version.getReleases().remove(release);
        }
        for (Revision version : release.getReleaseRevisions()) {
            version.getReleases().remove(release);
            branch.addRevision(version);
        }
        branch.setCreationDate(release.getTimeStamp());
        fBranches.put(releaseName, branch);
        release.setReleaseRevisions(null);
        release.setRevisions(null);
        fPersistenceProvider.delete(release);
        fPersistenceProvider.flush();
    }
View Full Code Here

TOP

Related Classes of org.evolizer.versioncontrol.svn.model.entities.SVNRelease

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.