Skip to content

Commit

Permalink
Move GHRepositoryChanges under Repository class
Browse files Browse the repository at this point in the history
  • Loading branch information
eleanorgoh committed Apr 26, 2024
1 parent 075d627 commit c5ce1f6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
12 changes: 1 addition & 11 deletions src/main/java/org/kohsuke/github/GHEventPayload.java
Original file line number Diff line number Diff line change
Expand Up @@ -1445,17 +1445,6 @@ public void setRelease(GHRelease release) {
* @see <a href="https://docs.github.com/en/rest/reference/repos">Repositories</a>
*/
public static class Repository extends GHEventPayload {

}

/**
* A repository was renamed or transferred.
*
* @see <a href="https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#repository">
* repository event</a>
* @see <a href="https://docs.github.com/en/rest/reference/repos">Repositories</a>
*/
public static class RepositoryChanges extends GHEventPayload {
private GHRepositoryChanges changes;

/**
Expand All @@ -1466,6 +1455,7 @@ public static class RepositoryChanges extends GHEventPayload {
public GHRepositoryChanges getChanges() {
return changes;
}

}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/test/java/org/kohsuke/github/GHEventPayloadTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -780,8 +780,8 @@ public void repository() throws Exception {
*/
@Test
public void repository_renamed() throws Exception {
final GHEventPayload.RepositoryChanges event = GitHub.offline()
.parseEventPayload(payload.asReader(), GHEventPayload.RepositoryChanges.class);
final GHEventPayload.Repository event = GitHub.offline()
.parseEventPayload(payload.asReader(), GHEventPayload.Repository.class);
assertThat(event.getAction(), is("renamed"));
assertThat(event.getChanges().getRepository().getName().getFrom(), is("react-workshop"));
assertThat(event.getRepository().getName(), is("react-workshop-renamed"));
Expand All @@ -798,8 +798,8 @@ public void repository_renamed() throws Exception {
*/
@Test
public void repository_transferred_to_org() throws Exception {
final GHEventPayload.RepositoryChanges event = GitHub.offline()
.parseEventPayload(payload.asReader(), GHEventPayload.RepositoryChanges.class);
final GHEventPayload.Repository event = GitHub.offline()
.parseEventPayload(payload.asReader(), GHEventPayload.Repository.class);
assertThat(event.getAction(), is("transferred"));
assertThat(event.getChanges().getOwner().getFrom().getUser().getLogin(), is("eleanorgoh"));
assertThat(event.getChanges().getOwner().getFrom().getUser().getId(), is(66235606L));
Expand All @@ -814,8 +814,8 @@ public void repository_transferred_to_org() throws Exception {
*/
@Test
public void repository_transferred_to_user() throws Exception {
final GHEventPayload.RepositoryChanges event = GitHub.offline()
.parseEventPayload(payload.asReader(), GHEventPayload.RepositoryChanges.class);
final GHEventPayload.Repository event = GitHub.offline()
.parseEventPayload(payload.asReader(), GHEventPayload.Repository.class);
assertThat(event.getAction(), is("transferred"));
assertThat(event.getChanges().getOwner().getFrom().getOrganization().getLogin(), is("EJG-Organization"));
assertThat(event.getChanges().getOwner().getFrom().getOrganization().getId(), is(168135412L));
Expand Down

0 comments on commit c5ce1f6

Please sign in to comment.