Search in sources :

Example 11 with FeedEntries

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);
}
Also used : FeedEntries(com.thoughtworks.go.domain.feed.FeedEntries) Username(com.thoughtworks.go.server.domain.Username) Test(org.junit.jupiter.api.Test)

Example 12 with FeedEntries

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")));
}
Also used : FeedEntries(com.thoughtworks.go.domain.feed.FeedEntries) Username(com.thoughtworks.go.server.domain.Username) MingleCard(com.thoughtworks.go.server.ui.MingleCard) Author(com.thoughtworks.go.domain.feed.Author) Test(org.junit.Test)

Example 13 with FeedEntries

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);
}
Also used : FeedEntries(com.thoughtworks.go.domain.feed.FeedEntries) StageFeedEntry(com.thoughtworks.go.domain.feed.stage.StageFeedEntry) FeedEntry(com.thoughtworks.go.domain.feed.FeedEntry) Author(com.thoughtworks.go.domain.feed.Author) Arrays.asList(java.util.Arrays.asList) Test(org.junit.Test)

Example 14 with FeedEntries

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();
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) FeedEntries(com.thoughtworks.go.domain.feed.FeedEntries) XmlWriterContext(com.thoughtworks.go.domain.XmlWriterContext) Document(org.dom4j.Document) FileSource(com.thoughtworks.go.junit5.FileSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 15 with FeedEntries

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();
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) FeedEntries(com.thoughtworks.go.domain.feed.FeedEntries) Author(com.thoughtworks.go.domain.feed.Author) XmlWriterContext(com.thoughtworks.go.domain.XmlWriterContext) Document(org.dom4j.Document) StageFeedEntry(com.thoughtworks.go.domain.feed.stage.StageFeedEntry) FileSource(com.thoughtworks.go.junit5.FileSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

FeedEntries (com.thoughtworks.go.domain.feed.FeedEntries)18 Author (com.thoughtworks.go.domain.feed.Author)7 StageFeedEntry (com.thoughtworks.go.domain.feed.stage.StageFeedEntry)7 Username (com.thoughtworks.go.server.domain.Username)7 Test (org.junit.Test)6 Test (org.junit.jupiter.api.Test)6 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)5 FeedEntry (com.thoughtworks.go.domain.feed.FeedEntry)4 Arrays.asList (java.util.Arrays.asList)4 List (java.util.List)3 XmlWriterContext (com.thoughtworks.go.domain.XmlWriterContext)2 FileSource (com.thoughtworks.go.junit5.FileSource)2 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)2 ArrayList (java.util.ArrayList)2 Document (org.dom4j.Document)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)1 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)1 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 NotAuthorizedException (com.thoughtworks.go.config.exceptions.NotAuthorizedException)1