Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GHPerson#getType() should call populate() only if type is null #2015

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/main/java/org/kohsuke/github/GHPerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,9 @@
* the io exception
*/
public String getType() throws IOException {
populate();
if (type == null) {
populate();

Check warning on line 320 in src/main/java/org/kohsuke/github/GHPerson.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/kohsuke/github/GHPerson.java#L320

Added line #L320 was not covered by tests
}
return type;
}

Expand Down
4 changes: 4 additions & 0 deletions src/test/java/org/kohsuke/github/GHAppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public void getGitHubApp() throws IOException {
assertThat(app.getId(), is((long) 82994));
assertThat(app.getOwner().getId(), is((long) 7544739));
assertThat(app.getOwner().getLogin(), is("hub4j-test-org"));
assertThat(app.getOwner().getType(), is("Organization"));
assertThat(app.getName(), is("GHApi Test app 1"));
assertThat(app.getSlug(), is("ghapi-test-app-1"));
assertThat(app.getDescription(), is(""));
Expand Down Expand Up @@ -85,8 +86,10 @@ public void listInstallationRequests() throws IOException {
assertThat(appInstallation.getId(), is((long) 1037204));
assertThat(appInstallation.getAccount().getId(), is((long) 195438329));
assertThat(appInstallation.getAccount().getLogin(), is("approval-test"));
assertThat(appInstallation.getAccount().getType(), is("Organization"));
assertThat(appInstallation.getRequester().getId(), is((long) 195437694));
assertThat(appInstallation.getRequester().getLogin(), is("kaladinstormblessed2"));
assertThat(appInstallation.getRequester().getType(), is("User"));
assertThat(appInstallation.getCreatedAt(), is(GitHubClient.parseDate("2025-01-17T15:50:51Z")));
assertThat(appInstallation.getNodeId(), is("MDMwOkludGVncmF0aW9uSW5zdGFsbGF0aW9uUmVxdWVzdDEwMzcyMDQ="));
}
Expand Down Expand Up @@ -275,6 +278,7 @@ private void testAppInstallation(GHAppInstallation appInstallation) throws IOExc
assertThat(appInstallation.getId(), is((long) 11111111));
assertThat(appAccount.getId(), is((long) 111111111));
assertThat(appAccount.login, is("bogus"));
assertThat(appAccount.getType(), is("Organization"));
assertThat(appInstallation.getRepositorySelection(), is(GHRepositorySelection.SELECTED));
assertThat(appInstallation.getAccessTokenUrl(), endsWith("/app/installations/11111111/access_tokens"));
assertThat(appInstallation.getRepositoriesUrl(), endsWith("/installation/repositories"));
Expand Down
Loading