use of com.thoughtworks.go.domain.feed.stage.StageFeedEntry in project gocd by gocd.
the class FeedEntriesRepresenterTest method shouldGenerateFeedXml.
@ParameterizedTest
@FileSource(files = "/feeds/stages-with-entries.xml")
void shouldGenerateFeedXml(String expectedXML) {
String pipelineName = "up42";
StageFeedEntry entryOne = cancelled();
StageFeedEntry entryTwo = passed();
entryOne.getAuthors().add(new Author("bob", "bob@gocd.org"));
entryTwo.getAuthors().add(new Author("joe <joe@gocd.org>", null));
XmlWriterContext context = new XmlWriterContext("https://go-server/go", null, null, null, new SystemEnvironment());
FeedEntriesRepresenter representable = new FeedEntriesRepresenter(pipelineName, new FeedEntries(entryOne, entryTwo));
Document document = representable.toXml(context);
XmlAssert.assertThat(document.asXML()).and(expectedXML).ignoreWhitespace().areIdentical();
}
use of com.thoughtworks.go.domain.feed.stage.StageFeedEntry in project gocd by gocd.
the class StageServiceTest method shouldReturnFeedsEvenIfUpstreamPipelineIsDeleted.
@Test
public void shouldReturnFeedsEvenIfUpstreamPipelineIsDeleted() {
Date updateDate = new Date();
CruiseConfig config = mock(BasicCruiseConfig.class);
PipelineConfig pipelineConfig = PipelineConfigMother.pipelineConfig("down");
Map<Long, List<ModificationForPipeline>> expectedModMapDown = new HashMap<>();
Modification mod1 = checkinWithComment("revision", "#123 hello wolrd", updateDate);
expectedModMapDown.put(1L, asList(new ModificationForPipeline(new PipelineId("down", 1L), mod1, "Svn", "fooBarBaaz")));
FeedEntry expected = stageFeedEntry("down", updateDate);
when(stageDao.findCompletedStagesFor("down", FeedModifier.Latest, -1, 25)).thenReturn(asList(stageFeedEntry("down", updateDate), stageFeedEntry("down", updateDate)));
when(goConfigService.currentCruiseConfig()).thenReturn(config);
when(changesetService.modificationsOfPipelines(asList(1L, 1L), "down", Username.ANONYMOUS)).thenReturn(expectedModMapDown);
when(config.hasPipelineNamed(any(CaseInsensitiveString.class))).thenReturn(false).thenReturn(true);
when(config.pipelineConfigByName(any(CaseInsensitiveString.class))).thenReturn(pipelineConfig);
StageService service = new StageService(stageDao, null, null, null, null, null, changesetService, goConfigService, transactionTemplate, transactionSynchronizationManager, new StubGoCache(transactionSynchronizationManager));
FeedEntries feedEntries = service.feed("down", Username.ANONYMOUS);
assertThat(feedEntries).isEqualTo(new FeedEntries(asList(expected, expected)));
assertThat(feedEntries.get(0).getAuthors()).isEqualTo(asList(new Author(MOD_USER_COMMITTER, EMAIL_ADDRESS)));
assertThat(feedEntries.get(1).getAuthors()).isEqualTo(asList(new Author(MOD_USER_COMMITTER, EMAIL_ADDRESS)));
}
use of com.thoughtworks.go.domain.feed.stage.StageFeedEntry in project gocd by gocd.
the class StageSqlMapDaoIntegrationTest method findCompletedStagesFor_shouldInvalidateCacheOnCompletionOfAStageForTheGivenPipeline.
@Test
public void findCompletedStagesFor_shouldInvalidateCacheOnCompletionOfAStageForTheGivenPipeline() {
SqlMapClientTemplate mockTemplate = mock(SqlMapClientTemplate.class);
stageDao.setSqlMapClientTemplate(mockTemplate);
List<StageFeedEntry> entries = asList(new StageFeedEntry(1L, 1L, null, 1L, null, null));
when(mockTemplate.queryForList(eq("allCompletedStagesForPipeline"), any())).thenReturn((List) entries);
stageDao.findCompletedStagesFor("cruise", FeedModifier.Latest, 10, 100);
updateResultInTransaction(StageMother.completedFailedStageInstance("cruise", "stage", "job"), StageResult.Failed);
List<FeedEntry> actual = new ArrayList<>(stageDao.findCompletedStagesFor("cruise", FeedModifier.Latest, 10, 100));
assertThat(actual).isEqualTo(entries);
verify(mockTemplate, times(2)).queryForList(eq("allCompletedStagesForPipeline"), any());
}
use of com.thoughtworks.go.domain.feed.stage.StageFeedEntry in project gocd by gocd.
the class StageSqlMapDaoIntegrationTest method shouldLoadApproverAndUnderstandIfBuildWasForced.
@Test
public void shouldLoadApproverAndUnderstandIfBuildWasForced() throws SQLException {
mingleConfig.get(0).updateApproval(Approval.manualApproval());
Pipeline cancelled = dbHelper.schedulePipeline(mingleConfig, ModificationsMother.modifySomeFiles(mingleConfig), "loser", new TimeProvider());
dbHelper.cancelStage(pipelineAndFirstStageOf(cancelled).stage);
mingleConfig.get(0).updateApproval(Approval.automaticApproval());
Pipeline passed = dbHelper.schedulePipeline(mingleConfig, ModificationsMother.modifySomeFiles(mingleConfig), "boozer", new TimeProvider());
dbHelper.passStage(pipelineAndFirstStageOf(passed).stage);
Pipeline failed = dbHelper.schedulePipeline(mingleConfig, new TimeProvider());
dbHelper.failStage(pipelineAndFirstStageOf(failed).stage);
List<StageFeedEntry> completedStages = stageDao.findCompletedStagesFor(mingleConfig.name().toString(), FeedModifier.Before, transitionId(pipelineAndFirstStageOf(failed).stage), 2);
assertThat(completedStages.get(0).isManuallyTriggered()).isFalse();
assertThat(completedStages.get(0).getApprovedBy()).isEqualTo("boozer");
assertThat(completedStages.get(1).isManuallyTriggered()).isTrue();
assertThat(completedStages.get(1).getApprovedBy()).isEqualTo("loser");
}
Aggregations