Search in sources :

Example 1 with StageAtomFeedsReader

use of com.thoughtworks.studios.shine.cruise.stage.feeds.StageAtomFeedsReader in project gocd by gocd.

the class StageAtomFeedsReaderTest method checkWeFollowPagingUntilWeHitADuplicate.

@Test
public void checkWeFollowPagingUntilWeHitADuplicate() throws Exception {
    StageFeedEntry entry1 = feedEntry(1);
    StageFeedEntry entry2 = feedEntry(2);
    StageFeedEntry entry3 = feedEntry(3);
    StageFeedEntry entry4 = feedEntry(4);
    when(stageDao.findAllCompletedStages(FeedModifier.Latest, -1, StageAtomFeedsReader.PAGE_SIZE)).thenReturn(Arrays.asList(entry4));
    when(stageDao.findAllCompletedStages(FeedModifier.Before, 4, StageAtomFeedsReader.PAGE_SIZE)).thenReturn(Arrays.asList(entry3, entry2, entry1));
    stageFeedHandler.previousHandled(entry1);
    stageFeedHandler.previousHandled(entry2);
    new StageAtomFeedsReader(stageDao).readFromLatest(stageFeedHandler, pipelineInstanceLoader);
    List<StageFeedEntry> list = stageFeedHandler.handledFeeds();
    assertEquals(2, list.size());
    assertEquals(4, list.get(0).getId());
    assertEquals(3, list.get(1).getId());
}
Also used : StageAtomFeedsReader(com.thoughtworks.studios.shine.cruise.stage.feeds.StageAtomFeedsReader) StageFeedEntry(com.thoughtworks.go.domain.feed.stage.StageFeedEntry) Test(org.junit.Test)

Example 2 with StageAtomFeedsReader

use of com.thoughtworks.studios.shine.cruise.stage.feeds.StageAtomFeedsReader in project gocd by gocd.

the class StageAtomFeedsReaderTest method canGetAllStageUrlsInAStagesFeed.

@Test
public void canGetAllStageUrlsInAStagesFeed() throws Exception {
    when(stageDao.findAllCompletedStages(FeedModifier.Latest, -1, StageAtomFeedsReader.PAGE_SIZE)).thenReturn(Arrays.asList(feedEntry(2), feedEntry(1)));
    new StageAtomFeedsReader(stageDao).readFromLatest(stageFeedHandler, pipelineInstanceLoader);
    List<StageFeedEntry> list = stageFeedHandler.handledFeeds();
    assertEquals(2, list.size());
    assertEquals(2, list.get(0).getId());
    assertEquals(1, list.get(1).getId());
}
Also used : StageAtomFeedsReader(com.thoughtworks.studios.shine.cruise.stage.feeds.StageAtomFeedsReader) StageFeedEntry(com.thoughtworks.go.domain.feed.stage.StageFeedEntry) Test(org.junit.Test)

Example 3 with StageAtomFeedsReader

use of com.thoughtworks.studios.shine.cruise.stage.feeds.StageAtomFeedsReader in project gocd by gocd.

the class StageAtomFeedsReaderTest method canPaginateToGetStages.

@Test
public void canPaginateToGetStages() throws Exception {
    when(stageDao.findAllCompletedStages(FeedModifier.Latest, -1, StageAtomFeedsReader.PAGE_SIZE)).thenReturn(Arrays.asList(feedEntry(4), feedEntry(3)));
    when(stageDao.findAllCompletedStages(FeedModifier.Before, 3, StageAtomFeedsReader.PAGE_SIZE)).thenReturn(Arrays.asList(feedEntry(2), feedEntry(1)));
    new StageAtomFeedsReader(stageDao).readFromLatest(stageFeedHandler, pipelineInstanceLoader);
    List<StageFeedEntry> list = stageFeedHandler.handledFeeds();
    assertEquals(4, list.size());
    assertEquals(4, list.get(0).getId());
    assertEquals(3, list.get(1).getId());
    assertEquals(2, list.get(2).getId());
    assertEquals(1, list.get(3).getId());
}
Also used : StageAtomFeedsReader(com.thoughtworks.studios.shine.cruise.stage.feeds.StageAtomFeedsReader) StageFeedEntry(com.thoughtworks.go.domain.feed.stage.StageFeedEntry) Test(org.junit.Test)

Aggregations

StageFeedEntry (com.thoughtworks.go.domain.feed.stage.StageFeedEntry)3 StageAtomFeedsReader (com.thoughtworks.studios.shine.cruise.stage.feeds.StageAtomFeedsReader)3 Test (org.junit.Test)3