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

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


     * @param path
     *            the Path of the file to create
     * @return the {@link VersionedFile} created
     */
    private VersionedFile createFile(String path) {
        VersionedFile file = fFiles.get(path);
        if (file == null) {
            file = new VersionedFile(path, null);
            String parentPath = this.getParentDirectoryPath(path);
            if (parentPath != null) {
                Directory parent = fDirectories.get(parentPath);
                if (parent == null) {
                    parent = this.createDirectory(parentPath);
                }
                file.setParentDirectory(parent);
                parent.add(file);
            }
            fFiles.put(path, file);
            LOGGER.debug("Created File [" + file + "]");
        }
View Full Code Here


                // 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

     */
    private void createFile() {
        String fullPath = "/" + fCurrentLogEntry.getWorkingFile();
        String parentDirPath = fullPath.substring(0, fullPath.lastIndexOf("/"));
        Directory parent = fAllocatedDirectories.get(parentDirPath);
        VersionedFile currentFile = new VersionedFile(fullPath, parent);

        fParent.add(currentFile);
        fCurrentFile = currentFile;
    }
View Full Code Here

    }
  }

  @Test
  public void testFileMapping() {
    VersionedFile file = new VersionedFile("full_path/foo", null);
    assertEquals("foo", file.getName());

    VersionedFile loadedFile = saveAndReloadUniqueFromDB(file, "from File", VersionedFile.class);
    assertNotNull(loadedFile);
    assertEquals("full_path/foo", loadedFile.getPath());
    assertEquals("foo", loadedFile.getName());
  }
View Full Code Here

  }

  @Test
  public void testDirectoryFileMapping() {
    Directory dir1 = new Directory("/dir_one", Directory.ROOT);
    VersionedFile file1 = new VersionedFile("/dir_one/file_one", dir1);
    VersionedFile file2 = new VersionedFile("/dir_one/file_two", dir1);
    dir1.add(file1);
    dir1.add(file2);
    Directory loadedDir = saveAndReloadUniqueFromDB(Directory.ROOT,
        "from Directory as d where d.path = '/dir_one'", Directory.class);
    assertNotNull(loadedDir);
    VersionedFile loadedFile = loadUniqueFromDB("from File f where f.path = '/dir_one/file_one'", VersionedFile.class);
    assertNotNull(loadedFile);
  }
View Full Code Here

    assertNotNull(loadedFile);
  }

  @Test
  public void testFileRevisionMapping() throws ParseException {
    VersionedFile file1 = new VersionedFile("foobar", null);
 
    Person p1 = new Person();
    p1.setFirstName("fn1");
    p1.setLastName("ln1");
    p1.setEmail("1@1.ch");
   
    Person p2 = new Person();
    p2.setFirstName("fn2");
    p2.setLastName("ln2");
    p2.setEmail("2@2.ch");
   
    Person p3 = new Person();
    p3.setFirstName("fn3");
    p3.setLastName("ln3");
    p3.setEmail("3@3.ch");
;

    ModificationReport mr1 = new ModificationReport("2006/11/08 12:00:00");
    mr1.setAuthor(p1);
    ModificationReport mr2 = new ModificationReport("2006/11/09 12:00:00");
    mr2.setAuthor(p2);
    ModificationReport mr3 = new ModificationReport("2006/11/10 12:00:00");
    mr3.setAuthor(p3);
    fEvolizerSession.startTransaction();
    fEvolizerSession.saveObject(mr1.getAuthor());
    fEvolizerSession.saveObject(mr2.getAuthor());
    fEvolizerSession.saveObject(mr3.getAuthor());
    fEvolizerSession.endTransaction();
   
    Revision rev1 = new Revision("1");
    rev1.setReport(mr1);
    Revision rev2 = new Revision("2");
    rev2.setReport(mr2);
    Revision rev3 = new Revision("3");
    rev3.setReport(mr3);   
   
    file1.addRevision(rev1);
    file1.addRevision(rev2);
    file1.addRevision(rev3);
    VersionedFile loadedFile = saveAndReloadUniqueFromDB(file1,
        "from File f where f.path = 'foobar'", VersionedFile.class);
    assertNotNull(loadedFile);
    assertEquals(rev3.getId(), loadedFile.getLatestRevision().getId());
    assertEquals(rev3.getNumber(), loadedFile.getLatestRevision().getNumber());
    assertEquals(3, loadedFile.getRevisions().size());
  }
View Full Code Here

    assertEquals(d1.hashCode(), d2.hashCode());
  }
 
  @Test
  public void testFileEqualsAndHashCode(){
    VersionedFile f1 = new VersionedFile("/foo/File.java", null);
    assertEquals(false, f1.equals(null));
    assertEquals(false, f1.equals(new Revision("1.1")));
   
    VersionedFile f2 = new VersionedFile("/foo/File.java", null);
   
    assertEquals(true, f1.equals(f2));
    assertEquals(true, f1.hashCode()==f2.hashCode());
   
    VersionedFile f3 = new VersionedFile("/foo/Test.java", null);
    assertFalse(f3.equals(f1));
  }
View Full Code Here

  @Test
  public void testRevisionEqualsAndHashCode(){
    Revision rev1 = new Revision("1.1");
    Revision rev2 = new Revision("1.1");
   
    VersionedFile file = new VersionedFile("foo.bar", null);
    ModificationReport modRe = new ModificationReport();
   
    rev1.setFile(file);
    rev2.setFile(file);
   
View Full Code Here

    /**
     * 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"))
View Full Code Here

    /**
     * Tests a specific modification report
     */
    @Test
    public void testSpecificModificationReport() {
        VersionedFile file =
                sSession.uniqueResult(
                        "from VersionedFile where path = 'test_package/Variables.java'",
                        VersionedFile.class);
        ModificationReport report = file.getRevisions().get(1).getReport();
        assertEquals("Wrong commit message for the report being tested", "change in trial branch", report
                .getCommitMessage());
        assertEquals("Wrong number of lines deleted for the report being tested", 9, report.getLinesDel());
        assertEquals("Wrong number of lines added for the report being tested", 1, report.getLinesAdd());
        Person p = sSession.uniqueResult("from Person where firstName='Giacomo Ghezzi'", Person.class);
View Full Code Here

TOP

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

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.