Search in sources :

Example 16 with StageHistoryEntry

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

the class StageServiceIntegrationTest method shouldGetStageHistoryForCurrentPage.

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

Example 17 with StageHistoryEntry

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

the class StageServiceIntegrationTest method createFiveStages.

private StageHistoryEntry[] createFiveStages() {
    Stage[] stages = new Stage[5];
    stages[0] = savedPipeline.getFirstStage();
    for (int i = 1; i < stages.length; i++) {
        DefaultSchedulingContext ctx = new DefaultSchedulingContext("anonumous");
        StageConfig stageCfg = pipelineConfig.first();
        stages[i] = i % 2 == 0 ? instanceFactory.createStageInstance(stageCfg, ctx, md5, new TimeProvider()) : instanceFactory.createStageForRerunOfJobs(stages[i - 1], a("unit", "blah"), ctx, stageCfg, new TimeProvider(), "md5");
        stageService.save(savedPipeline, stages[i]);
    }
    StageHistoryEntry[] entries = new StageHistoryEntry[5];
    for (int i = 0; i < stages.length; i++) {
        entries[i] = new StageHistoryEntry(stages[i], pipelineDao.loadHistory(savedPipeline.getId()).getNaturalOrder(), stages[i].getRerunOfCounter());
    }
    return entries;
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) StageHistoryEntry(com.thoughtworks.go.presentation.pipelinehistory.StageHistoryEntry)

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