Skip to content

Commit

Permalink
fixed test issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Alaurant committed Dec 3, 2024
1 parent 2ad3c5b commit a83d081
Show file tree
Hide file tree
Showing 34 changed files with 281 additions and 283 deletions.
78 changes: 38 additions & 40 deletions src/test/java/org/kohsuke/github/GHAutolinkTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import java.util.List;

import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;

// TODO: Auto-generated Javadoc
/**
Expand Down Expand Up @@ -100,47 +98,47 @@ public void testReadAutolink() throws Exception {
*/
@Test
public void testListAllAutolinks() throws Exception {
assertThat("Initial autolinks should be empty", repo.listAutolinks().toList(), is(empty()));
assertThat("Initial autolinks list", repo.listAutolinks().toList(), is(empty()));

try {
GHAutolink autolink1 = repo.createAutolink()
.withKeyPrefix("LIST-")
.withUrlTemplate("https://example.com/list1/<num>")
.withIsAlphanumeric(true)
.create();

GHAutolink autolink2 = repo.createAutolink()
.withKeyPrefix("LISTED-")
.withUrlTemplate("https://example.com/list2/<num>")
.withIsAlphanumeric(false)
.create();

List<GHAutolink> autolinks = repo.listAutolinks().toList();
assertThat("Should have exactly 2 autolinks", ((List<?>) autolinks).size(), is(2));

GHAutolink foundAutolink1 = autolinks.stream()
.filter(a -> a.getId().equals(autolink1.getId()))
.findFirst()
.orElseThrow(() -> new AssertionError("Autolink 1 not found"));

GHAutolink foundAutolink2 = autolinks.stream()
.filter(a -> a.getId().equals(autolink2.getId()))
.findFirst()
.orElseThrow(() -> new AssertionError("Autolink 2 not found"));

assertAutolinksEqual(autolink1, foundAutolink1);
assertAutolinksEqual(autolink2, foundAutolink2);

} catch (Exception e) {
System.err.println("Failed to list autolinks: " + e.getMessage());
GHAutolink autolink1 = repo.createAutolink()
.withKeyPrefix("LIST-")
.withUrlTemplate("https://example.com/list1/<num>")
.withIsAlphanumeric(true)
.create();

GHAutolink autolink2 = repo.createAutolink()
.withKeyPrefix("LISTED-")
.withUrlTemplate("https://example.com/list2/<num>")
.withIsAlphanumeric(false)
.create();

boolean found1 = false;
boolean found2 = false;

PagedIterable<GHAutolink> autolinks = repo.listAutolinks();

List<GHAutolink> autolinkList = autolinks.toList();
assertThat("Number of autolinks", autolinkList.size(), is(2));

for (GHAutolink autolink : autolinkList) {

if (autolink.getId().equals(autolink1.getId())) {
found1 = true;
assertThat(autolink.getKeyPrefix(), equalTo(autolink1.getKeyPrefix()));
assertThat(autolink.getUrlTemplate(), equalTo(autolink1.getUrlTemplate()));
assertThat(autolink.isAlphanumeric(), equalTo(autolink1.isAlphanumeric()));
}
if (autolink.getId().equals(autolink2.getId())) {
found2 = true;
assertThat(autolink.getKeyPrefix(), equalTo(autolink2.getKeyPrefix()));
assertThat(autolink.getUrlTemplate(), equalTo(autolink2.getUrlTemplate()));
assertThat(autolink.isAlphanumeric(), equalTo(autolink2.isAlphanumeric()));
}
}
}

private void assertAutolinksEqual(GHAutolink expected, GHAutolink actual) {
assertThat(actual.getKeyPrefix(), equalTo(expected.getKeyPrefix()));
assertThat(actual.getUrlTemplate(), equalTo(expected.getUrlTemplate()));
assertThat(actual.isAlphanumeric(), equalTo(expected.isAlphanumeric()));
assertThat(actual.getOwner(), equalTo(expected.getOwner()));
assertThat("First autolink", found1, is(true));
assertThat("Second autolink", found2, is(true));

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"triage": true,
"pull": true
},
"temp_clone_token": "AJ7BLWGMBCV4RX4BQQXEBOTHJ2WGQ",
"temp_clone_token": "AJ7BLWBKSYTW3I62UR7LF2DHJ23LK",
"allow_squash_merge": true,
"allow_merge_commit": true,
"allow_rebase_merge": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "a4f46a34-8c81-44e9-bec4-043ba7bdcb10",
"id": "98d81ba5-ebd3-49e4-84f2-75f985bc47cc",
"name": "user",
"request": {
"url": "/user",
Expand All @@ -14,7 +14,7 @@
"status": 200,
"bodyFileName": "1-user.json",
"headers": {
"Date": "Tue, 03 Dec 2024 06:54:51 GMT",
"Date": "Tue, 03 Dec 2024 07:38:48 GMT",
"Content-Type": "application/json; charset=utf-8",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": "Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With",
Expand All @@ -26,9 +26,9 @@
"X-GitHub-Media-Type": "github.v3; format=json",
"x-github-api-version-selected": "2022-11-28",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4953",
"X-RateLimit-Reset": "1733209471",
"X-RateLimit-Used": "47",
"X-RateLimit-Remaining": "4972",
"X-RateLimit-Reset": "1733215115",
"X-RateLimit-Used": "28",
"X-RateLimit-Resource": "core",
"Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset",
"Access-Control-Allow-Origin": "*",
Expand All @@ -39,10 +39,10 @@
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
"Content-Security-Policy": "default-src 'none'",
"Server": "github.com",
"X-GitHub-Request-Id": "AB78:259AD1:61CD9C:72C698:674EAB3B"
"X-GitHub-Request-Id": "AA46:260E1D:699639:7B2A52:674EB588"
}
},
"uuid": "a4f46a34-8c81-44e9-bec4-043ba7bdcb10",
"uuid": "98d81ba5-ebd3-49e4-84f2-75f985bc47cc",
"persistent": true,
"insertionIndex": 1
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "ee74a0a7-35fd-4683-a471-587c81678ae3",
"id": "2fcf27db-2e76-4f6f-a79f-c9519c5d91ca",
"name": "repos_alaurant_github-api-test",
"request": {
"url": "/repos/Alaurant/github-api-test",
Expand All @@ -14,7 +14,7 @@
"status": 200,
"bodyFileName": "2-r_a_github-api-test.json",
"headers": {
"Date": "Tue, 03 Dec 2024 06:54:52 GMT",
"Date": "Tue, 03 Dec 2024 07:38:49 GMT",
"Content-Type": "application/json; charset=utf-8",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": "Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With",
Expand All @@ -26,9 +26,9 @@
"X-GitHub-Media-Type": "github.v3; format=json",
"x-github-api-version-selected": "2022-11-28",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4951",
"X-RateLimit-Reset": "1733209471",
"X-RateLimit-Used": "49",
"X-RateLimit-Remaining": "4970",
"X-RateLimit-Reset": "1733215115",
"X-RateLimit-Used": "30",
"X-RateLimit-Resource": "core",
"Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset",
"Access-Control-Allow-Origin": "*",
Expand All @@ -39,10 +39,10 @@
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
"Content-Security-Policy": "default-src 'none'",
"Server": "github.com",
"X-GitHub-Request-Id": "ABD3:275BE1:5986ED:681867:674EAB3C"
"X-GitHub-Request-Id": "AA4A:275BE1:5DAE86:6CDB96:674EB589"
}
},
"uuid": "ee74a0a7-35fd-4683-a471-587c81678ae3",
"uuid": "2fcf27db-2e76-4f6f-a79f-c9519c5d91ca",
"persistent": true,
"insertionIndex": 2
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "e03166d6-8ef7-42ef-9fd9-3c37415b29d8",
"id": "8347f3dd-5be0-4a28-b01e-9e1405b46087",
"name": "repos_alaurant_github-api-test_autolinks",
"request": {
"url": "/repos/Alaurant/github-api-test/autolinks",
Expand All @@ -19,22 +19,22 @@
},
"response": {
"status": 201,
"body": "{\"id\":6208102,\"key_prefix\":\"EXAMPLE-\",\"url_template\":\"https://example.com/TICKET?q=<num>\",\"is_alphanumeric\":true}",
"body": "{\"id\":6208157,\"key_prefix\":\"EXAMPLE-\",\"url_template\":\"https://example.com/TICKET?q=<num>\",\"is_alphanumeric\":true}",
"headers": {
"Date": "Tue, 03 Dec 2024 06:54:53 GMT",
"Date": "Tue, 03 Dec 2024 07:38:49 GMT",
"Content-Type": "application/json; charset=utf-8",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": "Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With",
"ETag": "\"a43aceb24d084ac36cc51df4652c6770f8d169d875ecf46247ac99b589e441fe\"",
"ETag": "\"a36001f0fa64730b7452b1bc25ccdf888f1db06d9933656b99e2cff7b4e48b3a\"",
"X-OAuth-Scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, admin:ssh_signing_key, audit_log, codespace, delete:packages, delete_repo, gist, project, read:packages, repo, user, workflow, write:discussion",
"X-Accepted-OAuth-Scopes": "repo",
"github-authentication-token-expiration": "2025-02-25 04:28:56 UTC",
"X-GitHub-Media-Type": "github.v3; format=json",
"x-github-api-version-selected": "2022-11-28",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4950",
"X-RateLimit-Reset": "1733209471",
"X-RateLimit-Used": "50",
"X-RateLimit-Remaining": "4969",
"X-RateLimit-Reset": "1733215115",
"X-RateLimit-Used": "31",
"X-RateLimit-Resource": "core",
"Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset",
"Access-Control-Allow-Origin": "*",
Expand All @@ -45,10 +45,10 @@
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
"Content-Security-Policy": "default-src 'none'",
"Server": "github.com",
"X-GitHub-Request-Id": "ABD4:25E009:63825C:747B1A:674EAB3D"
"X-GitHub-Request-Id": "AA4D:261CA8:67BCCF:795107:674EB589"
}
},
"uuid": "e03166d6-8ef7-42ef-9fd9-3c37415b29d8",
"uuid": "8347f3dd-5be0-4a28-b01e-9e1405b46087",
"persistent": true,
"insertionIndex": 3
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"id": "5f7726c7-5f1a-4f69-9fee-3d2b34dcc2ee",
"name": "repos_alaurant_github-api-test_autolinks_6208102",
"id": "e3c2362c-a973-4ad6-91fa-5efe8aa8c05c",
"name": "repos_alaurant_github-api-test_autolinks_6208157",
"request": {
"url": "/repos/Alaurant/github-api-test/autolinks/6208102",
"url": "/repos/Alaurant/github-api-test/autolinks/6208157",
"method": "DELETE",
"headers": {
"Accept": {
Expand All @@ -13,16 +13,16 @@
"response": {
"status": 204,
"headers": {
"Date": "Tue, 03 Dec 2024 06:54:53 GMT",
"Date": "Tue, 03 Dec 2024 07:38:50 GMT",
"X-OAuth-Scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, admin:ssh_signing_key, audit_log, codespace, delete:packages, delete_repo, gist, project, read:packages, repo, user, workflow, write:discussion",
"X-Accepted-OAuth-Scopes": "repo",
"github-authentication-token-expiration": "2025-02-25 04:28:56 UTC",
"X-GitHub-Media-Type": "github.v3; format=json",
"x-github-api-version-selected": "2022-11-28",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4949",
"X-RateLimit-Reset": "1733209471",
"X-RateLimit-Used": "51",
"X-RateLimit-Remaining": "4968",
"X-RateLimit-Reset": "1733215115",
"X-RateLimit-Used": "32",
"X-RateLimit-Resource": "core",
"Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset",
"Access-Control-Allow-Origin": "*",
Expand All @@ -34,10 +34,10 @@
"Content-Security-Policy": "default-src 'none'",
"Vary": "Accept-Encoding, Accept, X-Requested-With",
"Server": "github.com",
"X-GitHub-Request-Id": "ABD8:25DAE6:6CEF86:7DE85D:674EAB3D"
"X-GitHub-Request-Id": "AA51:25CB59:664A36:77DE74:674EB589"
}
},
"uuid": "5f7726c7-5f1a-4f69-9fee-3d2b34dcc2ee",
"uuid": "e3c2362c-a973-4ad6-91fa-5efe8aa8c05c",
"persistent": true,
"insertionIndex": 4
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "b52b17ed-3b65-49ed-8179-e767d374d15b",
"id": "46498eb6-0cf4-48a7-ae76-a13a64665a7d",
"name": "repos_alaurant_github-api-test_autolinks",
"request": {
"url": "/repos/Alaurant/github-api-test/autolinks",
Expand All @@ -14,7 +14,7 @@
"status": 200,
"body": "[]",
"headers": {
"Date": "Tue, 03 Dec 2024 06:54:54 GMT",
"Date": "Tue, 03 Dec 2024 07:38:50 GMT",
"Content-Type": "application/json; charset=utf-8",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": "Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With",
Expand All @@ -25,9 +25,9 @@
"X-GitHub-Media-Type": "github.v3; format=json",
"x-github-api-version-selected": "2022-11-28",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4948",
"X-RateLimit-Reset": "1733209471",
"X-RateLimit-Used": "52",
"X-RateLimit-Remaining": "4967",
"X-RateLimit-Reset": "1733215115",
"X-RateLimit-Used": "33",
"X-RateLimit-Resource": "core",
"Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset",
"Access-Control-Allow-Origin": "*",
Expand All @@ -38,10 +38,10 @@
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
"Content-Security-Policy": "default-src 'none'",
"Server": "github.com",
"X-GitHub-Request-Id": "ABD9:25A8FF:6AF2EB:7BEB98:674EAB3E"
"X-GitHub-Request-Id": "AA52:25C9E5:68E849:7A7C9A:674EB58A"
}
},
"uuid": "b52b17ed-3b65-49ed-8179-e767d374d15b",
"uuid": "46498eb6-0cf4-48a7-ae76-a13a64665a7d",
"persistent": true,
"insertionIndex": 5
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"triage": true,
"pull": true
},
"temp_clone_token": "AJ7BLWE6E7DS3XCFU4IFDJTHJ2WFY",
"temp_clone_token": "AJ7BLWEMCYWAPCY2SLWSCG3HJ23KQ",
"allow_squash_merge": true,
"allow_merge_commit": true,
"allow_rebase_merge": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6cfc76cf-b384-4455-a987-1a9f887dd595",
"id": "8c382a42-5cba-408a-8e99-638371421c93",
"name": "user",
"request": {
"url": "/user",
Expand All @@ -14,7 +14,7 @@
"status": 200,
"bodyFileName": "1-user.json",
"headers": {
"Date": "Tue, 03 Dec 2024 06:54:38 GMT",
"Date": "Tue, 03 Dec 2024 07:38:35 GMT",
"Content-Type": "application/json; charset=utf-8",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": "Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With",
Expand All @@ -26,9 +26,9 @@
"X-GitHub-Media-Type": "github.v3; format=json",
"x-github-api-version-selected": "2022-11-28",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4980",
"X-RateLimit-Reset": "1733209471",
"X-RateLimit-Used": "20",
"X-RateLimit-Remaining": "4999",
"X-RateLimit-Reset": "1733215115",
"X-RateLimit-Used": "1",
"X-RateLimit-Resource": "core",
"Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset",
"Access-Control-Allow-Origin": "*",
Expand All @@ -39,10 +39,10 @@
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
"Content-Security-Policy": "default-src 'none'",
"Server": "github.com",
"X-GitHub-Request-Id": "AB83:2377CB:5F7383:6F2BD9:674EAB2E"
"X-GitHub-Request-Id": "ABFA:271404:583EF4:676428:674EB57B"
}
},
"uuid": "6cfc76cf-b384-4455-a987-1a9f887dd595",
"uuid": "8c382a42-5cba-408a-8e99-638371421c93",
"persistent": true,
"insertionIndex": 1
}
Loading

0 comments on commit a83d081

Please sign in to comment.