Search in sources :

Example 1 with FuncVarArg

use of com.thoughtworks.go.util.FuncVarArg in project gocd by gocd.

the class StageSqlMapDaoTest method shouldLoadStageHistoryEntryForAStageRunAfterTheLatestRunThatIsRetrievedForStageHistory.

@Test
public void shouldLoadStageHistoryEntryForAStageRunAfterTheLatestRunThatIsRetrievedForStageHistory() throws Exception {
    String pipelineName = "some_pipeline_name";
    String stageName = "some_stage_name";
    FuncVarArg function = mock(FuncVarArg.class);
    Pagination pagination = mock(Pagination.class);
    when(pagination.getCurrentPage()).thenReturn(3);
    when(pagination.getPageSize()).thenReturn(10);
    when(function.call()).thenReturn(pagination);
    StageSqlMapDao spy = spy(stageSqlMapDao);
    List<StageHistoryEntry> expectedStageHistoryEntriesList = mock(ArrayList.class);
    StageHistoryEntry topOfThisPage = mock(StageHistoryEntry.class);
    when(expectedStageHistoryEntriesList.get(0)).thenReturn(topOfThisPage);
    StageHistoryEntry bottomOfLastPage = mock(StageHistoryEntry.class);
    doReturn(expectedStageHistoryEntriesList).when(spy).findStages(pagination, pipelineName, stageName);
    doReturn(bottomOfLastPage).when(spy).findImmediateChronologicallyForwardStageHistoryEntry(topOfThisPage);
    StageHistoryPage stageHistoryPage = spy.findStageHistoryPage(pipelineName, stageName, function);
    assertThat(stageHistoryPage.getStages(), is(expectedStageHistoryEntriesList));
    assertThat(stageHistoryPage.getImmediateChronologicallyForwardStageHistoryEntry(), is(bottomOfLastPage));
    verify(spy, times(1)).findStages(pagination, pipelineName, stageName);
    verify(spy, times(1)).findImmediateChronologicallyForwardStageHistoryEntry(expectedStageHistoryEntriesList.get(0));
}
Also used : FuncVarArg(com.thoughtworks.go.util.FuncVarArg) Pagination(com.thoughtworks.go.server.util.Pagination) StageHistoryPage(com.thoughtworks.go.presentation.pipelinehistory.StageHistoryPage) StageHistoryEntry(com.thoughtworks.go.presentation.pipelinehistory.StageHistoryEntry) Test(org.junit.Test)

Aggregations

StageHistoryEntry (com.thoughtworks.go.presentation.pipelinehistory.StageHistoryEntry)1 StageHistoryPage (com.thoughtworks.go.presentation.pipelinehistory.StageHistoryPage)1 Pagination (com.thoughtworks.go.server.util.Pagination)1 FuncVarArg (com.thoughtworks.go.util.FuncVarArg)1 Test (org.junit.Test)1