use of com.thoughtworks.go.server.transaction.SqlMapClientTemplate 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");
}
Aggregations