Search in sources :

Example 51 with Modification

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

the class StageJsonPresentationModelTest method materialRevisions.

private MaterialRevisions materialRevisions(String userWithHtmlCharacters) {
    MaterialRevisions revisions = new MaterialRevisions();
    revisions.addRevision(MaterialsMother.svnMaterial(), new Modification(userWithHtmlCharacters, "comment", "email", new Date(), "r1"));
    return revisions;
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) Date(java.util.Date)

Example 52 with Modification

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

the class BuildCauseProducerServiceTest method shouldHandleNoModificationExceptionThrownByAutoBuild.

@Test
public void shouldHandleNoModificationExceptionThrownByAutoBuild() {
    String pipelineName = "pipeline";
    ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
    PipelineConfig config = PipelineConfigMother.pipelineConfig(pipelineName);
    Material svnMaterial = MaterialsMother.defaultMaterials().get(0);
    DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("up"), new CaseInsensitiveString("s1"));
    config.materialConfigs().clear();
    config.addMaterialConfig(svnMaterial.config());
    config.addMaterialConfig(dependencyMaterial.config());
    when(pipelineService.getRevisionsBasedOnDependencies(Matchers.<MaterialRevisions>any(), Matchers.<BasicCruiseConfig>any(), Matchers.<CaseInsensitiveString>any())).thenThrow(new NoModificationsPresentForDependentMaterialException("P/1/S/1"));
    when(pipelineScheduleQueue.mostRecentScheduled(pipelineName)).thenReturn(BuildCause.createNeverRun());
    Modification modification = ModificationsMother.checkinWithComment("r", "c", new Date(), "f1");
    when(materialRepository.findLatestModification(svnMaterial)).thenReturn(ModificationsMother.createSvnMaterialWithMultipleRevisions(1, modification));
    when(materialRepository.findLatestModification(dependencyMaterial)).thenReturn(new MaterialRevisions(ModificationsMother.changedDependencyMaterialRevision("up", 1, "1", "s", 1, new Date())));
    when(specificMaterialRevisionFactory.create(Matchers.<String>any(), Matchers.<Map<String, String>>any())).thenReturn(MaterialRevisions.EMPTY);
    when(goConfigService.upstreamDependencyGraphOf(Matchers.<String>any(), Matchers.<BasicCruiseConfig>any())).thenReturn(new PipelineConfigDependencyGraph(config));
    MaterialConfigs knownMaterialConfigs = new MaterialConfigs(svnMaterial.config(), dependencyMaterial.config());
    Materials materials = new Materials(svnMaterial, dependencyMaterial);
    when(materialConfigConverter.toMaterials(config.materialConfigs())).thenReturn(materials);
    when(materialExpansionService.expandMaterialConfigsForScheduling(config.materialConfigs())).thenReturn(knownMaterialConfigs);
    when(materialConfigConverter.toMaterials(knownMaterialConfigs)).thenReturn(materials);
    AutoBuild autoBuild = new AutoBuild(goConfigService, pipelineService, pipelineName, new SystemEnvironment(), null);
    ServerHealthState serverHealthState = buildCauseProducerService.newProduceBuildCause(config, autoBuild, result, 12345);
    assertThat(serverHealthState.isSuccess(), is(true));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Materials(com.thoughtworks.go.config.materials.Materials) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Material(com.thoughtworks.go.domain.materials.Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) ServerHealthState(com.thoughtworks.go.serverhealth.ServerHealthState) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) Test(org.junit.Test)

Example 53 with Modification

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

the class ConfigMaterialUpdaterTest method SetUp.

@Before
public void SetUp() {
    repoConfigDataSource = mock(GoRepoConfigDataSource.class);
    materialChecker = mock(MaterialChecker.class);
    materialRepository = mock(MaterialRepository.class);
    configCompleted = mock(ConfigMaterialUpdateCompletedTopic.class);
    topic = mock(MaterialUpdateCompletedTopic.class);
    materialService = mock(MaterialService.class);
    material = new SvnMaterial("url", "tom", "pass", false);
    when(materialRepository.folderFor(material)).thenReturn(folder);
    poller = mock(MaterialPoller.class);
    when(materialService.getPollerImplementation(any(Material.class))).thenReturn(poller);
    Modification svnModification = new Modification("user", "commend", "em@il", new Date(), "1");
    mods = revisions(material, svnModification);
    when(materialRepository.findLatestModification(material)).thenReturn(mods);
    configUpdater = new ConfigMaterialUpdater(repoConfigDataSource, materialRepository, materialChecker, configCompleted, topic, materialService, new TestSubprocessExecutionContext());
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Material(com.thoughtworks.go.domain.materials.Material) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Date(java.util.Date) GoRepoConfigDataSource(com.thoughtworks.go.config.GoRepoConfigDataSource) MaterialService(com.thoughtworks.go.server.service.MaterialService) MaterialPoller(com.thoughtworks.go.server.service.materials.MaterialPoller) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) MaterialRepository(com.thoughtworks.go.server.persistence.MaterialRepository) Before(org.junit.Before)

Example 54 with Modification

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

the class LegacyMaterialCheckerTest method shouldGetModificationsSinceRevision.

@Test
public void shouldGetModificationsSinceRevision() {
    Material material = mock(Material.class);
    MaterialRevision materialRevision = mock(MaterialRevision.class);
    Revision revision = mock(Revision.class);
    List<Modification> modifications = new ArrayList<>();
    when(materialRevision.getRevision()).thenReturn(revision);
    when(materialService.modificationsSince(material, file, revision, null)).thenReturn(modifications);
    List<Modification> actual = checker.findModificationsSince(file, material, materialRevision);
    assertThat(actual, is(modifications));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Revision(com.thoughtworks.go.domain.materials.Revision) ArrayList(java.util.ArrayList) Material(com.thoughtworks.go.domain.materials.Material) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Test(org.junit.Test)

Example 55 with Modification

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

the class MaterialCheckerTest method shouldUseLatestPipelineInstanceForDependentPipeline.

@Test
public void shouldUseLatestPipelineInstanceForDependentPipeline() throws Exception {
    DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
    Stage passedStage = StageMother.passedStageInstance("stage-name", "job-name", "pipeline-name");
    Modification modification = new Modification("Unknown", "Unknown", null, passedStage.completedDate(), "pipeline-name/1[LABEL-1]/stage-name/0");
    Mockito.when(materialRepository.findLatestModification(dependencyMaterial)).thenReturn(revisions(dependencyMaterial, modification));
    materialChecker.findLatestRevisions(new MaterialRevisions(), new Materials(dependencyMaterial));
    Mockito.verify(materialRepository).findLatestModification(dependencyMaterial);
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Materials(com.thoughtworks.go.config.materials.Materials) Stage(com.thoughtworks.go.domain.Stage) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Aggregations

Modification (com.thoughtworks.go.domain.materials.Modification)246 Test (org.junit.Test)176 Date (java.util.Date)76 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)65 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)54 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)40 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)38 ArrayList (java.util.ArrayList)35 File (java.io.File)25 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)21 Modifications (com.thoughtworks.go.domain.materials.Modifications)21 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)20 Material (com.thoughtworks.go.domain.materials.Material)20 Username (com.thoughtworks.go.server.domain.Username)17 StringRevision (com.thoughtworks.go.domain.materials.mercurial.StringRevision)16 HashMap (java.util.HashMap)16 StringContains.containsString (org.hamcrest.core.StringContains.containsString)15 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)14 Stage (com.thoughtworks.go.domain.Stage)13 ModifiedFile (com.thoughtworks.go.domain.materials.ModifiedFile)13