From 2b8dde242935b51b8b66fdb3f1bb805bc432dfc9 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Mon, 26 Sep 2022 23:23:54 -0700 Subject: [PATCH] Fix test javadocs --- .../org/kohsuke/github/AbuseLimitHandler.java | 1 + .../java/org/kohsuke/github/GHAppTest.java | 5 - .../java/org/kohsuke/github/GHIssueTest.java | 1 - .../org/kohsuke/github/GHLicenseTest.java | 1 - .../org/kohsuke/github/GHPullRequestTest.java | 1 - .../org/kohsuke/github/GHRepositoryTest.java | 19 - .../java/org/kohsuke/github/GHTeamTest.java | 1 - .../java/org/kohsuke/github/GHUserTest.java | 1 - .../java/org/kohsuke/github/GitHubTest.java | 4 - .../github/extras/GitHubCachingTest.java | 20 + .../github/extras/OkHttpConnectorTest.java | 39 ++ .../authorization/JWTTokenProviderTest.java | 21 + .../extras/okhttp3/GitHubCachingTest.java | 20 + .../extras/okhttp3/OkHttpConnectorTest.java | 44 ++ .../okhttp3/OkHttpGitHubConnectorTest.java | 44 ++ .../internal/DefaultGitHubConnectorTest.java | 12 + .../github/internal/EnumUtilsTest.java | 7 + .../github/junit/GitHubWireMockRule.java | 86 ++++ .../github/junit/WireMockMultiServerRule.java | 51 +++ .../kohsuke/github/junit/WireMockRule.java | 407 ++++++++++++++++++ .../junit/WireMockRuleConfiguration.java | 203 +++++++++ 21 files changed, 955 insertions(+), 33 deletions(-) diff --git a/src/main/java/org/kohsuke/github/AbuseLimitHandler.java b/src/main/java/org/kohsuke/github/AbuseLimitHandler.java index 415e093a14..d6894adf9a 100644 --- a/src/main/java/org/kohsuke/github/AbuseLimitHandler.java +++ b/src/main/java/org/kohsuke/github/AbuseLimitHandler.java @@ -8,6 +8,7 @@ import javax.annotation.Nonnull; +// TODO: Auto-generated Javadoc /** * Pluggable strategy to determine what to do when the API abuse limit is hit. * diff --git a/src/test/java/org/kohsuke/github/GHAppTest.java b/src/test/java/org/kohsuke/github/GHAppTest.java index 19755b9075..b667f7a95d 100644 --- a/src/test/java/org/kohsuke/github/GHAppTest.java +++ b/src/test/java/org/kohsuke/github/GHAppTest.java @@ -39,7 +39,6 @@ protected GitHubBuilder getGitHubBuilder() { /** * Gets the git hub app. * - * @return the git hub app * @throws IOException Signals that an I/O exception has occurred. */ @Test @@ -87,7 +86,6 @@ public void listInstallations() throws IOException { /** * Gets the installation by id. * - * @return the installation by id * @throws IOException Signals that an I/O exception has occurred. */ @Test @@ -100,7 +98,6 @@ public void getInstallationById() throws IOException { /** * Gets the installation by organization. * - * @return the installation by organization * @throws IOException Signals that an I/O exception has occurred. */ @Test @@ -113,7 +110,6 @@ public void getInstallationByOrganization() throws IOException { /** * Gets the installation by repository. * - * @return the installation by repository * @throws IOException Signals that an I/O exception has occurred. */ @Test @@ -126,7 +122,6 @@ public void getInstallationByRepository() throws IOException { /** * Gets the installation by user. * - * @return the installation by user * @throws IOException Signals that an I/O exception has occurred. */ @Test diff --git a/src/test/java/org/kohsuke/github/GHIssueTest.java b/src/test/java/org/kohsuke/github/GHIssueTest.java index c6a23bcedf..3e41db22e4 100644 --- a/src/test/java/org/kohsuke/github/GHIssueTest.java +++ b/src/test/java/org/kohsuke/github/GHIssueTest.java @@ -294,7 +294,6 @@ public void setAssignee() throws Exception { /** * Gets the user test. * - * @return the user test * @throws IOException Signals that an I/O exception has occurred. */ @Test diff --git a/src/test/java/org/kohsuke/github/GHLicenseTest.java b/src/test/java/org/kohsuke/github/GHLicenseTest.java index 63c52fefeb..cb20905720 100644 --- a/src/test/java/org/kohsuke/github/GHLicenseTest.java +++ b/src/test/java/org/kohsuke/github/GHLicenseTest.java @@ -73,7 +73,6 @@ public void listLicensesCheckIndividualLicense() throws IOException { * Checks that the request for an individual license using {@link GitHub#getLicense(String)} returns expected values * (not all properties are checked). * - * @return the license * @throws IOException if test fails */ @Test diff --git a/src/test/java/org/kohsuke/github/GHPullRequestTest.java b/src/test/java/org/kohsuke/github/GHPullRequestTest.java index f8fc9816bf..e67a79ea7f 100644 --- a/src/test/java/org/kohsuke/github/GHPullRequestTest.java +++ b/src/test/java/org/kohsuke/github/GHPullRequestTest.java @@ -730,7 +730,6 @@ public void setAssignee() throws Exception { /** * Gets the user test. * - * @return the user test * @throws IOException Signals that an I/O exception has occurred. */ @Test diff --git a/src/test/java/org/kohsuke/github/GHRepositoryTest.java b/src/test/java/org/kohsuke/github/GHRepositoryTest.java index c75fd0a254..fee5b844bd 100644 --- a/src/test/java/org/kohsuke/github/GHRepositoryTest.java +++ b/src/test/java/org/kohsuke/github/GHRepositoryTest.java @@ -149,7 +149,6 @@ public void isDisabledTrue() throws Exception { /** * Gets the branch URL encoded. * - * @return the branch URL encoded * @throws Exception the exception */ @Test @@ -224,7 +223,6 @@ public void listStargazers() throws IOException { /** * Gets the branch non existent but 200 status. * - * @return the branch non existent but 200 status * @throws Exception the exception */ // Issue #607 @@ -406,7 +404,6 @@ public void listContributors() throws IOException { /** * Gets the permission. * - * @return the permission * @throws Exception the exception */ @Test @@ -554,7 +551,6 @@ public void listReleases() throws IOException { /** * Gets the release exists. * - * @return the release exists * @throws IOException Signals that an I/O exception has occurred. */ @Test @@ -566,7 +562,6 @@ public void getReleaseExists() throws IOException { /** * Gets the release does not exist. * - * @return the release does not exist * @throws IOException Signals that an I/O exception has occurred. */ @Test @@ -578,7 +573,6 @@ public void getReleaseDoesNotExist() throws IOException { /** * Gets the release by tag name exists. * - * @return the release by tag name exists * @throws IOException Signals that an I/O exception has occurred. */ @Test @@ -591,7 +585,6 @@ public void getReleaseByTagNameExists() throws IOException { /** * Gets the release by tag name does not exist. * - * @return the release by tag name does not exist * @throws IOException Signals that an I/O exception has occurred. */ @Test @@ -889,7 +882,6 @@ public void setMergeOptions() throws IOException { /** * Gets the delete branch on merge. * - * @return the delete branch on merge * @throws IOException Signals that an I/O exception has occurred. */ @Test @@ -963,7 +955,6 @@ public void testSetTopics() throws Exception { /** * Gets the collaborators. * - * @return the collaborators * @throws Exception the exception */ @Test @@ -976,7 +967,6 @@ public void getCollaborators() throws Exception { /** * Gets the post commit hooks. * - * @return the post commit hooks * @throws Exception the exception */ @Test @@ -989,7 +979,6 @@ public void getPostCommitHooks() throws Exception { /** * Gets the refs. * - * @return the refs * @throws Exception the exception */ @Test @@ -1004,7 +993,6 @@ public void getRefs() throws Exception { /** * Gets the public key. * - * @return the public key * @throws Exception the exception */ @Test @@ -1019,7 +1007,6 @@ public void getPublicKey() throws Exception { /** * Gets the refs heads. * - * @return the refs heads * @throws Exception the exception */ @Test @@ -1034,7 +1021,6 @@ public void getRefsHeads() throws Exception { /** * Gets the refs empty tags. * - * @return the refs empty tags * @throws Exception the exception */ @Test @@ -1103,7 +1089,6 @@ public void listRefs() throws Exception { /** * Gets the ref. * - * @return the ref * @throws Exception the exception */ @Test @@ -1275,7 +1260,6 @@ public void userIsCollaborator() throws Exception { /** * Gets the check runs. * - * @return the check runs * @throws Exception the exception */ @Test @@ -1305,7 +1289,6 @@ public void getCheckRuns() throws Exception { /** * Gets the last commit status. * - * @return the last commit status * @throws Exception the exception */ @Test @@ -1362,7 +1345,6 @@ public void listCommitsBetweenPaginated() throws Exception { /** * Gets the commits between over 250. * - * @return the commits between over 250 * @throws Exception the exception */ @Test @@ -1436,7 +1418,6 @@ public void getCommitsBetweenOver250() throws Exception { /** * Gets the commits between paged. * - * @return the commits between paged * @throws Exception the exception */ @Test diff --git a/src/test/java/org/kohsuke/github/GHTeamTest.java b/src/test/java/org/kohsuke/github/GHTeamTest.java index 08fa04dcab..c8d1664e5b 100644 --- a/src/test/java/org/kohsuke/github/GHTeamTest.java +++ b/src/test/java/org/kohsuke/github/GHTeamTest.java @@ -54,7 +54,6 @@ public void testSetDescription() throws IOException { /** * Gets the members. * - * @return the members * @throws IOException Signals that an I/O exception has occurred. */ @Test diff --git a/src/test/java/org/kohsuke/github/GHUserTest.java b/src/test/java/org/kohsuke/github/GHUserTest.java index 5fe9f63d7a..9faa519871 100644 --- a/src/test/java/org/kohsuke/github/GHUserTest.java +++ b/src/test/java/org/kohsuke/github/GHUserTest.java @@ -69,7 +69,6 @@ private Set count30(PagedIterable l) { /** * Gets the keys. * - * @return the keys * @throws IOException Signals that an I/O exception has occurred. */ @Test diff --git a/src/test/java/org/kohsuke/github/GitHubTest.java b/src/test/java/org/kohsuke/github/GitHubTest.java index 524a520861..2f753f8278 100644 --- a/src/test/java/org/kohsuke/github/GitHubTest.java +++ b/src/test/java/org/kohsuke/github/GitHubTest.java @@ -33,7 +33,6 @@ public void listUsers() throws IOException { /** * Gets the repository. * - * @return the repository * @throws IOException Signals that an I/O exception has occurred. */ @Test @@ -63,7 +62,6 @@ public void getRepository() throws IOException { /** * Gets the orgs. * - * @return the orgs * @throws IOException Signals that an I/O exception has occurred. */ @Test @@ -265,7 +263,6 @@ public void testListMyAuthorizations() throws IOException { /** * Gets the meta. * - * @return the meta * @throws IOException Signals that an I/O exception has occurred. */ @Test @@ -304,7 +301,6 @@ public void getMeta() throws IOException { /** * Gets the my marketplace purchases. * - * @return the my marketplace purchases * @throws IOException Signals that an I/O exception has occurred. */ @Test diff --git a/src/test/java/org/kohsuke/github/extras/GitHubCachingTest.java b/src/test/java/org/kohsuke/github/extras/GitHubCachingTest.java index 2e03775f69..e39c507c62 100644 --- a/src/test/java/org/kohsuke/github/extras/GitHubCachingTest.java +++ b/src/test/java/org/kohsuke/github/extras/GitHubCachingTest.java @@ -22,6 +22,7 @@ import static org.junit.Assert.fail; +// TODO: Auto-generated Javadoc /** * Test showing the behavior of OkHttpGitHubConnector cache with GitHub 404 responses. * @@ -29,17 +30,31 @@ */ public class GitHubCachingTest extends AbstractGitHubWireMockTest { + /** + * Instantiates a new git hub caching test. + */ public GitHubCachingTest() { useDefaultGitHub = false; } + /** The test ref name. */ String testRefName = "heads/test/content_ref_cache"; + /** + * Gets the wire mock options. + * + * @return the wire mock options + */ @Override protected WireMockConfiguration getWireMockOptions() { return super.getWireMockOptions().extensions(templating.newResponseTransformer()); } + /** + * Setup repo. + * + * @throws Exception the exception + */ @Before public void setupRepo() throws Exception { if (mockGitHub.isUseProxy()) { @@ -54,6 +69,11 @@ public void setupRepo() throws Exception { } } + /** + * Test cached 404. + * + * @throws Exception the exception + */ @Test public void testCached404() throws Exception { Assume.assumeFalse(SystemUtils.IS_OS_WINDOWS); diff --git a/src/test/java/org/kohsuke/github/extras/OkHttpConnectorTest.java b/src/test/java/org/kohsuke/github/extras/OkHttpConnectorTest.java index 761cf32b55..a8a419634e 100644 --- a/src/test/java/org/kohsuke/github/extras/OkHttpConnectorTest.java +++ b/src/test/java/org/kohsuke/github/extras/OkHttpConnectorTest.java @@ -19,6 +19,7 @@ import static org.junit.Assume.assumeFalse; import static org.junit.Assume.assumeTrue; +// TODO: Auto-generated Javadoc /** * Test showing the behavior of OkHttpGitHubConnector with and without cache. *

