Search in sources :

Example 11 with Modification

use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.

the class SvnLogXmlParserTest method shouldParseSvnLogContainingNullComments.

@Test
public void shouldParseSvnLogContainingNullComments() throws IOException {
    InputStream stream = getClass().getResourceAsStream("jemstep_svn_log.xml");
    String xml = FileUtil.readToEnd(stream);
    stream.close();
    SvnLogXmlParser parser = new SvnLogXmlParser();
    List<Modification> revisions = parser.parse(xml, "", new SAXBuilder());
    assertThat(revisions.size(), is(43));
    Modification modWithoutComment = null;
    for (Modification revision : revisions) {
        if (revision.getRevision().equals("7815")) {
            modWithoutComment = revision;
        }
    }
    assertThat(modWithoutComment.getComment(), is(nullValue()));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) SAXBuilder(org.jdom2.input.SAXBuilder) InputStream(java.io.InputStream) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 12 with Modification

use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.

the class SvnLogXmlParserTest method shouldGetAllModifiedFilesUnderRootPath.

@Test
public void shouldGetAllModifiedFilesUnderRootPath() {
    SvnLogXmlParser parser = new SvnLogXmlParser();
    List<Modification> materialRevisions = parser.parse(MULTIPLE_FILES, "", new SAXBuilder());
    Modification mod = materialRevisions.get(0);
    List<ModifiedFile> files = mod.getModifiedFiles();
    assertThat(files.size(), is(2));
    ModifiedFile file = files.get(0);
    assertThat(file.getFileName(), is("/trunk/revision3.txt"));
    assertThat(file.getAction(), is(ModifiedAction.added));
    file = files.get(1);
    assertThat(file.getFileName(), is("/branch/1.1/readme.txt"));
    assertThat(file.getAction(), is(ModifiedAction.deleted));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) SAXBuilder(org.jdom2.input.SAXBuilder) ModifiedFile(com.thoughtworks.go.domain.materials.ModifiedFile) Test(org.junit.Test)

Example 13 with Modification

use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.

the class SvnLogXmlParserTest method shouldParseBJCruiseLogCorrectly.

@Test
public void shouldParseBJCruiseLogCorrectly() {
    String firstChangeLog = "<?xml version=\"1.0\"?>\n" + "<log>\n" + "<logentry\n" + "   revision=\"11238\">\n" + "<author>yxchu</author>\n" + "<date>2008-10-21T14:00:16.598195Z</date>\n" + "<paths>\n" + "<path\n" + "   action=\"M\">/trunk/test/unit/card_selection_test.rb</path>\n" + "<path\n" + "   action=\"M\">/trunk/test/functional/cards_controller_quick_add_test.rb</path>\n" + "<path\n" + "   action=\"M\">/trunk/app/controllers/cards_controller.rb</path>\n" + "</paths>\n" + "<msg>#2761, fix random test failure and add quick add card type to session</msg>\n" + "</logentry>\n" + "</log>";
    String secondChangeLog = "<?xml version=\"1.0\"?>\n" + "<log>\n" + "<logentry\n" + "   revision=\"11239\">\n" + "<author>yxchu</author>\n" + "<date>2008-10-21T14:00:36.209014Z</date>\n" + "<paths>\n" + "<path\n" + "   action=\"M\">/trunk/test/unit/card_selection_test.rb</path>\n" + "</paths>\n" + "<msg>still fix test</msg>\n" + "</logentry>\n" + "<logentry\n" + "   revision=\"11240\">\n" + "<author>yxchu</author>\n" + "<date>2008-10-21T14:00:47.614448Z</date>\n" + "<paths>\n" + "<path\n" + "   action=\"M\">/trunk/test/unit/card_selection_test.rb</path>\n" + "</paths>\n" + "<msg>fix test remove messaging helper</msg>\n" + "</logentry>\n" + "</log>";
    SvnLogXmlParser parser = new SvnLogXmlParser();
    List<Modification> mods = parser.parse(firstChangeLog, ".", new SAXBuilder());
    assertThat(mods.get(0).getUserName(), is("yxchu"));
    List<Modification> mods2 = parser.parse(secondChangeLog, ".", new SAXBuilder());
    assertThat(mods2.size(), is(2));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) SAXBuilder(org.jdom2.input.SAXBuilder) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 14 with Modification

use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.

the class SvnLogXmlParserTest method shouldParse.

@Test
public void shouldParse() throws ParseException {
    SvnLogXmlParser parser = new SvnLogXmlParser();
    List<Modification> materialRevisions = parser.parse(XML, "", new SAXBuilder());
    assertThat(materialRevisions.size(), is(1));
    Modification mod = materialRevisions.get(0);
    assertThat(mod.getRevision(), is("3"));
    assertThat(mod.getUserName(), is("cceuser"));
    assertThat(mod.getModifiedTime(), is(convertDate("2008-03-11T07:52:41.162075Z")));
    assertThat(mod.getComment(), is("[Liyanhui & Gabbar] Checked in new file for test"));
    List<ModifiedFile> files = mod.getModifiedFiles();
    assertThat(files.size(), is(1));
    ModifiedFile file = files.get(0);
    assertThat(file.getFileName(), is("/trunk/revision3.txt"));
    assertThat(file.getAction(), is(ModifiedAction.added));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) SAXBuilder(org.jdom2.input.SAXBuilder) ModifiedFile(com.thoughtworks.go.domain.materials.ModifiedFile) Test(org.junit.Test)

Example 15 with Modification

use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.

the class SvnLogXmlParserTest method shouldFilterModifiedFilesByPath.

@Test
public void shouldFilterModifiedFilesByPath() {
    SvnLogXmlParser parser = new SvnLogXmlParser();
    List<Modification> materialRevisions = parser.parse(MULTIPLE_FILES, "/branch", new SAXBuilder());
    Modification mod = materialRevisions.get(0);
    List<ModifiedFile> files = mod.getModifiedFiles();
    assertThat(files.size(), is(1));
    ModifiedFile file = files.get(0);
    assertThat(file.getFileName(), is("/branch/1.1/readme.txt"));
    assertThat(file.getAction(), is(ModifiedAction.deleted));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) SAXBuilder(org.jdom2.input.SAXBuilder) ModifiedFile(com.thoughtworks.go.domain.materials.ModifiedFile) Test(org.junit.Test)

Aggregations

Modification (com.thoughtworks.go.domain.materials.Modification)242 Test (org.junit.Test)164 Date (java.util.Date)78 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)68 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)55 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)41 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)40 ArrayList (java.util.ArrayList)34 File (java.io.File)25 Modifications (com.thoughtworks.go.domain.materials.Modifications)21 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)20 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)20 Material (com.thoughtworks.go.domain.materials.Material)20 HashMap (java.util.HashMap)18 Username (com.thoughtworks.go.server.domain.Username)17 StringRevision (com.thoughtworks.go.domain.materials.mercurial.StringRevision)15 Pipeline (com.thoughtworks.go.domain.Pipeline)14 Stage (com.thoughtworks.go.domain.Stage)14 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)14 StringContains.containsString (org.hamcrest.core.StringContains.containsString)14