use of com.thoughtworks.go.server.domain.StageIdentity in project gocd by gocd.
the class CcTrayStageStatusLoaderTest method setupStagesInDB.
private List<Stage> setupStagesInDB(StageIdentity... stageIdentities) {
when(stageDao.findLatestStageInstances()).thenReturn(asList(stageIdentities));
List<Stage> stages = new ArrayList<>();
for (StageIdentity identity : stageIdentities) {
Stage stage = StageMother.custom(identity.getPipelineName() + " - " + identity.getStageName());
lenient().when(stageDao.stageById(identity.getStageId())).thenReturn(stage);
stages.add(stage);
}
return stages;
}
use of com.thoughtworks.go.server.domain.StageIdentity in project gocd by gocd.
the class CcTrayStageStatusLoaderTest method shouldConvertToStatusesIfAStageIsFoundInDB.
@Test
public void shouldConvertToStatusesIfAStageIsFoundInDB() throws Exception {
List<ProjectStatus> expectedStatuses = asList(new ProjectStatus("pipeline1 :: stage1", "Sleeping", "some-status", "some-label", new Date(), "some-url"));
List<Stage> stages = setupStagesInDB(new StageIdentity("pipeline1", "stage1", 12L), new StageIdentity("pipeline2", "stage2", 14L));
when(stageChangeHandler.statusesOfStageAndItsJobsFor(stages.get(0))).thenReturn(expectedStatuses);
List<ProjectStatus> actualStatuses = loader.getStatusesForStageAndJobsOf(pipelineConfigFor("pipeline1"), stageConfigFor("stage1"));
assertThat(actualStatuses, is(expectedStatuses));
}
use of com.thoughtworks.go.server.domain.StageIdentity in project gocd by gocd.
the class CcTrayStageStatusLoaderTest method shouldNotHaveAnyStatusesIfAStageCannotBeFoundInDB.
@Test
public void shouldNotHaveAnyStatusesIfAStageCannotBeFoundInDB() throws Exception {
setupStagesInDB(new StageIdentity("pipeline1", "stage1", 12L), new StageIdentity("pipeline2", "stage2", 14L));
List<ProjectStatus> actualStatuses = loader.getStatusesForStageAndJobsOf(pipelineConfigFor("pipeline1"), stageConfigFor("non-existent-stage"));
assertThat(actualStatuses, is(Collections.<ProjectStatus>emptyList()));
}
use of com.thoughtworks.go.server.domain.StageIdentity in project gocd by gocd.
the class CcTrayStageStatusLoaderTest method shouldCacheResultOfLatestStageInstancesOnce.
@Test
public void shouldCacheResultOfLatestStageInstancesOnce() throws Exception {
setupStagesInDB(new StageIdentity("pipeline1", "stage1", 12L), new StageIdentity("pipeline2", "stage2", 14L));
loader.getStatusesForStageAndJobsOf(pipelineConfigFor("pipeline1"), stageConfigFor("stage1"));
loader.getStatusesForStageAndJobsOf(pipelineConfigFor("pipeline1"), stageConfigFor("stage2"));
loader.getStatusesForStageAndJobsOf(pipelineConfigFor("pipeline1"), stageConfigFor("stage-some-nonexistent-one"));
verify(stageDao, times(1)).findLatestStageInstances();
}
use of com.thoughtworks.go.server.domain.StageIdentity in project gocd by gocd.
the class StageSqlMapDao method findLatestStageInstances.
@Override
public List<StageIdentity> findLatestStageInstances() {
String key = cacheKeyForLatestStageInstances();
List<StageIdentity> stageIdentities = (List<StageIdentity>) goCache.get(key);
if (stageIdentities == null) {
synchronized (key) {
stageIdentities = (List<StageIdentity>) goCache.get(key);
if (stageIdentities == null) {
stageIdentities = (List<StageIdentity>) getSqlMapClientTemplate().queryForList("latestStageInstances");
goCache.put(key, stageIdentities);
}
}
}
return stageIdentities;
}
Aggregations