当前位置: 首页>>代码示例>>Java>>正文


Java PullRequest类代码示例

本文整理汇总了Java中com.atlassian.stash.pull.PullRequest的典型用法代码示例。如果您正苦于以下问题:Java PullRequest类的具体用法?Java PullRequest怎么用?Java PullRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PullRequest类属于com.atlassian.stash.pull包,在下文中一共展示了PullRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: pullRequestListener

import com.atlassian.stash.pull.PullRequest; //导入依赖的package包/类
@EventListener
public void pullRequestListener(PullRequestMergeActivityEvent pullRequestMergeActivityEvent) {
    Repository targetRepo = pullRequestMergeActivityEvent.getPullRequest().getToRef().getRepository();
    PullRequest pullRequest = pullRequestMergeActivityEvent.getPullRequest();

    RepositoryHook repositoryHook = repositoryHookService.getByKey(targetRepo, REPO_HOOK_KEY);
    if (repositoryHook.isEnabled() && pullRequestMergeActivityEvent.getActivity().getAction().equals(PullRequestAction.MERGED)) {
        Settings settings = repositoryHookService.getSettings(targetRepo, REPO_HOOK_KEY);
        String bypassKeyword = settings.getString(PullRequestMergeRulesCheck.SETTING_KEY_BYPASS_KEYWORD);
        String apiToken = settings.getString(PullRequestMergeRulesCheck.SETTING_KEY_HIPCHAT_API_TOKEN);
        String roomId = settings.getString(PullRequestMergeRulesCheck.SETTING_KEY_HIPCHAT_ROOM_ID);

        if (StringUtils.containsIgnoreCase(pullRequest.getTitle(), bypassKeyword)
                && isHipChatConfigured(settings)) {
            String message = String.format("<b>%s</b> bypassed merge checks for pull request <b>#%d</b> in <b>%s/%s</b> <br/>%s",
                    pullRequestMergeActivityEvent.getUser().getDisplayName(),
                    pullRequest.getId(),
                    targetRepo.getProject().getKey(),
                    targetRepo.getSlug(),
                    pullRequest.getTitle());

            HipChatClient client = new HipChatClient(apiToken);
            client.sendRoomNotification(new HipChatNotification(message, roomId, HipChatNotification.Color.RED));
        }
    }
}
 
开发者ID:scheerer,项目名称:stash-merge-rules-plugin,代码行数:27,代码来源:MergeCheckBypassListener.java

示例2: triggerBuild

import com.atlassian.stash.pull.PullRequest; //导入依赖的package包/类
@Override
public void triggerBuild(PullRequestEvent pullRequestEvent, BranchPredicate predicate) {
  final PullRequest pullRequest = pullRequestEvent.getPullRequest();
  final PullRequestTriggerSettings settings = getSettings(pullRequest);
  final Repository repository = getRepository(pullRequest);
  final String branchName = pullRequest.getToRef().getId();
  final List<BranchSettings> branchSettingsList = service.getBranchSettingsForBranch(repository, branchName);
  final Long prNumber = pullRequest.getId();

  if (prNumber != null) {
    if (settings.isEnabled()) {
      for (BranchSettings branchSettings : branchSettingsList) {
        if (predicate.matches(branchSettings)) {
          buildTriggerer.invoke(prNumber, settings, branchSettings);
        }
      }
    }
  } else {
    log.error("id of pull request is null: " + pullRequest);
  }
}
 
开发者ID:RichRelevance,项目名称:StashPRTriggerPlugin,代码行数:22,代码来源:TriggerImpl.java

示例3: automaticTriggerIsCalledOnRescopeChangingHashTest

import com.atlassian.stash.pull.PullRequest; //导入依赖的package包/类
@Test
public void automaticTriggerIsCalledOnRescopeChangingHashTest() {
  Trigger trigger = mock(Trigger.class);
  PullRequestRescopedEvent event = mock(PullRequestRescopedEvent.class);
  PullRequest pullRequest = mock(PullRequest.class);
  PullRequestRef fromRef = mock(PullRequestRef.class);

  when(event.getPreviousFromHash()).thenReturn("X");
  when(event.getPullRequest()).thenReturn(pullRequest);
  when(pullRequest.getFromRef()).thenReturn(fromRef);
  when(fromRef.getLatestChangeset()).thenReturn("Y");

  PullRequestHook pullRequestHook = new PullRequestHook(trigger);

  pullRequestHook.onPullRequestRescope(event);

  verify(trigger).automaticTrigger(event);
}
 
