Search in sources :

Example 1 with MingleCard

use of com.thoughtworks.go.server.ui.MingleCard in project gocd by gocd.

the class StageFeedEntryTest method shouldNotAddDuplicateMingleCardsToMingleCardsList.

@Test
public void shouldNotAddDuplicateMingleCardsToMingleCardsList() {
    StageFeedEntry entry = new StageFeedEntry(1, 1, new StageIdentifier(), 1, new Date(), StageResult.Passed);
    entry.addCard(new MingleCard(new MingleConfig("mingle-url", "project-name", null), "#1234"));
    entry.addCard(new MingleCard(new MingleConfig("mingle-url", "project-name", null), "#1234"));
    entry.addCard(new MingleCard(new MingleConfig("mingle-url", "project-name-2", null), "#5678"));
    assertThat(entry.getMingleCards().size(), is(2));
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) MingleCard(com.thoughtworks.go.server.ui.MingleCard) MingleConfig(com.thoughtworks.go.config.MingleConfig) Date(java.util.Date) Test(org.junit.Test)

Example 2 with MingleCard

use of com.thoughtworks.go.server.ui.MingleCard in project gocd by gocd.

the class StageService method populateAuthorsAndMingleCards.

private void populateAuthorsAndMingleCards(List<StageFeedEntry> stageEntries, String pipelineName, Username username) {
    List<Long> pipelineIds = new ArrayList<>();
    for (StageFeedEntry stageEntry : stageEntries) {
        pipelineIds.add(stageEntry.getPipelineId());
    }
    CruiseConfig config = goConfigService.currentCruiseConfig();
    Map<Long, List<ModificationForPipeline>> revisionsPerPipeline = changesetService.modificationsOfPipelines(pipelineIds, pipelineName, username);
    for (StageFeedEntry stageEntry : stageEntries) {
        List<ModificationForPipeline> revs = revisionsPerPipeline.get(stageEntry.getPipelineId());
        for (ModificationForPipeline rev : revs) {
            Author author = rev.getAuthor();
            if (author != null) {
                stageEntry.addAuthor(author);
            }
            String pipelineForRev = rev.getPipelineId().getPipelineName();
            if (config.hasPipelineNamed(new CaseInsensitiveString(pipelineForRev))) {
                PipelineConfig pipelineConfig = config.pipelineConfigByName(new CaseInsensitiveString(pipelineForRev));
                MingleConfig mingleConfig = pipelineConfig.getMingleConfig();
                Set<String> cardNos = rev.getCardNumbersFromComments();
                if (mingleConfig.isDefined()) {
                    for (String cardNo : cardNos) {
                        stageEntry.addCard(new MingleCard(mingleConfig, cardNo));
                    }
                }
            } else {
                LOGGER.debug("pipeline not found: {}", pipelineForRev);
            }
        }
    }
}
Also used : ModificationForPipeline(com.thoughtworks.go.server.ui.ModificationForPipeline) StageFeedEntry(com.thoughtworks.go.domain.feed.stage.StageFeedEntry) MingleCard(com.thoughtworks.go.server.ui.MingleCard) Author(com.thoughtworks.go.domain.feed.Author)

Example 3 with MingleCard

use of com.thoughtworks.go.server.ui.MingleCard 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)

Aggregations

MingleCard (com.thoughtworks.go.server.ui.MingleCard)3 Author (com.thoughtworks.go.domain.feed.Author)2 Test (org.junit.Test)2 MingleConfig (com.thoughtworks.go.config.MingleConfig)1 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)1 FeedEntries (com.thoughtworks.go.domain.feed.FeedEntries)1 StageFeedEntry (com.thoughtworks.go.domain.feed.stage.StageFeedEntry)1 Username (com.thoughtworks.go.server.domain.Username)1 ModificationForPipeline (com.thoughtworks.go.server.ui.ModificationForPipeline)1 Date (java.util.Date)1