use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.
the class MaterialDatabaseDependencyUpdaterTest method shouldReturnLatestPipelineIfThereHasBeenANewOne.
@Test
public void shouldReturnLatestPipelineIfThereHasBeenANewOne() 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(null, 9, stages(10));
updater.updateMaterial(dependencyMaterial);
List<Modification> newModifications = materialRepository.findModificationsSince(dependencyMaterial, new MaterialRevision(dependencyMaterial, modification));
assertThat(newModifications.size(), is(1));
assertThat(newModifications.get(0).getRevision(), is("pipeline-name/10/stage-name/0"));
assertThat(newModifications.get(0).getPipelineLabel(), is("LABEL-10"));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.
the class MaterialDatabaseDependencyUpdaterTest method shouldClearServerHealthIfCheckSucceeds.
@Test
public void shouldClearServerHealthIfCheckSucceeds() throws Exception {
DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
Mockito.when(dependencyMaterialSourceDao.getPassedStagesByName(new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name")), Pagination.pageStartingAt(0, null, MaterialDatabaseUpdater.STAGES_PER_PAGE))).thenReturn(new ArrayList<>());
updater.updateMaterial(dependencyMaterial);
Mockito.verify(healthService).removeByScope(HealthStateScope.forMaterial(dependencyMaterial));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.
the class MaterialDatabaseDependencyUpdaterTest method shouldUpdateMaterialCorrectlyIfCaseOfPipelineNameIsDifferentInConfigurationOfDependencyMaterial.
@Test
public void shouldUpdateMaterialCorrectlyIfCaseOfPipelineNameIsDifferentInConfigurationOfDependencyMaterial() throws Exception {
DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("PIPEline-name"), new CaseInsensitiveString("STAge-name"));
stubStageServiceGetHistory(dependencyMaterial, stages(1));
// create the material instance
updater.updateMaterial(dependencyMaterial);
stubStageServiceGetHistoryAfter(dependencyMaterial, 1, stages(2));
// update first time & should mark cache as updated
updater.updateMaterial(dependencyMaterial);
Stage stage = stage(3);
ReflectionUtil.setField(stage, "result", StageResult.Passed);
// update subsequently should hit database
updater.updateMaterial(dependencyMaterial);
Mockito.verify(dependencyMaterialSourceDao, times(2)).getPassedStagesAfter(any(String.class), any(DependencyMaterial.class), any(Pagination.class));
Mockito.verify(dependencyMaterialSourceDao, times(2)).getPassedStagesByName(any(DependencyMaterial.class), any(Pagination.class));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.
the class MaterialDatabaseDependencyUpdaterTest method shouldInsertAllHistoricRunsOfUpstreamStageTheFirstTime.
@Test
public void shouldInsertAllHistoricRunsOfUpstreamStageTheFirstTime() throws Exception {
DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
stubStageServiceGetHistory(null, stages(9, 10, 11), stages(12, 13));
updater.updateMaterial(dependencyMaterial);
for (Integer revision : new int[] { 9, 10, 11, 12, 13 }) {
String stageLocator = String.format("pipeline-name/%s/stage-name/0", revision);
Modification modification = materialRepository.findModificationWithRevision(dependencyMaterial, stageLocator);
assertThat(modification.getRevision(), is(stageLocator));
assertThat(modification.getPipelineLabel(), is(String.format("LABEL-%s", revision)));
}
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method shouldPersistActualFromRevisionForSameRevisionOfDependencyMaterialModifications.
@Test
public void shouldPersistActualFromRevisionForSameRevisionOfDependencyMaterialModifications() throws Exception {
Material material = new DependencyMaterial(new CaseInsensitiveString("pipeline_name"), new CaseInsensitiveString("stage_name"));
Modification actualFrom = modification("pipeline_name/8/stage_name/2");
MaterialRevision firstRevision = new MaterialRevision(material, new Modifications(actualFrom));
saveMaterialRev(firstRevision);
Pipeline firstPipeline = createPipeline();
savePMR(firstRevision, firstPipeline);
firstPipeline = createPipeline();
savePMR(firstRevision, firstPipeline);
List<PipelineMaterialRevision> pmrs = repo.findPipelineMaterialRevisions(firstPipeline.getId());
assertThat(pmrs.get(0).getActualFromRevisionId(), is(actualFrom.getId()));
assertEquals(actualFrom, pmrs.get(0).getFromModification());
}
Aggregations