use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.
the class MaterialDatabaseDependencyUpdaterTest method shouldReturnNoNewModificationsIfNoNewPipelineHasBennCompleted.
@Test
public void shouldReturnNoNewModificationsIfNoNewPipelineHasBennCompleted() throws Exception {
DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
stubStageServiceGetHistory(null, stages(9));
updater.updateMaterial(dependencyMaterial);
List<Modification> modification = materialRepository.findLatestModification(dependencyMaterial).getMaterialRevision(0).getModifications();
stubStageServiceGetHistoryAfter(dependencyMaterial, 9, stages());
updater.updateMaterial(dependencyMaterial);
List<Modification> newModifications = materialRepository.findModificationsSince(dependencyMaterial, new MaterialRevision(dependencyMaterial, modification));
assertThat(newModifications.size(), is(0));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.
the class MaterialDatabaseDependencyUpdaterTest method stubStageServiceGetHistory.
private void stubStageServiceGetHistory(DependencyMaterial dependencyMaterial, Stages... stageses) {
if (material == null) {
dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
}
for (int i = 0; i < stageses.length; i++) {
ArrayList<Modification> mods = new ArrayList<>();
for (Stage stage : stageses[i]) {
StageIdentifier id = stage.getIdentifier();
mods.add(new Modification(stage.completedDate(), id.stageLocator(), id.getPipelineLabel(), stage.getPipelineId()));
}
Mockito.when(dependencyMaterialSourceDao.getPassedStagesByName(dependencyMaterial, Pagination.pageStartingAt(i * MaterialDatabaseUpdater.STAGES_PER_PAGE, null, MaterialDatabaseUpdater.STAGES_PER_PAGE))).thenReturn(mods);
}
Mockito.when(dependencyMaterialSourceDao.getPassedStagesByName(dependencyMaterial, Pagination.pageStartingAt(MaterialDatabaseUpdater.STAGES_PER_PAGE * stageses.length, null, MaterialDatabaseUpdater.STAGES_PER_PAGE))).thenReturn(new ArrayList<>());
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method shouldFindModificationsForAStageIdentifier.
@Test
public void shouldFindModificationsForAStageIdentifier() {
DependencyMaterial material = new DependencyMaterial(new CaseInsensitiveString("P1"), new CaseInsensitiveString("S1"));
repo.saveOrUpdate(material.createMaterialInstance());
saveOneDependencyModification(material, "P1/1/S1/1");
saveOneDependencyModification(material, "P1/2/S1/1");
saveOneDependencyModification(material, "P1/1/S2/1");
saveOneDependencyModification(material, "P2/1/S1/1");
StageIdentifier stageIdentifier = new StageIdentifier("P1", 2, "2", "S1", "1");
List<Modification> modifications = repo.modificationFor(stageIdentifier);
assertThat(modifications.size(), is(1));
assertThat(modifications.get(0).getRevision(), is("P1/2/S1/1"));
assertThat(goCache.get(repo.cacheKeyForModificationsForStageLocator(stageIdentifier)), is(modifications));
StageIdentifier p2_s1_stageId = new StageIdentifier("P2", 1, "S1", "1");
List<Modification> mod_p2_s1 = repo.modificationFor(p2_s1_stageId);
assertThat(goCache.get(repo.cacheKeyForModificationsForStageLocator(p2_s1_stageId)), is(mod_p2_s1));
StageIdentifier p2_s1_3 = new StageIdentifier("P2", 1, "S1", "3");
assertThat(repo.modificationFor(p2_s1_3).isEmpty(), is(true));
assertThat(goCache.get(repo.cacheKeyForModificationsForStageLocator(p2_s1_3)), is(nullValue()));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method hasPipelineEverRunWithMultipleMaterialsAndNewChanges.
@Test
public void hasPipelineEverRunWithMultipleMaterialsAndNewChanges() {
HgMaterial material = MaterialsMother.hgMaterial("hgUrl", "dest");
MaterialRevision hgMaterialRevision = saveOneScmModification(material, "user", "file");
DependencyMaterial depMaterial = new DependencyMaterial(new CaseInsensitiveString("blahPipeline"), new CaseInsensitiveString("blahStage"));
MaterialRevision depMaterialRevision = saveOneDependencyModification(depMaterial, "blahPipeline/1/blahStage/1");
PipelineConfig pipelineConfig = PipelineMother.createPipelineConfig("mingle", new MaterialConfigs(material.config(), depMaterial.config()), "dev");
MaterialRevisions revisions = new MaterialRevisions(hgMaterialRevision, depMaterialRevision);
pipelineSqlMapDao.save(instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(revisions, Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider()));
MaterialRevision laterRevision = saveOneScmModification(material, "user", "file");
MaterialRevisions newRevisions = new MaterialRevisions(depMaterialRevision, laterRevision);
assertThat(repo.hasPipelineEverRunWith("mingle", newRevisions), is(false));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method shouldReturnModificationForASpecificRevision.
@Test
public void shouldReturnModificationForASpecificRevision() throws Exception {
DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("blahPipeline"), new CaseInsensitiveString("blahStage"));
MaterialRevision originalRevision = saveOneDependencyModification(dependencyMaterial, "blahPipeline/3/blahStage/1");
Modification modification = repo.findModificationWithRevision(dependencyMaterial, "blahPipeline/3/blahStage/1");
assertThat(modification.getRevision(), is("blahPipeline/3/blahStage/1"));
assertEquals(originalRevision.getModification(0).getModifiedTime(), modification.getModifiedTime());
}
Aggregations