本文整理汇总了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));
}
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
示例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);
}
示例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();
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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);
}
示例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);
}