@@ -41,6 +42,9 @@ */ public class OkHttpConnectorTest extends AbstractGitHubWireMockTest { + /** + * Instantiates a new ok http connector test. + */ public OkHttpConnectorTest() { useDefaultGitHub = false; } @@ -65,11 +69,21 @@ public OkHttpConnectorTest() { private GHRateLimit rateLimitBefore; + /** + * Gets the wire mock options. + * + * @return the wire mock options + */ @Override protected WireMockConfiguration getWireMockOptions() { return super.getWireMockOptions().extensions(templating.newResponseTransformer()); } + /** + * Setup repo. + * + * @throws Exception the exception + */ @Before public void setupRepo() throws Exception { if (mockGitHub.isUseProxy()) { @@ -82,6 +96,11 @@ public void setupRepo() throws Exception { } } + /** + * Default connector. + * + * @throws Exception the exception + */ @Test public void DefaultConnector() throws Exception { @@ -96,6 +115,11 @@ public void DefaultConnector() throws Exception { checkRequestAndLimit(defaultNetworkRequestCount, defaultRateLimitUsed); } + /** + * Ok http connector no cache. + * + * @throws Exception the exception + */ @Test public void OkHttpConnector_NoCache() throws Exception { @@ -118,6 +142,11 @@ public void OkHttpConnector_NoCache() throws Exception { assertThat("Cache", cache, is(nullValue())); } + /** + * Ok http connector cache max age none. + * + * @throws Exception the exception + */ @Test public void OkHttpConnector_Cache_MaxAgeNone() throws Exception { // The responses were recorded from github, but the Date headers @@ -148,6 +177,11 @@ public void OkHttpConnector_Cache_MaxAgeNone() throws Exception { assertThat("getHitCount", cache.getHitCount(), is(maxAgeNoneHitCount)); } + /** + * Ok http connector cache max age three. + * + * @throws Exception the exception + */ @Test public void OkHttpConnector_Cache_MaxAge_Three() throws Exception { @@ -174,6 +208,11 @@ public void OkHttpConnector_Cache_MaxAge_Three() throws Exception { assertThat("getHitCount", cache.getHitCount(), is(maxAgeThreeHitCount)); } + /** + * Ok http connector cache max age default zero. + * + * @throws Exception the exception + */ @Ignore("ISSUE #597 - Correctly formatted Last-Modified headers cause this test to fail") @Test public void OkHttpConnector_Cache_MaxAgeDefault_Zero() throws Exception { diff --git a/src/test/java/org/kohsuke/github/extras/authorization/JWTTokenProviderTest.java b/src/test/java/org/kohsuke/github/extras/authorization/JWTTokenProviderTest.java index 24581000ed..1630bd6cac 100644 --- a/src/test/java/org/kohsuke/github/extras/authorization/JWTTokenProviderTest.java +++ b/src/test/java/org/kohsuke/github/extras/authorization/JWTTokenProviderTest.java @@ -11,6 +11,10 @@ import static org.hamcrest.Matchers.*; +// TODO: Auto-generated Javadoc +/** + * The Class JWTTokenProviderTest. + */ /* * This test will request an application ensuring that the header for the "Authorization" matches a valid JWT token. * A JWT token in the Authorization header will always start with "ey" which is always the start of the base64 @@ -35,6 +39,11 @@ public class JWTTokenProviderTest extends AbstractGHAppInstallationTest { private static String TEST_APP_ID_2 = "83009"; private static String PRIVATE_KEY_FILE_APP_2 = "/ghapi-test-app-2.private-key.pem"; + /** + * Test caching valid authorization. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testCachingValidAuthorization() throws IOException { assertThat(jwtProvider1, instanceOf(JWTTokenProvider.class)); @@ -47,6 +56,12 @@ public void testCachingValidAuthorization() throws IOException { assertThat(authorizationRefresh, sameInstance(authorization)); } + /** + * Test authorization header pattern. + * + * @throws GeneralSecurityException the general security exception + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testAuthorizationHeaderPattern() throws GeneralSecurityException, IOException { // authorization header check is custom @@ -63,6 +78,12 @@ public void testAuthorizationHeaderPattern() throws GeneralSecurityException, IO gh.getApp(); } + /** + * Test issued at skew. + * + * @throws GeneralSecurityException the general security exception + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testIssuedAtSkew() throws GeneralSecurityException, IOException { // TODO: This isn't a great test as it doesn't really check anything in CI diff --git a/src/test/java/org/kohsuke/github/extras/okhttp3/GitHubCachingTest.java b/src/test/java/org/kohsuke/github/extras/okhttp3/GitHubCachingTest.java index 00abeaad20..c73bdabcf6 100644 --- a/src/test/java/org/kohsuke/github/extras/okhttp3/GitHubCachingTest.java +++ b/src/test/java/org/kohsuke/github/extras/okhttp3/GitHubCachingTest.java @@ -21,6 +21,7 @@ import static org.junit.Assert.fail; +// TODO: Auto-generated Javadoc /** * Test showing the behavior of OkHttpGitHubConnector cache with GitHub 404 responses. * @@ -28,12 +29,21 @@ */ public class GitHubCachingTest extends AbstractGitHubWireMockTest { + /** + * Instantiates a new git hub caching test. + */ public GitHubCachingTest() { useDefaultGitHub = false; } + /** The test ref name. */ String testRefName = "heads/test/content_ref_cache"; + /** + * Gets the wire mock options. + * + * @return the wire mock options + */ @Override protected WireMockConfiguration getWireMockOptions() { return super.getWireMockOptions() @@ -42,6 +52,11 @@ protected WireMockConfiguration getWireMockOptions() { .extensions(templating.newResponseTransformer()); } + /** + * Setup repo. + * + * @throws Exception the exception + */ @Before public void setupRepo() throws Exception { if (mockGitHub.isUseProxy()) { @@ -56,6 +71,11 @@ public void setupRepo() throws Exception { } } + /** + * Test cached 404. + * + * @throws Exception the exception + */ @Test public void testCached404() throws Exception { Assume.assumeFalse(SystemUtils.IS_OS_WINDOWS); diff --git a/src/test/java/org/kohsuke/github/extras/okhttp3/OkHttpConnectorTest.java b/src/test/java/org/kohsuke/github/extras/okhttp3/OkHttpConnectorTest.java index 792c199442..ad7d7a15b0 100644 --- a/src/test/java/org/kohsuke/github/extras/okhttp3/OkHttpConnectorTest.java +++ b/src/test/java/org/kohsuke/github/extras/okhttp3/OkHttpConnectorTest.java @@ -23,6 +23,7 @@ import static org.junit.Assume.assumeFalse; import static org.junit.Assume.assumeTrue; +// TODO: Auto-generated Javadoc /** * Test showing the behavior of OkHttpConnector with and without cache. *

@@ -45,6 +46,9 @@ */ public class OkHttpConnectorTest extends AbstractGitHubWireMockTest { + /** + * Instantiates a new ok http connector test. + */ public OkHttpConnectorTest() { useDefaultGitHub = false; } @@ -70,6 +74,11 @@ public OkHttpConnectorTest() { private GHRateLimit rateLimitBefore; private Cache cache = null; + /** + * Gets the wire mock options. + * + * @return the wire mock options + */ @Override protected WireMockConfiguration getWireMockOptions() { return super.getWireMockOptions() @@ -78,6 +87,11 @@ protected WireMockConfiguration getWireMockOptions() { .extensions(templating.newResponseTransformer()); } + /** + * Setup repo. + * + * @throws Exception the exception + */ @Before public void setupRepo() throws Exception { if (mockGitHub.isUseProxy()) { @@ -90,6 +104,11 @@ public void setupRepo() throws Exception { } } + /** + * Delete cache. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @After public void deleteCache() throws IOException { if (cache != null) { @@ -97,6 +116,11 @@ public void deleteCache() throws IOException { } } + /** + * Default connector. + * + * @throws Exception the exception + */ @Test public void DefaultConnector() throws Exception { @@ -111,6 +135,11 @@ public void DefaultConnector() throws Exception { checkRequestAndLimit(defaultNetworkRequestCount, defaultRateLimitUsed); } + /** + * Ok http connector no cache. + * + * @throws Exception the exception + */ @Test public void OkHttpConnector_NoCache() throws Exception { @@ -132,6 +161,11 @@ public void OkHttpConnector_NoCache() throws Exception { assertThat("Cache", cache, is(nullValue())); } + /** + * Ok http connector cache max age none. + * + * @throws Exception the exception + */ @Test public void OkHttpConnector_Cache_MaxAgeNone() throws Exception { // The responses were recorded from github, but the Date headers @@ -160,6 +194,11 @@ public void OkHttpConnector_Cache_MaxAgeNone() throws Exception { assertThat("getHitCount", cache.hitCount(), is(maxAgeNoneHitCount)); } + /** + * Ok http connector cache max age three. + * + * @throws Exception the exception + */ @Test public void OkHttpConnector_Cache_MaxAge_Three() throws Exception { @@ -185,6 +224,11 @@ public void OkHttpConnector_Cache_MaxAge_Three() throws Exception { assertThat("getHitCount", cache.hitCount(), is(maxAgeThreeHitCount)); } + /** + * Ok http connector cache max age default zero. + * + * @throws Exception the exception + */ @Test public void OkHttpConnector_Cache_MaxAgeDefault_Zero() throws Exception { // The responses were recorded from github, but the Date headers diff --git a/src/test/java/org/kohsuke/github/extras/okhttp3/OkHttpGitHubConnectorTest.java b/src/test/java/org/kohsuke/github/extras/okhttp3/OkHttpGitHubConnectorTest.java index 773b3f8614..cc55cf577f 100644 --- a/src/test/java/org/kohsuke/github/extras/okhttp3/OkHttpGitHubConnectorTest.java +++ b/src/test/java/org/kohsuke/github/extras/okhttp3/OkHttpGitHubConnectorTest.java @@ -22,6 +22,7 @@ import static org.junit.Assume.assumeFalse; import static org.junit.Assume.assumeTrue; +// TODO: Auto-generated Javadoc /** * Test showing the behavior of OkHttpGitHubConnector with and without cache. *

@@ -44,6 +45,9 @@ */ public class OkHttpGitHubConnectorTest extends AbstractGitHubWireMockTest { + /** + * Instantiates a new ok http git hub connector test. + */ public OkHttpGitHubConnectorTest() { useDefaultGitHub = false; } @@ -69,6 +73,11 @@ public OkHttpGitHubConnectorTest() { private GHRateLimit rateLimitBefore; private Cache cache = null; + /** + * Gets the wire mock options. + * + * @return the wire mock options + */ @Override protected WireMockConfiguration getWireMockOptions() { return super.getWireMockOptions() @@ -77,6 +86,11 @@ protected WireMockConfiguration getWireMockOptions() { .extensions(templating.newResponseTransformer()); } + /** + * Setup repo. + * + * @throws Exception the exception + */ @Before public void setupRepo() throws Exception { if (mockGitHub.isUseProxy()) { @@ -89,6 +103,11 @@ public void setupRepo() throws Exception { } } + /** + * Delete cache. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @After public void deleteCache() throws IOException { if (cache != null) { @@ -96,6 +115,11 @@ public void deleteCache() throws IOException { } } + /** + * Default connector. + * + * @throws Exception the exception + */ @Test public void DefaultConnector() throws Exception { @@ -110,6 +134,11 @@ public void DefaultConnector() throws Exception { checkRequestAndLimit(defaultNetworkRequestCount, defaultRateLimitUsed); } + /** + * Ok http connector no cache. + * + * @throws Exception the exception + */ @Test public void OkHttpConnector_NoCache() throws Exception { @@ -131,6 +160,11 @@ public void OkHttpConnector_NoCache() throws Exception { assertThat("Cache", cache, is(nullValue())); } + /** + * Ok http connector cache max age none. + * + * @throws Exception the exception + */ @Test public void OkHttpConnector_Cache_MaxAgeNone() throws Exception { // The responses were recorded from github, but the Date headers @@ -159,6 +193,11 @@ public void OkHttpConnector_Cache_MaxAgeNone() throws Exception { assertThat("getHitCount", cache.hitCount(), is(maxAgeNoneHitCount)); } + /** + * Ok http connector cache max age three. + * + * @throws Exception the exception + */ @Test public void OkHttpConnector_Cache_MaxAge_Three() throws Exception { @@ -184,6 +223,11 @@ public void OkHttpConnector_Cache_MaxAge_Three() throws Exception { assertThat("getHitCount", cache.hitCount(), is(maxAgeThreeHitCount)); } + /** + * Ok http connector cache max age default zero. + * + * @throws Exception the exception + */ @Test public void OkHttpConnector_Cache_MaxAgeDefault_Zero() throws Exception { // The responses were recorded from github, but the Date headers diff --git a/src/test/java/org/kohsuke/github/internal/DefaultGitHubConnectorTest.java b/src/test/java/org/kohsuke/github/internal/DefaultGitHubConnectorTest.java index e7f66b1ff1..fcd7d14c65 100644 --- a/src/test/java/org/kohsuke/github/internal/DefaultGitHubConnectorTest.java +++ b/src/test/java/org/kohsuke/github/internal/DefaultGitHubConnectorTest.java @@ -15,12 +15,24 @@ import static org.hamcrest.CoreMatchers.*; +// TODO: Auto-generated Javadoc +/** + * The Class DefaultGitHubConnectorTest. + */ public class DefaultGitHubConnectorTest extends AbstractGitHubWireMockTest { + /** + * Instantiates a new default git hub connector test. + */ public DefaultGitHubConnectorTest() { useDefaultGitHub = false; } + /** + * Test create. + * + * @throws Exception the exception + */ @Test public void testCreate() throws Exception { GitHubConnector connector; diff --git a/src/test/java/org/kohsuke/github/internal/EnumUtilsTest.java b/src/test/java/org/kohsuke/github/internal/EnumUtilsTest.java index 0eb47385e0..b7bab96ec9 100644 --- a/src/test/java/org/kohsuke/github/internal/EnumUtilsTest.java +++ b/src/test/java/org/kohsuke/github/internal/EnumUtilsTest.java @@ -5,8 +5,15 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; +// TODO: Auto-generated Javadoc +/** + * The Class EnumUtilsTest. + */ public class EnumUtilsTest { + /** + * Test get enum. + */ @Test public void testGetEnum() { assertThat(EnumUtils.getEnumOrDefault(TestEnum.class, null, TestEnum.UNKNOWN), equalTo(TestEnum.UNKNOWN)); diff --git a/src/test/java/org/kohsuke/github/junit/GitHubWireMockRule.java b/src/test/java/org/kohsuke/github/junit/GitHubWireMockRule.java index 38c7c5f3c3..bb4398831c 100644 --- a/src/test/java/org/kohsuke/github/junit/GitHubWireMockRule.java +++ b/src/test/java/org/kohsuke/github/junit/GitHubWireMockRule.java @@ -26,6 +26,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.*; import static com.github.tomakehurst.wiremock.common.Gzip.unGzipToString; +// TODO: Auto-generated Javadoc /** * The standard WireMockRule eagerly initializes a WireMockServer. This version suptakes a laze approach allowing us to * automatically isolate snapshots for each method. @@ -43,56 +44,118 @@ public class GitHubWireMockRule extends WireMockMultiServerRule { private final static boolean useProxy = takeSnapshot || System.getProperty("test.github.useProxy", "false") != "false"; + /** + * Customize record spec. + * + * @param customizeRecordSpec the customize record spec + */ public void customizeRecordSpec(Consumer customizeRecordSpec) { this.customizeRecordSpec = customizeRecordSpec; } private Consumer customizeRecordSpec = null; + /** + * Instantiates a new git hub wire mock rule. + */ public GitHubWireMockRule() { this(WireMockConfiguration.options()); } + /** + * Instantiates a new git hub wire mock rule. + * + * @param options the options + */ public GitHubWireMockRule(WireMockConfiguration options) { this(options, true); } + /** + * Instantiates a new git hub wire mock rule. + * + * @param options the options + * @param failOnUnmatchedRequests the fail on unmatched requests + */ public GitHubWireMockRule(WireMockConfiguration options, boolean failOnUnmatchedRequests) { super(options, failOnUnmatchedRequests); } + /** + * Api server. + * + * @return the wire mock server + */ public WireMockServer apiServer() { return servers.get("default"); } + /** + * Raw server. + * + * @return the wire mock server + */ public WireMockServer rawServer() { return servers.get("raw"); } + /** + * Uploads server. + * + * @return the wire mock server + */ public WireMockServer uploadsServer() { return servers.get("uploads"); } + /** + * Codeload server. + * + * @return the wire mock server + */ public WireMockServer codeloadServer() { return servers.get("codeload"); } + /** + * Actions user content server. + * + * @return the wire mock server + */ public WireMockServer actionsUserContentServer() { return servers.get("actions-user-content"); } + /** + * Checks if is use proxy. + * + * @return true, if is use proxy + */ public boolean isUseProxy() { return GitHubWireMockRule.useProxy; } + /** + * Checks if is take snapshot. + * + * @return true, if is take snapshot + */ public boolean isTakeSnapshot() { return GitHubWireMockRule.takeSnapshot; } + /** + * Checks if is test with org. + * + * @return true, if is test with org + */ public boolean isTestWithOrg() { return GitHubWireMockRule.testWithOrg; } + /** + * Initialize servers. + */ @Override protected void initializeServers() { super.initializeServers(); @@ -116,6 +179,9 @@ protected void initializeServers() { } } + /** + * Before. + */ @Override protected void before() { super.before(); @@ -144,6 +210,9 @@ protected void before() { } + /** + * After. + */ @Override protected void after() { super.after(); @@ -191,10 +260,21 @@ private void recordSnapshot(WireMockServer server, String target, boolean isRawS } } + /** + * Gets the request count. + * + * @return the request count + */ public int getRequestCount() { return getRequestCount(apiServer()); } + /** + * Gets the request count. + * + * @param server the server + * @return the request count + */ public static int getRequestCount(WireMockServer server) { return server.countRequestsMatching(RequestPatternBuilder.allRequests().build()).getCount(); } @@ -314,6 +394,12 @@ private Path renameFileToIndex(Path filePath, Map.Entry idToInde return targetPath; } + /** + * Map to mock git hub. + * + * @param body the body + * @return the string + */ @Nonnull public String mapToMockGitHub(String body) { body = body.replace("https://api.github.com", this.apiServer().baseUrl()); diff --git a/src/test/java/org/kohsuke/github/junit/WireMockMultiServerRule.java b/src/test/java/org/kohsuke/github/junit/WireMockMultiServerRule.java index 81e1a958d8..ba1e42c9cc 100644 --- a/src/test/java/org/kohsuke/github/junit/WireMockMultiServerRule.java +++ b/src/test/java/org/kohsuke/github/junit/WireMockMultiServerRule.java @@ -18,6 +18,7 @@ import java.util.List; import java.util.Map; +// TODO: Auto-generated Javadoc /** * The standard WireMockRule eagerly initializes a WireMockServer. This version supports multiple servers in one rule * and takes a lazy approach to intitialization allowing us to isolate files snapshots for each method. @@ -26,33 +27,68 @@ */ public class WireMockMultiServerRule implements MethodRule, TestRule { + /** The servers. */ protected final Map servers = new HashMap<>(); private boolean failOnUnmatchedRequests; private final Options options; + /** + * Gets the method name. + * + * @return the method name + */ public String getMethodName() { return methodName; } private String methodName = null; + /** + * Instantiates a new wire mock multi server rule. + * + * @param options the options + */ public WireMockMultiServerRule(Options options) { this(options, true); } + /** + * Instantiates a new wire mock multi server rule. + * + * @param options the options + * @param failOnUnmatchedRequests the fail on unmatched requests + */ public WireMockMultiServerRule(Options options, boolean failOnUnmatchedRequests) { this.options = options; this.failOnUnmatchedRequests = failOnUnmatchedRequests; } + /** + * Instantiates a new wire mock multi server rule. + */ public WireMockMultiServerRule() { this(WireMockRuleConfiguration.wireMockConfig()); } + /** + * Apply. + * + * @param base the base + * @param description the description + * @return the statement + */ public Statement apply(Statement base, Description description) { return this.apply(base, description.getMethodName()); } + /** + * Apply. + * + * @param base the base + * @param method the method + * @param target the target + * @return the statement + */ public Statement apply(final Statement base, FrameworkMethod method, Object target) { return this.apply(base, method.getName()); } @@ -79,9 +115,18 @@ public void evaluate() throws Throwable { }; } + /** + * Initialize servers. + */ protected void initializeServers() { } + /** + * Initialize server. + * + * @param serverId the server id + * @param extensions the extensions + */ protected final void initializeServer(String serverId, Extension... extensions) { String directoryName = methodName; if (!serverId.equals("default")) { @@ -104,9 +149,15 @@ protected final void initializeServer(String serverId, Extension... extensions) } } + /** + * Before. + */ protected void before() { } + /** + * After. + */ protected void after() { } diff --git a/src/test/java/org/kohsuke/github/junit/WireMockRule.java b/src/test/java/org/kohsuke/github/junit/WireMockRule.java index 0e5340fb54..8073fc9a9b 100644 --- a/src/test/java/org/kohsuke/github/junit/WireMockRule.java +++ b/src/test/java/org/kohsuke/github/junit/WireMockRule.java @@ -34,7 +34,10 @@ import java.util.List; import java.util.UUID; +// TODO: Auto-generated Javadoc /** + * The Class WireMockRule. + * * @author Liam Newman */ public class WireMockRule implements MethodRule, TestRule, Container, Stubbing, Admin { @@ -43,37 +46,82 @@ public class WireMockRule implements MethodRule, TestRule, Container, Stubbing, private boolean failOnUnmatchedRequests; private final Options options; + /** + * Gets the method name. + * + * @return the method name + */ public String getMethodName() { return methodName; } private String methodName = null; + /** + * Instantiates a new wire mock rule. + * + * @param options the options + */ public WireMockRule(Options options) { this(options, true); } + /** + * Instantiates a new wire mock rule. + * + * @param options the options + * @param failOnUnmatchedRequests the fail on unmatched requests + */ public WireMockRule(Options options, boolean failOnUnmatchedRequests) { this.options = options; this.failOnUnmatchedRequests = failOnUnmatchedRequests; } + /** + * Instantiates a new wire mock rule. + * + * @param port the port + */ public WireMockRule(int port) { this(WireMockConfiguration.wireMockConfig().port(port)); } + /** + * Instantiates a new wire mock rule. + * + * @param port the port + * @param httpsPort the https port + */ public WireMockRule(int port, Integer httpsPort) { this(WireMockConfiguration.wireMockConfig().port(port).httpsPort(httpsPort)); } + /** + * Instantiates a new wire mock rule. + */ public WireMockRule() { this(WireMockRuleConfiguration.wireMockConfig()); } + /** + * Apply. + * + * @param base the base + * @param description the description + * @return the statement + */ public Statement apply(Statement base, Description description) { return this.apply(base, description.getMethodName()); } + /** + * Apply. + * + * @param base the base + * @param method the method + * @param target the target + * @return the statement + */ public Statement apply(final Statement base, FrameworkMethod method, Object target) { return this.apply(base, method.getName()); } @@ -120,288 +168,647 @@ private void checkForUnmatchedRequests() { } + /** + * Before. + */ protected void before() { } + /** + * After. + */ protected void after() { } + /** + * Load mappings using. + * + * @param mappingsLoader the mappings loader + */ public void loadMappingsUsing(MappingsLoader mappingsLoader) { wireMockServer.loadMappingsUsing(mappingsLoader); } + /** + * Gets the global settings holder. + * + * @return the global settings holder + */ public GlobalSettingsHolder getGlobalSettingsHolder() { return wireMockServer.getGlobalSettingsHolder(); } + /** + * Adds the mock service request listener. + * + * @param listener the listener + */ public void addMockServiceRequestListener(RequestListener listener) { wireMockServer.addMockServiceRequestListener(listener); } + /** + * Enable record mappings. + * + * @param mappingsFileSource the mappings file source + * @param filesFileSource the files file source + */ public void enableRecordMappings(FileSource mappingsFileSource, FileSource filesFileSource) { wireMockServer.enableRecordMappings(mappingsFileSource, filesFileSource); } + /** + * Stop. + */ public void stop() { wireMockServer.stop(); } + /** + * Start. + */ public void start() { wireMockServer.start(); } + /** + * Shutdown. + */ public void shutdown() { wireMockServer.shutdown(); } + /** + * Port. + * + * @return the int + */ public int port() { return wireMockServer.port(); } + /** + * Https port. + * + * @return the int + */ public int httpsPort() { return wireMockServer.httpsPort(); } + /** + * Url. + * + * @param path the path + * @return the string + */ public String url(String path) { return wireMockServer.url(path); } + /** + * Base url. + * + * @return the string + */ public String baseUrl() { return wireMockServer.baseUrl(); } + /** + * Checks if is running. + * + * @return true, if is running + */ public boolean isRunning() { return wireMockServer.isRunning(); } + /** + * Given that. + * + * @param mappingBuilder the mapping builder + * @return the stub mapping + */ public StubMapping givenThat(MappingBuilder mappingBuilder) { return wireMockServer.givenThat(mappingBuilder); } + /** + * Stub for. + * + * @param mappingBuilder the mapping builder + * @return the stub mapping + */ public StubMapping stubFor(MappingBuilder mappingBuilder) { return wireMockServer.stubFor(mappingBuilder); } + /** + * Edits the stub. + * + * @param mappingBuilder the mapping builder + */ public void editStub(MappingBuilder mappingBuilder) { wireMockServer.editStub(mappingBuilder); } + /** + * Removes the stub. + * + * @param mappingBuilder the mapping builder + */ public void removeStub(MappingBuilder mappingBuilder) { wireMockServer.removeStub(mappingBuilder); } + /** + * Removes the stub. + * + * @param stubMapping the stub mapping + */ public void removeStub(StubMapping stubMapping) { wireMockServer.removeStub(stubMapping); } + /** + * Gets the stub mappings. + * + * @return the stub mappings + */ public List getStubMappings() { return wireMockServer.getStubMappings(); } + /** + * Gets the single stub mapping. + * + * @param id the id + * @return the single stub mapping + */ public StubMapping getSingleStubMapping(UUID id) { return wireMockServer.getSingleStubMapping(id); } + /** + * Find stub mappings by metadata. + * + * @param pattern the pattern + * @return the list + */ public List findStubMappingsByMetadata(StringValuePattern pattern) { return wireMockServer.findStubMappingsByMetadata(pattern); } + /** + * Removes the stub mappings by metadata. + * + * @param pattern the pattern + */ public void removeStubMappingsByMetadata(StringValuePattern pattern) { wireMockServer.removeStubMappingsByMetadata(pattern); } + /** + * Removes the stub mapping. + * + * @param stubMapping the stub mapping + */ public void removeStubMapping(StubMapping stubMapping) { wireMockServer.removeStubMapping(stubMapping); } + /** + * Verify. + * + * @param requestPatternBuilder the request pattern builder + */ public void verify(RequestPatternBuilder requestPatternBuilder) { wireMockServer.verify(requestPatternBuilder); } + /** + * Verify. + * + * @param count the count + * @param requestPatternBuilder the request pattern builder + */ public void verify(int count, RequestPatternBuilder requestPatternBuilder) { wireMockServer.verify(count, requestPatternBuilder); } + /** + * Verify. + * + * @param countMatchingStrategy the count matching strategy + * @param requestPatternBuilder the request pattern builder + */ public void verify(CountMatchingStrategy countMatchingStrategy, RequestPatternBuilder requestPatternBuilder) { wireMockServer.verify(countMatchingStrategy, requestPatternBuilder); } + /** + * Find all. + * + * @param requestPatternBuilder the request pattern builder + * @return the list + */ public List findAll(RequestPatternBuilder requestPatternBuilder) { return wireMockServer.findAll(requestPatternBuilder); } + /** + * Gets the all serve events. + * + * @return the all serve events + */ public List getAllServeEvents() { return wireMockServer.getAllServeEvents(); } + /** + * Sets the global fixed delay. + * + * @param milliseconds the new global fixed delay + */ public void setGlobalFixedDelay(int milliseconds) { wireMockServer.setGlobalFixedDelay(milliseconds); } + /** + * Find all unmatched requests. + * + * @return the list + */ public List findAllUnmatchedRequests() { return wireMockServer.findAllUnmatchedRequests(); } + /** + * Find near misses for all unmatched requests. + * + * @return the list + */ public List findNearMissesForAllUnmatchedRequests() { return wireMockServer.findNearMissesForAllUnmatchedRequests(); } + /** + * Find all near misses for. + * + * @param requestPatternBuilder the request pattern builder + * @return the list + */ public List findAllNearMissesFor(RequestPatternBuilder requestPatternBuilder) { return wireMockServer.findAllNearMissesFor(requestPatternBuilder); } + /** + * Find near misses for. + * + * @param loggedRequest the logged request + * @return the list + */ public List findNearMissesFor(LoggedRequest loggedRequest) { return wireMockServer.findNearMissesFor(loggedRequest); } + /** + * Adds the stub mapping. + * + * @param stubMapping the stub mapping + */ public void addStubMapping(StubMapping stubMapping) { wireMockServer.addStubMapping(stubMapping); } + /** + * Edits the stub mapping. + * + * @param stubMapping the stub mapping + */ public void editStubMapping(StubMapping stubMapping) { wireMockServer.editStubMapping(stubMapping); } + /** + * List all stub mappings. + * + * @return the list stub mappings result + */ public ListStubMappingsResult listAllStubMappings() { return wireMockServer.listAllStubMappings(); } + /** + * Gets the stub mapping. + * + * @param id the id + * @return the stub mapping + */ public SingleStubMappingResult getStubMapping(UUID id) { return wireMockServer.getStubMapping(id); } + /** + * Save mappings. + */ public void saveMappings() { wireMockServer.saveMappings(); } + /** + * Reset all. + */ public void resetAll() { wireMockServer.resetAll(); } + /** + * Reset requests. + */ public void resetRequests() { wireMockServer.resetRequests(); } + /** + * Reset to default mappings. + */ public void resetToDefaultMappings() { wireMockServer.resetToDefaultMappings(); } + /** + * Gets the serve events. + * + * @return the serve events + */ public GetServeEventsResult getServeEvents() { return wireMockServer.getServeEvents(); } + /** + * Gets the serve events. + * + * @param serveEventQuery the serve event query + * @return the serve events + */ public GetServeEventsResult getServeEvents(ServeEventQuery serveEventQuery) { return wireMockServer.getServeEvents(serveEventQuery); } + /** + * Gets the served stub. + * + * @param id the id + * @return the served stub + */ public SingleServedStubResult getServedStub(UUID id) { return wireMockServer.getServedStub(id); } + /** + * Reset scenarios. + */ public void resetScenarios() { wireMockServer.resetScenarios(); } + /** + * Reset mappings. + */ public void resetMappings() { wireMockServer.resetMappings(); } + /** + * Count requests matching. + * + * @param requestPattern the request pattern + * @return the verification result + */ public VerificationResult countRequestsMatching(RequestPattern requestPattern) { return wireMockServer.countRequestsMatching(requestPattern); } + /** + * Find requests matching. + * + * @param requestPattern the request pattern + * @return the find requests result + */ public FindRequestsResult findRequestsMatching(RequestPattern requestPattern) { return wireMockServer.findRequestsMatching(requestPattern); } + /** + * Find unmatched requests. + * + * @return the find requests result + */ public FindRequestsResult findUnmatchedRequests() { return wireMockServer.findUnmatchedRequests(); } + /** + * Removes the serve event. + * + * @param uuid the uuid + */ public void removeServeEvent(UUID uuid) { wireMockServer.removeServeEvent(uuid); } + /** + * Removes the serve events matching. + * + * @param requestPattern the request pattern + * @return the find serve events result + */ public FindServeEventsResult removeServeEventsMatching(RequestPattern requestPattern) { return wireMockServer.removeServeEventsMatching(requestPattern); } + /** + * Removes the serve events for stubs matching metadata. + * + * @param stringValuePattern the string value pattern + * @return the find serve events result + */ public FindServeEventsResult removeServeEventsForStubsMatchingMetadata(StringValuePattern stringValuePattern) { return wireMockServer.removeServeEventsForStubsMatchingMetadata(stringValuePattern); } + /** + * Update global settings. + * + * @param newSettings the new settings + */ public void updateGlobalSettings(GlobalSettings newSettings) { wireMockServer.updateGlobalSettings(newSettings); } + /** + * Find near misses for unmatched requests. + * + * @return the find near misses result + */ public FindNearMissesResult findNearMissesForUnmatchedRequests() { return wireMockServer.findNearMissesForUnmatchedRequests(); } + /** + * Gets the all scenarios. + * + * @return the all scenarios + */ public GetScenariosResult getAllScenarios() { return wireMockServer.getAllScenarios(); } + /** + * Find top near misses for. + * + * @param loggedRequest the logged request + * @return the find near misses result + */ public FindNearMissesResult findTopNearMissesFor(LoggedRequest loggedRequest) { return wireMockServer.findTopNearMissesFor(loggedRequest); } + /** + * Find top near misses for. + * + * @param requestPattern the request pattern + * @return the find near misses result + */ public FindNearMissesResult findTopNearMissesFor(RequestPattern requestPattern) { return wireMockServer.findTopNearMissesFor(requestPattern); } + /** + * Start recording. + * + * @param targetBaseUrl the target base url + */ public void startRecording(String targetBaseUrl) { wireMockServer.startRecording(targetBaseUrl); } + /** + * Start recording. + * + * @param spec the spec + */ public void startRecording(RecordSpec spec) { wireMockServer.startRecording(spec); } + /** + * Start recording. + * + * @param recordSpec the record spec + */ public void startRecording(RecordSpecBuilder recordSpec) { wireMockServer.startRecording(recordSpec); } + /** + * Stop recording. + * + * @return the snapshot record result + */ public SnapshotRecordResult stopRecording() { return wireMockServer.stopRecording(); } + /** + * Gets the recording status. + * + * @return the recording status + */ public RecordingStatusResult getRecordingStatus() { return wireMockServer.getRecordingStatus(); } + /** + * Snapshot record. + * + * @return the snapshot record result + */ public SnapshotRecordResult snapshotRecord() { return wireMockServer.snapshotRecord(); } + /** + * Snapshot record. + * + * @param spec the spec + * @return the snapshot record result + */ public SnapshotRecordResult snapshotRecord(RecordSpecBuilder spec) { return wireMockServer.snapshotRecord(spec); } + /** + * Snapshot record. + * + * @param spec the spec + * @return the snapshot record result + */ public SnapshotRecordResult snapshotRecord(RecordSpec spec) { return wireMockServer.snapshotRecord(spec); } + /** + * Gets the options. + * + * @return the options + */ public Options getOptions() { return wireMockServer.getOptions(); } + /** + * Shutdown server. + */ public void shutdownServer() { wireMockServer.shutdownServer(); } + /** + * Find all stubs by metadata. + * + * @param pattern the pattern + * @return the list stub mappings result + */ public ListStubMappingsResult findAllStubsByMetadata(StringValuePattern pattern) { return wireMockServer.findAllStubsByMetadata(pattern); } + /** + * Removes the stubs by metadata. + * + * @param pattern the pattern + */ public void removeStubsByMetadata(StringValuePattern pattern) { wireMockServer.removeStubsByMetadata(pattern); } + /** + * Import stubs. + * + * @param stubImport the stub import + */ public void importStubs(StubImport stubImport) { wireMockServer.importStubs(stubImport); } + /** + * Gets the global settings. + * + * @return the global settings + */ public GetGlobalSettingsResult getGlobalSettings() { return wireMockServer.getGlobalSettings(); } diff --git a/src/test/java/org/kohsuke/github/junit/WireMockRuleConfiguration.java b/src/test/java/org/kohsuke/github/junit/WireMockRuleConfiguration.java index 478e14272a..f60f51ec43 100644 --- a/src/test/java/org/kohsuke/github/junit/WireMockRuleConfiguration.java +++ b/src/test/java/org/kohsuke/github/junit/WireMockRuleConfiguration.java @@ -22,6 +22,10 @@ import java.util.List; import java.util.Map; +// TODO: Auto-generated Javadoc +/** + * The Class WireMockRuleConfiguration. + */ public class WireMockRuleConfiguration implements Options { private final Options parent; @@ -29,24 +33,50 @@ public class WireMockRuleConfiguration implements Options { private MappingsSource mappingsSource; private Map extensions = Maps.newLinkedHashMap(); + /** + * Instantiates a new wire mock rule configuration. + */ WireMockRuleConfiguration() { this(WireMockConfiguration.options(), null); } + /** + * Instantiates a new wire mock rule configuration. + * + * @param parent the parent + * @param childDirectory the child directory + * @param extensionInstances the extension instances + */ WireMockRuleConfiguration(Options parent, String childDirectory, Extension... extensionInstances) { this.parent = parent; this.childDirectory = childDirectory; this.extensions.putAll(ExtensionLoader.asMap(Arrays.asList(extensionInstances))); } + /** + * Wire mock config. + * + * @return the wire mock rule configuration + */ public static WireMockRuleConfiguration wireMockConfig() { return new WireMockRuleConfiguration(); } + /** + * Options. + * + * @return the wire mock rule configuration + */ public static WireMockRuleConfiguration options() { return wireMockConfig(); } + /** + * For child path. + * + * @param childPath the child path + * @return the wire mock rule configuration + */ public WireMockRuleConfiguration forChildPath(String childPath) { return new WireMockRuleConfiguration(this, childPath); } @@ -59,23 +89,51 @@ private MappingsSource getMappingsSource() { return this.mappingsSource; } + /** + * Files root. + * + * @return the file source + */ public FileSource filesRoot() { return childDirectory != null ? parent.filesRoot().child(childDirectory) : parent.filesRoot(); } + /** + * Mappings loader. + * + * @return the mappings loader + */ public MappingsLoader mappingsLoader() { return this.getMappingsSource(); } + /** + * Mappings saver. + * + * @return the mappings saver + */ public MappingsSaver mappingsSaver() { return this.getMappingsSource(); } + /** + * Mapping source. + * + * @param mappingsSource the mappings source + * @return the wire mock rule configuration + */ public WireMockRuleConfiguration mappingSource(MappingsSource mappingsSource) { this.mappingsSource = mappingsSource; return this; } + /** + * Extensions of type. + * + * @param the generic type + * @param extensionType the extension type + * @return the map + */ public Map extensionsOfType(Class extensionType) { Map result = Maps.newLinkedHashMap(this.parent.extensionsOfType(extensionType)); result.putAll((Map) Maps.filterEntries(this.extensions, @@ -85,118 +143,263 @@ public Map extensionsOfType(Class extensionT // Simple wrappers + /** + * Port number. + * + * @return the int + */ public int portNumber() { return parent.portNumber(); } + /** + * Gets the http disabled. + * + * @return the http disabled + */ public boolean getHttpDisabled() { return parent.getHttpDisabled(); } + /** + * Container threads. + * + * @return the int + */ public int containerThreads() { return parent.containerThreads(); } + /** + * Https settings. + * + * @return the https settings + */ public HttpsSettings httpsSettings() { return parent.httpsSettings(); } + /** + * Jetty settings. + * + * @return the jetty settings + */ public JettySettings jettySettings() { return parent.jettySettings(); } + /** + * Browser proxying enabled. + * + * @return true, if successful + */ public boolean browserProxyingEnabled() { return parent.browserProxyingEnabled(); } + /** + * Browser proxy settings. + * + * @return the browser proxy settings + */ public BrowserProxySettings browserProxySettings() { return parent.browserProxySettings(); } + /** + * Proxy via. + * + * @return the proxy settings + */ public ProxySettings proxyVia() { return parent.proxyVia(); } + /** + * Notifier. + * + * @return the notifier + */ public Notifier notifier() { return parent.notifier(); } + /** + * Request journal disabled. + * + * @return true, if successful + */ public boolean requestJournalDisabled() { return parent.requestJournalDisabled(); } + /** + * Max request journal entries. + * + * @return the optional + */ public Optional maxRequestJournalEntries() { return parent.maxRequestJournalEntries(); } + /** + * Bind address. + * + * @return the string + */ public String bindAddress() { return parent.bindAddress(); } + /** + * Matching headers. + * + * @return the list + */ public List matchingHeaders() { return parent.matchingHeaders(); } + /** + * Http server factory. + * + * @return the http server factory + */ public HttpServerFactory httpServerFactory() { return parent.httpServerFactory(); } + /** + * Thread pool factory. + * + * @return the thread pool factory + */ public ThreadPoolFactory threadPoolFactory() { return parent.threadPoolFactory(); } + /** + * Should preserve host header. + * + * @return true, if successful + */ public boolean shouldPreserveHostHeader() { return parent.shouldPreserveHostHeader(); } + /** + * Proxy host header. + * + * @return the string + */ public String proxyHostHeader() { return parent.proxyHostHeader(); } + /** + * Network traffic listener. + * + * @return the wiremock network traffic listener + */ public WiremockNetworkTrafficListener networkTrafficListener() { return parent.networkTrafficListener(); } + /** + * Gets the admin authenticator. + * + * @return the admin authenticator + */ public Authenticator getAdminAuthenticator() { return parent.getAdminAuthenticator(); } + /** + * Gets the https required for admin api. + * + * @return the https required for admin api + */ public boolean getHttpsRequiredForAdminApi() { return parent.getHttpsRequiredForAdminApi(); } + /** + * Gets the not matched renderer. + * + * @return the not matched renderer + */ public NotMatchedRenderer getNotMatchedRenderer() { return parent.getNotMatchedRenderer(); } + /** + * Gets the asynchronous response settings. + * + * @return the asynchronous response settings + */ public AsynchronousResponseSettings getAsynchronousResponseSettings() { return parent.getAsynchronousResponseSettings(); } + /** + * Gets the chunked encoding policy. + * + * @return the chunked encoding policy + */ public ChunkedEncodingPolicy getChunkedEncodingPolicy() { return parent.getChunkedEncodingPolicy(); } + /** + * Gets the gzip disabled. + * + * @return the gzip disabled + */ public boolean getGzipDisabled() { return parent.getGzipDisabled(); } + /** + * Gets the stub request logging disabled. + * + * @return the stub request logging disabled + */ public boolean getStubRequestLoggingDisabled() { return parent.getStubRequestLoggingDisabled(); } + /** + * Gets the stub cors enabled. + * + * @return the stub cors enabled + */ public boolean getStubCorsEnabled() { return parent.getStubCorsEnabled(); } + /** + * Timeout. + * + * @return the long + */ public long timeout() { return parent.timeout(); } + /** + * Gets the disable optimize xml factories loading. + * + * @return the disable optimize xml factories loading + */ public boolean getDisableOptimizeXmlFactoriesLoading() { return parent.getDisableOptimizeXmlFactoriesLoading(); } + /** + * Gets the disable strict http headers. + * + * @return the disable strict http headers + */ public boolean getDisableStrictHttpHeaders() { return parent.getDisableStrictHttpHeaders(); }