开发者ID:RichRelevance,项目名称:StashPRTriggerPlugin,代码行数:19,代码来源:PullRequestHookTest.java

示例4: triggerIsNotCalledOnRescopesWithSameHashTest

import com.atlassian.stash.pull.PullRequest; //导入依赖的package包/类
@Test
public void triggerIsNotCalledOnRescopesWithSameHashTest() {
  Trigger trigger = mock(Trigger.class);
  PullRequestRescopedEvent event = mock(PullRequestRescopedEvent.class);
  PullRequest pullRequest = mock(PullRequest.class);
  PullRequestRef fromRef = mock(PullRequestRef.class);

  when(event.getPreviousFromHash()).thenReturn("X");
  when(event.getPullRequest()).thenReturn(pullRequest);
  when(pullRequest.getFromRef()).thenReturn(fromRef);
  when(fromRef.getLatestChangeset()).thenReturn("X");

  PullRequestHook pullRequestHook = new PullRequestHook(trigger);

  pullRequestHook.onPullRequestRescope(event);

  verify(trigger, never()).automaticTrigger(event);
}
 
开发者ID:RichRelevance,项目名称:StashPRTriggerPlugin,代码行数:19,代码来源:PullRequestHookTest.java

示例5: automaticTriggerBuildIfBranchAutomaticBuildIsEnabledTest

import com.atlassian.stash.pull.PullRequest; //导入依赖的package包/类
@Test
public void automaticTriggerBuildIfBranchAutomaticBuildIsEnabledTest() {
  BuildTriggerer buildTriggerer = mock(BuildTriggerer.class);
  PullRequestEvent event = mock(PullRequestEvent.class);
  PullRequest pullRequest = mock(PullRequest.class);
  PullRequestRef ref = mock(PullRequestRef.class);
  Repository repository = mock(Repository.class);

  when(event.getPullRequest()).thenReturn(pullRequest);
  when(pullRequest.getToRef()).thenReturn(ref, ref);
  when(ref.getRepository()).thenReturn(repository);
  when(ref.getId()).thenReturn(branchName);
  when(pullRequest.getId()).thenReturn(1L);

  Trigger trigger = new TriggerImpl(settingsServiceEnabled, buildTriggerer);

  trigger.automaticTrigger(event);

  verify(buildTriggerer).invoke(1L, settingsEnabled, immutableBranchSettings);
}
 
开发者ID:RichRelevance,项目名称:StashPRTriggerPlugin,代码行数:21,代码来源:TriggerImplTest.java

示例6: automaticTriggerDoesNotBuildIfBranchAutomaticBuildIsDisabledTest

import com.atlassian.stash.pull.PullRequest; //导入依赖的package包/类
@Test
public void automaticTriggerDoesNotBuildIfBranchAutomaticBuildIsDisabledTest() {
  BuildTriggerer buildTriggerer = mock(BuildTriggerer.class);
  PullRequestEvent event = mock(PullRequestEvent.class);
  PullRequest pullRequest = mock(PullRequest.class);
  PullRequestRef ref = mock(PullRequestRef.class);
  Repository repository = mock(Repository.class);

  when(event.getPullRequest()).thenReturn(pullRequest);
  when(pullRequest.getToRef()).thenReturn(ref, ref);
  when(ref.getRepository()).thenReturn(repository);
  when(ref.getId()).thenReturn(branchName);
  when(pullRequest.getId()).thenReturn(1L);

  Trigger trigger = new TriggerImpl(settingsServiceOnDemand, buildTriggerer);

  trigger.automaticTrigger(event);

  verify(buildTriggerer, never()).invoke(anyLong(), any(PullRequestTriggerSettings.class), any(BranchSettings.class));
}
 
开发者ID:RichRelevance,项目名称:StashPRTriggerPlugin,代码行数:21,代码来源:TriggerImplTest.java

示例7: onDemandTriggerBuildsIfMessageMatchesSettingsTest

