Search in sources :

Example 56 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.

the class MaterialDatabaseSvnWithExternalsUpdaterTest method shouldNotTryToSaveModificationForAnExternalThathasAlreadyBeenSaved.

@Test
public void shouldNotTryToSaveModificationForAnExternalThathasAlreadyBeenSaved() throws Exception {
    updater.updateMaterial(material);
    SvnTestRepoWithExternal otherRepo = new SvnTestRepoWithExternal(testRepoWithExternal.externalRepositoryUrl(), temporaryFolder);
    SvnMaterial otherMaterial = new SvnMaterial(otherRepo.projectRepositoryUrl(), null, null, true);
    updater.updateMaterial(otherMaterial);
    MaterialRevisions materialRevisions = materialRepository.findLatestModification(otherMaterial);
    assertThat(materialRevisions.numberOfRevisions(), is(2));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) SvnTestRepoWithExternal(com.thoughtworks.go.helper.SvnTestRepoWithExternal) Test(org.junit.Test)

Example 57 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.

the class MaterialDatabaseSvnWithExternalsUpdaterTest method shouldUpdateModificationsForNewlyAddedExternalToExistingMaterial.

@Test
public void shouldUpdateModificationsForNewlyAddedExternalToExistingMaterial() throws Exception {
    updater.updateMaterial(material);
    testRepoWithExternal.checkInOneFile("another_dir/some_file");
    testRepoWithExternal.setupExternals("another_repo", new File(testRepoWithExternal.workingFolder(), "another_dir"));
    updater.updateMaterial(material);
    MaterialRevisions materialRevisions = materialRepository.findLatestModification(material);
    assertThat(materialRevisions.numberOfRevisions(), is(3));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) File(java.io.File) Test(org.junit.Test)

Example 58 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.

the class TestBaseForDatabaseUpdater method shouldSaveTheRevisionsInRightOrder.

@Test
public void shouldSaveTheRevisionsInRightOrder() throws Exception {
    updater.updateMaterial(material);
    testRepo.checkInOneFile("test1.txt", "This is a new checkin");
    updater.updateMaterial(material);
    MaterialRevisions original = materialRepository.findLatestModification(material);
    testRepo.checkInOneFile("test2.txt", "Checkin 1");
    testRepo.checkInOneFile("test3.txt", "Checkin 2");
    testRepo.checkInOneFile("test4.txt", "Checkin 3");
    updater.updateMaterial(material);
    List<Modification> changes = materialRepository.findModificationsSince(material, original.getMaterialRevision(0));
    assertThat(changes.size(), is(3));
    assertThat(changes.get(0).getComment(), is("Checkin 3"));
    assertThat(changes.get(1).getComment(), is("Checkin 2"));
    assertThat(changes.get(2).getComment(), is("Checkin 1"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Test(org.junit.Test)

Example 59 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.

the class PipelineServiceIntegrationTest method shouldReturnCorrectNumberOfMaterialRevisionsAndMaterials.

@Test
public void shouldReturnCorrectNumberOfMaterialRevisionsAndMaterials() throws Exception {
    File file1 = new File("file1");
    File file2 = new File("file2");
    File file3 = new File("file3");
    File file4 = new File("file4");
    Material hg = new HgMaterial("url", "Dest");
    String[] hgRevs = new String[] { "h1" };
    u.checkinFiles(hg, "h1", a(file1, file2, file3, file4), ModifiedAction.added);
    ScheduleTestUtil.AddedPipeline pair01 = u.saveConfigWith("pair01", "stageName", u.m(hg));
    u.runAndPass(pair01, hgRevs);
    ReflectionUtil.invoke(pipelineSqlMapDao, "initDao");
    Pipeline pipeline = pipelineService.mostRecentFullPipelineByName("pair01");
    MaterialRevisions materialRevisions = pipeline.getBuildCause().getMaterialRevisions();
    assertThat(materialRevisions.getMaterials().size(), is(1));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Material(com.thoughtworks.go.domain.materials.Material) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) File(java.io.File) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 60 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.

the class PipelineServiceTriangleDependencyTest method shouldNotGetTheRevisionsFromUpStreamPipelineIfTheDependencyMaterialHasNotChanged.

@Test
public void shouldNotGetTheRevisionsFromUpStreamPipelineIfTheDependencyMaterialHasNotChanged() throws Exception {
    MaterialRevisions expected = createHgMaterialWithMultipleRevisions(1L, first);
    MaterialRevision up1Revision = dependencyMaterialRevision("up1", 1, "label", "stage", 1, new Date());
    expected.addRevision(up1Revision);
    MaterialRevisions actual = createHgMaterialWithMultipleRevisions(1L, third);
    actual.addRevision(up1Revision);
    up1Revision.markAsNotChanged();
    PipelineConfig current = createPipelineConfigWithMaterialConfig("current", actual.getMaterials().get(0).config(), new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first")));
    PipelineConfig up1 = createPipelineConfigWithMaterialConfig("up1", expected.getMaterials().get(0).config());
    when(pipelineDao.findBuildCauseOfPipelineByNameAndCounter("up1", 1)).thenReturn(BuildCause.createManualForced(expected, new Username(str("loser"))));
    PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(current, new PipelineConfigDependencyGraph(up1));
    assertThat(service.getRevisionsBasedOnDependencies(dependencyGraph, actual), is(actual));
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) Username(com.thoughtworks.go.server.domain.Username) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) ModificationsMother.dependencyMaterialRevision(com.thoughtworks.go.helper.ModificationsMother.dependencyMaterialRevision) ModificationsMother.changedDependencyMaterialRevision(com.thoughtworks.go.helper.ModificationsMother.changedDependencyMaterialRevision) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Date(java.util.Date) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Aggregations

MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)212 Test (org.junit.Test)166 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)111 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)68 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)55 Date (java.util.Date)49 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)46 Modification (com.thoughtworks.go.domain.materials.Modification)38 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)33 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)33 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)31 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)31 Materials (com.thoughtworks.go.config.materials.Materials)27 Pipeline (com.thoughtworks.go.domain.Pipeline)20 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)19 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)17 Material (com.thoughtworks.go.domain.materials.Material)16 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)15 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)14 File (java.io.File)12