Search in sources :

Example 11 with StageHistoryEntry

use of com.thoughtworks.go.presentation.pipelinehistory.StageHistoryEntry 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)

Example 12 with StageHistoryEntry

use of com.thoughtworks.go.presentation.pipelinehistory.StageHistoryEntry in project gocd by gocd.

the class StageServiceIntegrationTest method shouldReturnTheLatestAndOldestStageInstanceId.

@Test
public void shouldReturnTheLatestAndOldestStageInstanceId() {
    StageHistoryEntry[] stages = createFiveStages();
    PipelineRunIdInfo oldestAndLatestPipelineId = stageService.getOldestAndLatestStageInstanceId(new Username(new CaseInsensitiveString("admin1")), savedPipeline.getName(), savedPipeline.getFirstStage().getName());
    assertThat(oldestAndLatestPipelineId.getLatestRunId(), is(stages[4].getId()));
    assertThat(oldestAndLatestPipelineId.getOldestRunId(), is(stages[0].getId()));
}
Also used : Username(com.thoughtworks.go.server.domain.Username) StageHistoryEntry(com.thoughtworks.go.presentation.pipelinehistory.StageHistoryEntry) Test(org.junit.jupiter.api.Test)

Example 13 with StageHistoryEntry

use of com.thoughtworks.go.presentation.pipelinehistory.StageHistoryEntry in project gocd by gocd.

the class StageServiceIntegrationTest method shouldReturnThePipelineHistoryBeforeTheSpecifiedCursor.

@Test
public void shouldReturnThePipelineHistoryBeforeTheSpecifiedCursor() {
    StageHistoryEntry[] stages = createFiveStages();
    StageInstanceModels history = stageService.findStageHistoryViaCursor(new Username(new CaseInsensitiveString("admin1")), savedPipeline.getName(), savedPipeline.getFirstStage().getName(), 0, stages[2].getId(), 10);
    assertThat(history.size(), is(2));
    assertThat(history.get(0).getId(), is(stages[4].getId()));
    assertThat(history.get(1).getId(), is(stages[3].getId()));
}
Also used : Username(com.thoughtworks.go.server.domain.Username) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) StageHistoryEntry(com.thoughtworks.go.presentation.pipelinehistory.StageHistoryEntry) Test(org.junit.jupiter.api.Test)

Example 14 with StageHistoryEntry

use of com.thoughtworks.go.presentation.pipelinehistory.StageHistoryEntry in project gocd by gocd.

the class StageServiceIntegrationTest method shouldGetStageHistoryByPageNumber.

@Test
public void shouldGetStageHistoryByPageNumber() throws Exception {
    StageHistoryEntry[] stages = createFiveStages();
    StageHistoryPage history = stageService.findStageHistoryPageByNumber(PIPELINE_NAME, STAGE_NAME, 2, 3);
    assertThat("Found " + history, history.getPagination(), is(Pagination.pageStartingAt(3, 5, 3)));
    assertThat("Found " + history, history.getStages().size(), is(2));
    assertThat("Found " + history, history.getStages().get(0), is(stages[1]));
    assertThat("Found " + history, history.getStages().get(1), is(stages[0]));
}
Also used : StageHistoryPage(com.thoughtworks.go.presentation.pipelinehistory.StageHistoryPage) StageHistoryEntry(com.thoughtworks.go.presentation.pipelinehistory.StageHistoryEntry) Test(org.junit.jupiter.api.Test)

Example 15 with StageHistoryEntry

use of com.thoughtworks.go.presentation.pipelinehistory.StageHistoryEntry in project gocd by gocd.

the class StageServiceIntegrationTest method shouldReturnThePipelineHistoryAfterTheSpecifiedCursor.

@Test
public void shouldReturnThePipelineHistoryAfterTheSpecifiedCursor() {
    StageHistoryEntry[] stages = createFiveStages();
    StageInstanceModels history = stageService.findStageHistoryViaCursor(new Username(new CaseInsensitiveString("admin1")), savedPipeline.getName(), savedPipeline.getFirstStage().getName(), stages[2].getId(), 0, 10);
    assertThat(history.size(), is(2));
    assertThat(history.get(0).getId(), is(stages[1].getId()));
    assertThat(history.get(1).getId(), is(stages[0].getId()));
}
Also used : Username(com.thoughtworks.go.server.domain.Username) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) StageHistoryEntry(com.thoughtworks.go.presentation.pipelinehistory.StageHistoryEntry) Test(org.junit.jupiter.api.Test)

Aggregations

StageHistoryEntry (com.thoughtworks.go.presentation.pipelinehistory.StageHistoryEntry)17 Test (org.junit.jupiter.api.Test)14 StageHistoryPage (com.thoughtworks.go.presentation.pipelinehistory.StageHistoryPage)11 Pagination (com.thoughtworks.go.server.util.Pagination)6 Username (com.thoughtworks.go.server.domain.Username)4 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)3 StageInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels)3 ScheduleTestUtil (com.thoughtworks.go.server.service.ScheduleTestUtil)3 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)2 SqlMapClientTemplate (com.thoughtworks.go.server.transaction.SqlMapClientTemplate)2 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)1 TimeProvider (com.thoughtworks.go.util.TimeProvider)1 HashMap (java.util.HashMap)1 Supplier (java.util.function.Supplier)1