Search in sources :

Example 36 with SqlMapClientTemplate

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);
}
Also used : SqlMapClientTemplate(org.springframework.orm.ibatis.SqlMapClientTemplate) Test(org.junit.Test)

Aggregations

SqlMapClientTemplate (org.springframework.orm.ibatis.SqlMapClientTemplate)36 Test (org.junit.Test)35 PluginTestVerifier (com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier)8 Method (java.lang.reflect.Method)8 PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)2 StageHistoryEntry (com.thoughtworks.go.presentation.pipelinehistory.StageHistoryEntry)2 StageHistoryPage (com.thoughtworks.go.presentation.pipelinehistory.StageHistoryPage)2 TransactionManager (com.ibatis.sqlmap.engine.transaction.TransactionManager)1 Cache (com.opensymphony.oscache.base.Cache)1 Cloner (com.rits.cloning.Cloner)1 FeedEntry (com.thoughtworks.go.domain.feed.FeedEntry)1 StageFeedEntry (com.thoughtworks.go.domain.feed.stage.StageFeedEntry)1 GoCache (com.thoughtworks.go.server.cache.GoCache)1 StubGoCache (com.thoughtworks.go.server.service.StubGoCache)1 TestTransactionSynchronizationManager (com.thoughtworks.go.server.transaction.TestTransactionSynchronizationManager)1 Before (org.junit.Before)1 Matchers.anyObject (org.mockito.Matchers.anyObject)1 Mockito.doAnswer (org.mockito.Mockito.doAnswer)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 Answer (org.mockito.stubbing.Answer)1