import com.atlassian.stash.pull.PullRequest; //导入依赖的package包/类
@Test
public void onDemandTriggerBuildsIfMessageMatchesSettingsTest() {
  PullRequestCommentAddedEvent event = mock(PullRequestCommentAddedEvent.class);
  Comment comment = mock(Comment.class);
  PullRequest pullRequest = mock(PullRequest.class);
  PullRequestRef ref = mock(PullRequestRef.class);
  Repository repository = mock(Repository.class);
  BuildTriggerer buildTriggerer = mock(BuildTriggerer.class);

  when(event.getComment()).thenReturn(comment);
  when(comment.getText()).thenReturn(retestMsg);
  when(event.getPullRequest()).thenReturn(pullRequest);
  when(pullRequest.getToRef()).thenReturn(ref);
  when(ref.getRepository()).thenReturn(repository);
  when(ref.getId()).thenReturn(branchName);
  when(pullRequest.getId()).thenReturn(1L);

  Trigger trigger = new TriggerImpl(settingsServiceEnabled, buildTriggerer);

  trigger.onDemandTrigger(event);

  verify(buildTriggerer).invoke(1L, settingsEnabled, immutableBranchSettings);
}
 
开发者ID:RichRelevance,项目名称:StashPRTriggerPlugin,代码行数:24,代码来源:TriggerImplTest.java

示例8: onDemandTriggerBuildsIfMessageMatchesRegexTest

import com.atlassian.stash.pull.PullRequest; //导入依赖的package包/类
@Test
public void onDemandTriggerBuildsIfMessageMatchesRegexTest() {
  PullRequestCommentAddedEvent event = mock(PullRequestCommentAddedEvent.class);
  Comment comment = mock(Comment.class);
  PullRequest pullRequest = mock(PullRequest.class);
  PullRequestRef ref = mock(PullRequestRef.class);
  Repository repository = mock(Repository.class);
  BuildTriggerer buildTriggerer = mock(BuildTriggerer.class);

  when(event.getComment()).thenReturn(comment);
  when(comment.getText()).thenReturn("KLAATU BARADA NIKTO");
  when(event.getPullRequest()).thenReturn(pullRequest);
  when(pullRequest.getToRef()).thenReturn(ref);
  when(ref.getRepository()).thenReturn(repository);
  when(ref.getId()).thenReturn(branchName);
  when(pullRequest.getId()).thenReturn(1L);

  Trigger trigger = new TriggerImpl(settingsServiceRegexEnabled, buildTriggerer);

  trigger.onDemandTrigger(event);

  verify(buildTriggerer).invoke(1L, settingsRegexEnabled, immutableBranchSettings);
}
 
开发者ID:RichRelevance,项目名称:StashPRTriggerPlugin,代码行数:24,代码来源:TriggerImplTest.java

示例9: onDemandTriggersOnlyMatchingBranchesWithMatchingMessagesTest

import com.atlassian.stash.pull.PullRequest; //导入依赖的package包/类
@Test
public void onDemandTriggersOnlyMatchingBranchesWithMatchingMessagesTest() {
  PullRequestCommentAddedEvent event = mock(PullRequestCommentAddedEvent.class);
  Comment comment = mock(Comment.class);
  PullRequest pullRequest = mock(PullRequest.class);
  PullRequestRef ref = mock(PullRequestRef.class);
  Repository repository = mock(Repository.class);
  BuildTriggerer buildTriggerer = mock(BuildTriggerer.class);

  when(event.getComment()).thenReturn(comment);
  when(comment.getText()).thenReturn(alternateMsg);

  when(event.getPullRequest()).thenReturn(pullRequest);
  when(pullRequest.getToRef()).thenReturn(ref);
  when(ref.getRepository()).thenReturn(repository);
  when(ref.getId()).thenReturn(branchName);
  when(pullRequest.getId()).thenReturn(1L);

  Trigger trigger = new TriggerImpl(settingsServiceEnabledMultiBranch, buildTriggerer);

  trigger.onDemandTrigger(event);

  InOrder inOrder = inOrder(buildTriggerer);
  inOrder.verify(buildTriggerer).invoke(1L, settingsEnabled, alternateBranchSettings);
  inOrder.verifyNoMoreInteractions();
}
 
开发者ID:RichRelevance,项目名称:StashPRTriggerPlugin,代码行数:27,代码来源:TriggerImplTest.java

