Search in sources :

Example 96 with Modification

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

the class HgModificationSplitterTest method shouldBeAbleToParseModifications.

@Test
public void shouldBeAbleToParseModifications() throws Exception {
    ConsoleResult result = new ConsoleResult(0, Arrays.asList(("<changeset>\n" + "<node>ca3ebb67f527c0ad7ed26b789056823d8b9af23f</node>\n" + "<author>cruise</author>\n" + "<date>Tue, 09 Dec 2008 18:56:14 +0800</date>\n" + "<desc>test</desc>\n" + "<files>\n" + "<modified>\n" + "<file>end2end/file</file>\n" + "</modified>\n" + "<added>\n" + "<file>end2end/file</file>\n" + "</added>\n" + "<deleted>\n" + "</deleted>\n" + "</files>\n" + "</changeset>").split("\n")), new ArrayList<>(), new ArrayList<>(), new ArrayList<>());
    HgModificationSplitter splitter = new HgModificationSplitter(result);
    List<Modification> list = splitter.modifications();
    assertThat(list.size(), is(1));
    assertThat(list.get(0).getModifiedTime(), is(new DateTime("2008-12-09T18:56:14+08:00").toDate()));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) ConsoleResult(com.thoughtworks.go.util.command.ConsoleResult) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 97 with Modification

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

the class P4CommandTestBase method shouldGetChangesSinceARevision.

@Test
public void shouldGetChangesSinceARevision() throws Exception {
    List<Modification> output = p4.changesSince(new StringRevision("1"));
    assertThat(output.size(), is(3));
    assertThat(output.get(0).getRevision(), is("4"));
    assertThat(output.get(1).getRevision(), is("3"));
    assertThat(output.get(2).getRevision(), is("2"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) Test(org.junit.Test)

Example 98 with Modification

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

the class P4CommandTestBase method shouldReturnEmptyModificationListWhenP4OutputIsEmpty.

@Test
public void shouldReturnEmptyModificationListWhenP4OutputIsEmpty() throws Exception {
    P4Material anotherMaterial = p4Fixture.material(EMPTY_VIEW);
    List<Modification> materialRevisions = anotherMaterial.latestModification(clientFolder, new TestSubprocessExecutionContext());
    assertThat(materialRevisions.size(), is(0));
    List<Modification> mods = anotherMaterial.modificationsSince(clientFolder, new StringRevision("1"), new TestSubprocessExecutionContext());
    assertThat(mods.size(), is(0));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) Test(org.junit.Test)

Example 99 with Modification

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

the class GitCommandTest method shouldRetrieveLatestModificationFromBranch.

@Test
public void shouldRetrieveLatestModificationFromBranch() throws Exception {
    GitTestRepo branchedRepo = GitTestRepo.testRepoAtBranch(GIT_FOO_BRANCH_BUNDLE, BRANCH);
    GitCommand branchedGit = new GitCommand(null, createTempWorkingDirectory(), BRANCH, false, new HashMap<>(), null);
    branchedGit.clone(inMemoryConsumer(), branchedRepo.projectRepositoryUrl());
    Modification mod = branchedGit.latestModification().get(0);
    assertThat(mod.getUserName(), is("Chris Turner <cturner@thoughtworks.com>"));
    assertThat(mod.getComment(), is("Started foo branch"));
    assertThat(mod.getModifiedTime(), is(parseRFC822("Tue, 05 Feb 2009 14:28:08 -0800")));
    assertThat(mod.getRevision(), is("b4fa7271c3cef91822f7fa502b999b2eab2a380d"));
    List<ModifiedFile> files = mod.getModifiedFiles();
    assertThat(files.size(), is(1));
    assertThat(files.get(0).getFileName(), is("first.txt"));
    assertThat(files.get(0).getAction(), is(ModifiedAction.modified));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) GitTestRepo(com.thoughtworks.go.domain.materials.git.GitTestRepo) ModifiedFile(com.thoughtworks.go.domain.materials.ModifiedFile)

Example 100 with Modification

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

the class GitCommandTest method shouldIncludeNewChangesInModificationCheck.

@Test
public void shouldIncludeNewChangesInModificationCheck() throws Exception {
    String originalNode = git.latestModification().get(0).getRevision();
    File testingFile = checkInNewRemoteFile();
    Modification modification = git.latestModification().get(0);
    assertThat(modification.getRevision(), is(not(originalNode)));
    assertThat(modification.getComment(), is("New checkin of " + testingFile.getName()));
    assertThat(modification.getModifiedFiles().size(), is(1));
    assertThat(modification.getModifiedFiles().get(0).getFileName(), is(testingFile.getName()));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) StringContains.containsString(org.hamcrest.core.StringContains.containsString) ModifiedFile(com.thoughtworks.go.domain.materials.ModifiedFile) File(java.io.File)

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