Search in sources :

Example 26 with SqlMapClientTemplate

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");
}
Also used : StageHistoryPage(com.thoughtworks.go.presentation.pipelinehistory.StageHistoryPage) SqlMapClientTemplate(com.thoughtworks.go.server.transaction.SqlMapClientTemplate) StageHistoryEntry(com.thoughtworks.go.presentation.pipelinehistory.StageHistoryEntry) Test(org.junit.jupiter.api.Test)

Aggregations

SqlMapClientTemplate (com.thoughtworks.go.server.transaction.SqlMapClientTemplate)26 Test (org.junit.jupiter.api.Test)25 StageHistoryEntry (com.thoughtworks.go.presentation.pipelinehistory.StageHistoryEntry)2 StageHistoryPage (com.thoughtworks.go.presentation.pipelinehistory.StageHistoryPage)2 TimeProvider (com.thoughtworks.go.util.TimeProvider)2 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 BeforeEach (org.junit.jupiter.api.BeforeEach)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 Answer (org.mockito.stubbing.Answer)1