use of org.springframework.orm.ibatis.SqlMapClientTemplate in project gocd by gocd.
the class StageSqlMapDaoIntegrationTest method getTotalStageCountForChart_shouldCacheTheCount.
@Test
public void getTotalStageCountForChart_shouldCacheTheCount() throws SQLException {
SqlMapClientTemplate mockClient = mock(SqlMapClientTemplate.class);
stageDao.setSqlMapClientTemplate(mockClient);
Map<String, Object> toGet = arguments("pipelineName", "maar").and("stageName", "khoon").asMap();
when(mockClient.queryForObject("getTotalStageCountForChart", toGet)).thenReturn(3);
// Should prime the cache
assertThat(stageDao.getTotalStageCountForChart("maar", "khoon"), is(3));
// should use the cache
assertThat(stageDao.getTotalStageCountForChart("maar", "khoon"), is(3));
verify(mockClient).queryForObject("getTotalStageCountForChart", toGet);
verifyNoMoreInteractions(mockClient);
}
Aggregations