示例10: onDemandDoesNotTriggerBuildsIfMessageDoesNotMatchSettingsTest

import com.atlassian.stash.pull.PullRequest; //导入依赖的package包/类
@Test
public void onDemandDoesNotTriggerBuildsIfMessageDoesNotMatchSettingsTest() {
  PullRequestCommentAddedEvent event = mock(PullRequestCommentAddedEvent.class);
  Comment comment = mock(Comment.class);
  PullRequest pullRequest = mock(PullRequest.class);
  PullRequestRef ref = mock(PullRequestRef.class);
  Repository repository = mock(Repository.class);
  BuildTriggerer buildTriggerer = mock(BuildTriggerer.class);

  when(event.getComment()).thenReturn(comment);
  when(comment.getText()).thenReturn("Do Not Retest");
  when(event.getPullRequest()).thenReturn(pullRequest);
  when(pullRequest.getToRef()).thenReturn(ref);
  when(ref.getRepository()).thenReturn(repository);
  when(ref.getId()).thenReturn(branchName);
  when(pullRequest.getId()).thenReturn(1L);

  Trigger trigger = new TriggerImpl(settingsServiceEnabled, buildTriggerer);

  trigger.onDemandTrigger(event);

  verify(buildTriggerer, never()).invoke(anyLong(), any(PullRequestTriggerSettings.class), any(BranchSettings.class));
}
 
开发者ID:RichRelevance,项目名称:StashPRTriggerPlugin,代码行数:24,代码来源:TriggerImplTest.java

示例11: onDemandDoesNotTriggerBuildsIfMessageIsEmptyTest

import com.atlassian.stash.pull.PullRequest; //导入依赖的package包/类
@Test
public void onDemandDoesNotTriggerBuildsIfMessageIsEmptyTest() {
  PullRequestCommentAddedEvent event = mock(PullRequestCommentAddedEvent.class);
  Comment comment = mock(Comment.class);
  PullRequest pullRequest = mock(PullRequest.class);
  PullRequestRef ref = mock(PullRequestRef.class);
  Repository repository = mock(Repository.class);
  BuildTriggerer buildTriggerer = mock(BuildTriggerer.class);

  when(event.getComment()).thenReturn(comment);
  when(comment.getText()).thenReturn(retestMsg);
  when(event.getPullRequest()).thenReturn(pullRequest);
  when(pullRequest.getToRef()).thenReturn(ref);
  when(ref.getRepository()).thenReturn(repository);
  when(ref.getId()).thenReturn(branchName);
  when(pullRequest.getId()).thenReturn(1L);

  Trigger trigger = new TriggerImpl(settingsServiceEmptyMsg, buildTriggerer);

  trigger.onDemandTrigger(event);

  verify(buildTriggerer, never()).invoke(anyLong(), any(PullRequestTriggerSettings.class), any(BranchSettings.class));
}
 
开发者ID:RichRelevance,项目名称:StashPRTriggerPlugin,代码行数:24,代码来源:TriggerImplTest.java

示例12: triggerBuildDoesNotTriggerBuildsIfRepositoryDisabledTest

import com.atlassian.stash.pull.PullRequest; //导入依赖的package包/类
@Test
public void triggerBuildDoesNotTriggerBuildsIfRepositoryDisabledTest() {
  BuildTriggerer buildTriggerer = mock(BuildTriggerer.class);
  PullRequestEvent event = mock(PullRequestEvent.class);
  PullRequest pullRequest = mock(PullRequest.class);
  PullRequestRef ref = mock(PullRequestRef.class);
  Repository repository = mock(Repository.class);

  when(event.getPullRequest()).thenReturn(pullRequest);
  when(pullRequest.getToRef()).thenReturn(ref, ref);
  when(ref.getRepository()).thenReturn(repository);
  when(ref.getId()).thenReturn(branchName);

  Trigger trigger = new TriggerImpl(settingsServiceDisabled, buildTriggerer);

  trigger.triggerBuild(event, AlwaysTruePredicate.instance);

  verify(buildTriggerer, never()).invoke(anyLong(), any(PullRequestTriggerSettings.class), any(BranchSettings.class));
}
 
