@Mock
private GhprbPullRequest pr;
@Test
public void testCheckSkipBuild() throws NoSuchFieldException, SecurityException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
GHIssue issue = mock(GHIssue.class);
String[] comments = {"Some dumb comment\r\nThat shouldn't match", "[skip ci]"};
String[] phraseArray = {"\\[skip\\W+ci\\]", "skip ci"};
Method checkSkip = GhprbPullRequest.class.getDeclaredMethod("checkSkipBuild", GHIssue.class);
checkSkip.setAccessible(true);
Field shouldRun = GhprbPullRequest.class.getDeclaredField("shouldRun");
shouldRun.setAccessible(true);
for (String phraseString : phraseArray) {
for (String comment : comments) {
Set<String> phrases = new HashSet<String>(Arrays.asList(phraseString.split("[\\r\\n]+")));
given(issue.getBody()).willReturn(comment);
given(pr.getSkipBuildPhrases()).willReturn(phrases);
boolean isMatch = false;
for (String phrase : phrases) {
isMatch = Pattern.matches(phrase, comment);
if (isMatch) {