use of com.thoughtworks.go.domain.feed.FeedEntries in project gocd by gocd.
the class StageServiceIntegrationTest method shouldLoadStageAuthors_forSubsequentPages.
@Test
public void shouldLoadStageAuthors_forSubsequentPages() throws Exception {
PipelineConfig downstream = setup2DependentInstances();
FeedEntries feed = stageService.feedBefore(Integer.MAX_VALUE, downstream.name().toString(), new Username(new CaseInsensitiveString("loser")));
assertStageEntryAuthor(feed);
}
use of com.thoughtworks.go.domain.feed.FeedEntries in project gocd by gocd.
the class StageServiceIntegrationTest method shouldNotLoadStageAuthorsAndMingleCards_fromUpstreamInvisibleToUser.
@Test
public void shouldNotLoadStageAuthorsAndMingleCards_fromUpstreamInvisibleToUser() throws Exception {
MingleConfig upstreamMingle = new MingleConfig("https://mingle.gingle/when/single", "jingle");
MingleConfig downstreamMingle = new MingleConfig("https://downstream-mingle", "go");
PipelineConfig downstream = setup2DependentInstances(upstreamMingle, downstreamMingle);
configFileHelper.enableSecurity();
configFileHelper.addAdmins("super-hero");
configFileHelper.addAuthorizedUserForPipelineGroup("loser", "upstream-without-mingle");
configFileHelper.addAuthorizedUserForPipelineGroup("loser", "downstream");
configFileHelper.addAuthorizedUserForPipelineGroup("boozer", "upstream-with-mingle");
FeedEntries feed = stageService.feed(downstream.name().toString(), new Username(new CaseInsensitiveString("loser")));
assertAuthorsAndCardsOnEntry((StageFeedEntry) feed.get(0), Arrays.asList(new Author("svn 3 guy", "svn.3@gmail.com"), new Author("p4 2 guy", "p4.2@gmail.com")), Arrays.asList(new MingleCard(downstreamMingle, "103")));
assertAuthorsAndCardsOnEntry((StageFeedEntry) feed.get(1), Arrays.asList(new Author("svn 1 guy", "svn.1@gmail.com"), new Author("svn 2 guy", "svn.2@gmail.com"), new Author("p4 1 guy", "p4.1@gmail.com")), Arrays.asList(new MingleCard(downstreamMingle, "101"), new MingleCard(downstreamMingle, "102")));
}
use of com.thoughtworks.go.domain.feed.FeedEntries in project gocd by gocd.
the class StageServiceTest method findCompletedStagesFor_shouldCacheTheResultPerPipeline.
@Test
public void findCompletedStagesFor_shouldCacheTheResultPerPipeline() {
Date updateDate = new Date();
when(stageDao.findCompletedStagesFor("cruise", FeedModifier.Latest, -1, 25)).thenReturn(asList(stageFeedEntry("cruise", updateDate))).thenReturn(asList(stageFeedEntry("cruise", updateDate)));
MingleConfig mingleConfig = new MingleConfig("http://foo.bar:7019/baz/", "go-project");
when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfigWithMingle("cruise", mingleConfig));
Map<Long, List<ModificationForPipeline>> expectedMap = new HashMap<>();
expectedMap.put(1L, asList(new ModificationForPipeline(new PipelineId("cruise", 1L), ModificationsMother.checkinWithComment("revision", "#123 hello wolrd", updateDate), "Svn", "fooBarBaaz")));
when(changesetService.modificationsOfPipelines(asList(1L), "cruise", Username.ANONYMOUS)).thenReturn(expectedMap);
StageService service = new StageService(stageDao, null, null, null, null, null, changesetService, goConfigService, transactionTemplate, transactionSynchronizationManager, new StubGoCache(transactionSynchronizationManager));
FeedEntry expected = stageFeedEntry("cruise", updateDate);
// Should prime the cache
FeedEntries feedEntries = service.feed("cruise", Username.ANONYMOUS);
assertThat(feedEntries, is(new FeedEntries(asList(expected))));
assertThat(feedEntries.get(0).getAuthors(), is(asList(new Author(ModificationsMother.MOD_USER_COMMITTER, ModificationsMother.EMAIL_ADDRESS))));
assertThat(feedEntries.get(0).getMingleCards(), is(asList(new MingleCard(mingleConfig, "123"))));
// Should use the cache
feedEntries = service.feed("cruise", Username.ANONYMOUS);
assertThat(feedEntries, is(new FeedEntries(asList(expected))));
assertThat(feedEntries.get(0).getAuthors(), is(asList(new Author(ModificationsMother.MOD_USER_COMMITTER, ModificationsMother.EMAIL_ADDRESS))));
assertThat(feedEntries.get(0).getMingleCards(), is(asList(new MingleCard(mingleConfig, "123"))));
verify(stageDao).findCompletedStagesFor("cruise", FeedModifier.Latest, -1, 25);
verify(changesetService).modificationsOfPipelines(asList(1L), "cruise", Username.ANONYMOUS);
verifyNoMoreInteractions(stageDao);
verifyNoMoreInteractions(changesetService);
}
use of com.thoughtworks.go.domain.feed.FeedEntries in project gocd by gocd.
the class FeedEntriesRepresenterTest method shouldGenerateXmlWithoutEntryWhenEmpty.
@ParameterizedTest
@FileSource(files = "/feeds/stages-with-no-entries.xml")
void shouldGenerateXmlWithoutEntryWhenEmpty(String expectedXML) {
String pipelineName = "up42";
XmlWriterContext context = new XmlWriterContext("https://go-server/go", null, null, null, new SystemEnvironment());
FeedEntries feedEntries = mock(FeedEntries.class);
when(feedEntries.lastUpdatedDate()).thenReturn(DateUtils.parseISO8601("2019-12-31T07:28:30+05:30"));
Document document = new FeedEntriesRepresenter(pipelineName, feedEntries).toXml(context);
XmlAssert.assertThat(document.asXML()).and(expectedXML).ignoreWhitespace().areIdentical();
}
use of com.thoughtworks.go.domain.feed.FeedEntries 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();
}
Aggregations