Merge branch 'master' into jae/bulk-update

This commit is contained in:
Liam Newman
2020-12-15 16:08:41 -08:00
committed by GitHub
29 changed files with 380 additions and 65 deletions

View File

@@ -0,0 +1,58 @@
package org.kohsuke.github;
import com.tngtech.archunit.core.domain.JavaClasses;
import com.tngtech.archunit.core.importer.ClassFileImporter;
import com.tngtech.archunit.core.importer.ImportOption;
import com.tngtech.archunit.lang.ArchRule;
import org.junit.BeforeClass;
import org.junit.Test;
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes;
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.fields;
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.methods;
import static org.junit.Assert.assertTrue;
public class ArchTests {
private static final JavaClasses classFiles = new ClassFileImporter()
.withImportOption(new ImportOption.DoNotIncludeTests())
.withImportOption(new ImportOption.DoNotIncludeJars())
.importPackages("org.kohsuke.github");
@BeforeClass
public static void beforeClass() {
assertTrue(classFiles.size() > 0);
}
@Test
public void testPreviewsAreFlaggedAsDeprecated() {
String reason = "all preview APIs must be annotated as @Deprecated until they are promoted to stable";
ArchRule classRule = classes().that()
.areAnnotatedWith(Preview.class)
.should()
.beAnnotatedWith(Deprecated.class)
.because(reason);
ArchRule methodRule = methods().that()
.areAnnotatedWith(Preview.class)
.should()
.beAnnotatedWith(Deprecated.class)
.because(reason);
ArchRule enumFieldsRule = fields().that()
.areDeclaredInClassesThat()
.areEnums()
.and()
.areAnnotatedWith(Preview.class)
.should()
.beAnnotatedWith(Deprecated.class)
.because(reason);
classRule.check(classFiles);
enumFieldsRule.check(classFiles);
methodRule.check(classFiles);
}
}

View File

@@ -471,6 +471,14 @@ public class GHEventPayloadTest extends AbstractGitHubWireMockTest {
assertThat(event.getState(), is(GHCommitState.SUCCESS));
assertThat(event.getCommit().getSHA1(), is("9049f1265b7d61be4a8904a9a27120d2064dab3b"));
assertThat(event.getRepository().getOwner().getLogin(), is("baxterthehacker"));
assertNull(event.getTargetUrl());
}
@Test
public void status2() throws Exception {
GHEventPayload.Status event = GitHub.offline()
.parseEventPayload(payload.asReader(), GHEventPayload.Status.class);
assertThat(event.getTargetUrl(), is("https://www.wikipedia.org/"));
}
// TODO implement support classes and write test