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;
}
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));
}
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());
}
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));
}
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);
}
Aggregations