Search in sources :

Example 21 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 22 with MaterialRevisions

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

the class MaterialDatabaseSvnWithExternalsUpdaterTest method shouldUpdateModificationsForExternals.

@Test
public void shouldUpdateModificationsForExternals() throws Exception {
    updater.updateMaterial(material);
    testRepoWithExternal.checkInExternalFile("foo_bar", "foo bar quux");
    updater.updateMaterial(material);
    MaterialRevisions materialRevisions = materialRepository.findLatestModification(material);
    assertThat(materialRevisions.numberOfRevisions(), is(2));
    SvnMaterial externalMaterial = testRepoWithExternal.externalMaterial();
    MaterialRevision revisionForExternal = materialRevisions.findRevisionFor(externalMaterial);
    assertThat(revisionForExternal.getModification(0).getComment(), is("foo bar quux"));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Test(org.junit.Test)

Example 23 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());
    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 24 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 25 with MaterialRevisions

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

the class StageNotificationServiceTest method stubPipelineAndStage.

private void stubPipelineAndStage(Date date) {
    final PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfig("go", "dev", "compile", "test", "twist");
    final Modification svnModification = new Modification("lgao", "Fixing the not checked in files", "jez@cruise.com", date, "123");
    svnModification.createModifiedFile("build.xml", "some_dir", ModifiedAction.added);
    svnModification.createModifiedFile("some.xml", "other_dir", ModifiedAction.deleted);
    Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, new ManualBuild(new Username(new CaseInsensitiveString("loser"))).onModifications(new MaterialRevisions(new MaterialRevision(new MaterialConfigConverter().toMaterials(pipelineConfig.materialConfigs()).get(0), svnModification)), false, null), new DefaultSchedulingContext("loser"), "md5-test", new TimeProvider());
    Stage stage = pipeline.getStages().get(0);
    when(stageService.findStageWithIdentifier(stageIdentifier)).thenReturn(stage);
    stage.setPipelineId(100L);
    when(pipelineService.fullPipelineById(100)).thenReturn(pipeline);
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) TimeProvider(com.thoughtworks.go.util.TimeProvider) Username(com.thoughtworks.go.server.domain.Username) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Stage(com.thoughtworks.go.domain.Stage) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Pipeline(com.thoughtworks.go.domain.Pipeline) DefaultSchedulingContext(com.thoughtworks.go.domain.DefaultSchedulingContext)

Aggregations

MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)215 Test (org.junit.Test)172 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)110 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)72 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)55 Date (java.util.Date)52 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)46 Modification (com.thoughtworks.go.domain.materials.Modification)41 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)35 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)33 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)31 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)30 Materials (com.thoughtworks.go.config.materials.Materials)24 Pipeline (com.thoughtworks.go.domain.Pipeline)22 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)20 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)16 Material (com.thoughtworks.go.domain.materials.Material)16 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)15 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)12 File (java.io.File)12