use of com.thoughtworks.go.presentation.pipelinehistory.StageHistoryEntry in project gocd by gocd.
the class StageSqlMapDaoIntegrationTest method findStageHistoryPage_shouldReturnStageHistoryEntryWithConfigVersion.
@Test
public void findStageHistoryPage_shouldReturnStageHistoryEntryWithConfigVersion() {
SqlMapClientTemplate mockTemplate = mock(SqlMapClientTemplate.class);
Stage stage = StageMother.passedStageInstance("dev", "java", "pipeline-name");
stage.setApprovedBy("admin");
stage.setConfigVersion("md5-test");
stageDao.setSqlMapClientTemplate(mockTemplate);
when(mockTemplate.queryForObject(eq("getStageHistoryCount"), any())).thenReturn(20);
when(mockTemplate.queryForObject(eq("findOffsetForStage"), any())).thenReturn(10);
List<StageHistoryEntry> stageList = asList(new StageHistoryEntry(stage, 1, 10));
when(mockTemplate.queryForList(eq("findStageHistoryPage"), any())).thenReturn((List) stageList);
StageHistoryPage stageHistoryPage = stageDao.findStageHistoryPage(stage, 10);
assertThat(stageHistoryPage.getStages().get(0).getConfigVersion()).isEqualTo("md5-test");
}
use of com.thoughtworks.go.presentation.pipelinehistory.StageHistoryEntry in project gocd by gocd.
the class StageServiceIntegrationTest method shouldReturnTheLatestAndOldestStageInstanceId.
@Test
public void shouldReturnTheLatestAndOldestStageInstanceId() {
StageHistoryEntry[] stages = createFiveStages();
PipelineRunIdInfo oldestAndLatestPipelineId = stageService.getOldestAndLatestStageInstanceId(new Username(new CaseInsensitiveString("admin1")), savedPipeline.getName(), savedPipeline.getFirstStage().getName());
assertThat(oldestAndLatestPipelineId.getLatestRunId(), is(stages[4].getId()));
assertThat(oldestAndLatestPipelineId.getOldestRunId(), is(stages[0].getId()));
}
use of com.thoughtworks.go.presentation.pipelinehistory.StageHistoryEntry in project gocd by gocd.
the class StageServiceIntegrationTest method shouldReturnThePipelineHistoryBeforeTheSpecifiedCursor.
@Test
public void shouldReturnThePipelineHistoryBeforeTheSpecifiedCursor() {
StageHistoryEntry[] stages = createFiveStages();
StageInstanceModels history = stageService.findStageHistoryViaCursor(new Username(new CaseInsensitiveString("admin1")), savedPipeline.getName(), savedPipeline.getFirstStage().getName(), 0, stages[2].getId(), 10);
assertThat(history.size(), is(2));
assertThat(history.get(0).getId(), is(stages[4].getId()));
assertThat(history.get(1).getId(), is(stages[3].getId()));
}
use of com.thoughtworks.go.presentation.pipelinehistory.StageHistoryEntry in project gocd by gocd.
the class StageServiceIntegrationTest method shouldGetStageHistoryByPageNumber.
@Test
public void shouldGetStageHistoryByPageNumber() throws Exception {
StageHistoryEntry[] stages = createFiveStages();
StageHistoryPage history = stageService.findStageHistoryPageByNumber(PIPELINE_NAME, STAGE_NAME, 2, 3);
assertThat("Found " + history, history.getPagination(), is(Pagination.pageStartingAt(3, 5, 3)));
assertThat("Found " + history, history.getStages().size(), is(2));
assertThat("Found " + history, history.getStages().get(0), is(stages[1]));
assertThat("Found " + history, history.getStages().get(1), is(stages[0]));
}
use of com.thoughtworks.go.presentation.pipelinehistory.StageHistoryEntry in project gocd by gocd.
the class StageServiceIntegrationTest method shouldReturnThePipelineHistoryAfterTheSpecifiedCursor.
@Test
public void shouldReturnThePipelineHistoryAfterTheSpecifiedCursor() {
StageHistoryEntry[] stages = createFiveStages();
StageInstanceModels history = stageService.findStageHistoryViaCursor(new Username(new CaseInsensitiveString("admin1")), savedPipeline.getName(), savedPipeline.getFirstStage().getName(), stages[2].getId(), 0, 10);
assertThat(history.size(), is(2));
assertThat(history.get(0).getId(), is(stages[1].getId()));
assertThat(history.get(1).getId(), is(stages[0].getId()));
}
Aggregations