开发者ID:RichRelevance,项目名称:StashPRTriggerPlugin,代码行数:20,代码来源:TriggerImplTest.java

示例13: triggerBuildDoesNotTriggerBuildsIfBranchSettingsIsNullTest

import com.atlassian.stash.pull.PullRequest; //导入依赖的package包/类
@Test
public void triggerBuildDoesNotTriggerBuildsIfBranchSettingsIsNullTest() {
  BuildTriggerer buildTriggerer = mock(BuildTriggerer.class);
  PullRequestEvent event = mock(PullRequestEvent.class);
  PullRequest pullRequest = mock(PullRequest.class);
  PullRequestRef ref = mock(PullRequestRef.class);
  Repository repository = mock(Repository.class);

  when(event.getPullRequest()).thenReturn(pullRequest);
  when(pullRequest.getToRef()).thenReturn(ref, ref);
  when(ref.getRepository()).thenReturn(repository);
  when(ref.getId()).thenReturn("another branch");

  Trigger trigger = new TriggerImpl(settingsServiceEnabled, buildTriggerer);

  trigger.triggerBuild(event, AlwaysTruePredicate.instance);

  verify(buildTriggerer, never()).invoke(anyLong(), any(PullRequestTriggerSettings.class), any(BranchSettings.class));
}
 
开发者ID:RichRelevance,项目名称:StashPRTriggerPlugin,代码行数:20,代码来源:TriggerImplTest.java

示例14: triggerBuildBuildsIfEnabledAndBranchSettingsExistAndAutomaticBuildIsEnabledTest

import com.atlassian.stash.pull.PullRequest; //导入依赖的package包/类
@Test
public void triggerBuildBuildsIfEnabledAndBranchSettingsExistAndAutomaticBuildIsEnabledTest() {
  BuildTriggerer buildTriggerer = mock(BuildTriggerer.class);
  PullRequestEvent event = mock(PullRequestEvent.class);
  PullRequest pullRequest = mock(PullRequest.class);
  PullRequestRef ref = mock(PullRequestRef.class);
  Repository repository = mock(Repository.class);

  when(event.getPullRequest()).thenReturn(pullRequest);
  when(pullRequest.getToRef()).thenReturn(ref, ref);
  when(ref.getRepository()).thenReturn(repository);
  when(ref.getId()).thenReturn(branchName);
  when(pullRequest.getId()).thenReturn(1L);

  Trigger trigger = new TriggerImpl(settingsServiceEnabled, buildTriggerer);

  trigger.triggerBuild(event, AlwaysTruePredicate.instance);

  verify(buildTriggerer).invoke(1L, settingsEnabled, immutableBranchSettings);
}
 
开发者ID:RichRelevance,项目名称:StashPRTriggerPlugin,代码行数:21,代码来源:TriggerImplTest.java

示例15: triggerBuildTriggersMultipleBuildsIfMoreThanOneBranchMatchesNameTest

import com.atlassian.stash.pull.PullRequest; //导入依赖的package包/类
@Test
public void triggerBuildTriggersMultipleBuildsIfMoreThanOneBranchMatchesNameTest() {
  BuildTriggerer buildTriggerer = mock(BuildTriggerer.class);
  PullRequestEvent event = mock(PullRequestEvent.class);
  PullRequest pullRequest = mock(PullRequest.class);
  PullRequestRef ref = mock(PullRequestRef.class);
  Repository repository = mock(Repository.class);

  when(event.getPullRequest()).thenReturn(pullRequest);
  when(pullRequest.getToRef()).thenReturn(ref, ref);
  when(ref.getRepository()).thenReturn(repository);
  when(ref.getId()).thenReturn(branchName);
  when(pullRequest.getId()).thenReturn(1L);

  Trigger trigger = new TriggerImpl(settingsServiceEnabledMultiBranch, buildTriggerer);

  trigger.triggerBuild(event, AlwaysTruePredicate.instance);

  verify(buildTriggerer).invoke(1L, settingsEnabled, immutableBranchSettings);
  verify(buildTriggerer).invoke(1L, settingsEnabled, wildcardBranchSettings);
}
 
开发者ID:RichRelevance,项目名称:StashPRTriggerPlugin,代码行数:22,代码来源:TriggerImplTest.java


注:本文中的com.atlassian.stash.pull.PullRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。