Skip to content

Commit e685367

Browse files
committed
Refactor
1 parent f8afbbb commit e685367

File tree

3 files changed

+112
-46
lines changed

3 files changed

+112
-46
lines changed

src/main/java/org/kohsuke/github/GHEventPayload.java

Lines changed: 5 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,55 +1458,14 @@ public static class Repository extends GHEventPayload {
14581458
public static class RepositoryChanges extends GHEventPayload {
14591459
private GHRepositoryChanges changes;
14601460

1461+
/**
1462+
* Get changes.
1463+
*
1464+
* @return GHRepositoryChanges
1465+
*/
14611466
public GHRepositoryChanges getChanges() {
14621467
return changes;
14631468
}
1464-
1465-
public static class GHRepositoryChanges {
1466-
private FromRepository repository;
1467-
private Owner owner;
1468-
1469-
public Owner getOwner() {
1470-
return owner;
1471-
}
1472-
1473-
public static class Owner {
1474-
private FromOwner from;
1475-
1476-
public FromOwner getFrom() {
1477-
return from;
1478-
}
1479-
}
1480-
1481-
public static class FromOwner {
1482-
private GHUser user;
1483-
1484-
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
1485-
public GHUser getUser() {
1486-
return user;
1487-
}
1488-
}
1489-
1490-
public FromRepository getRepository() {
1491-
return repository;
1492-
}
1493-
1494-
public static class FromRepository {
1495-
private FromName name;
1496-
1497-
public FromName getName() {
1498-
return name;
1499-
}
1500-
}
1501-
1502-
public static class FromName {
1503-
private String from;
1504-
1505-
public String getFrom() {
1506-
return from;
1507-
}
1508-
}
1509-
}
15101469
}
15111470

15121471
/**
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
package org.kohsuke.github;
2+
3+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
4+
5+
/**
6+
* Changes made to a repository.
7+
*/
8+
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "JSON API")
9+
public class GHRepositoryChanges {
10+
private FromRepository repository;
11+
private Owner owner;
12+
13+
/**
14+
* Get outer owner object.
15+
*
16+
* @return Owner
17+
*/
18+
public Owner getOwner() {
19+
return owner;
20+
}
21+
22+
/**
23+
* Outer object of owner from whom this repository was transferred.
24+
*/
25+
public static class Owner {
26+
private FromOwner from;
27+
28+
/**
29+
* Get in owner object.
30+
*
31+
* @return FromOwner
32+
*/
33+
public FromOwner getFrom() {
34+
return from;
35+
}
36+
}
37+
38+
/**
39+
* Owner from whom this repository was transferred.
40+
*/
41+
public static class FromOwner {
42+
private GHUser user;
43+
44+
/**
45+
* Get user from which this repository was transferrred.
46+
*
47+
* @return user
48+
*/
49+
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
50+
public GHUser getUser() {
51+
return user;
52+
}
53+
}
54+
55+
/**
56+
* Get repository.
57+
*
58+
* @return FromRepository
59+
*/
60+
public FromRepository getRepository() {
61+
return repository;
62+
}
63+
64+
/**
65+
* Repository object from which the name was changed.
66+
*/
67+
public static class FromRepository {
68+
private FromName name;
69+
70+
/**
71+
* Get top level object for the previous name of the repository.
72+
*
73+
* @return FromName
74+
*/
75+
public FromName getName() {
76+
return name;
77+
}
78+
}
79+
80+
/**
81+
* Repository name that was changed.
82+
*/
83+
public static class FromName {
84+
private String from;
85+
86+
/**
87+
* Get previous name of the repository before rename.
88+
*
89+
* @return String
90+
*/
91+
public String getFrom() {
92+
return from;
93+
}
94+
}
95+
}

src/test/java/org/kohsuke/github/GHEventPayloadTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,12 @@ public void repository() throws Exception {
772772
assertThat(event.getSender().getLogin(), is("baxterthehacker"));
773773
}
774774

775+
/**
776+
* Repository renamed.
777+
*
778+
* @throws Exception
779+
* the exception
780+
*/
775781
@Test
776782
public void repository_renamed() throws Exception {
777783
final GHEventPayload.RepositoryChanges event = GitHub.offline()
@@ -784,6 +790,12 @@ public void repository_renamed() throws Exception {
784790
assertThat(event.getSender().getLogin(), is("egoh"));
785791
}
786792

793+
/**
794+
* Repository ownership transferred.
795+
*
796+
* @throws Exception
797+
* the exception
798+
*/
787799
@Test
788800
public void repository_transferred() throws Exception {
789801
final GHEventPayload.RepositoryChanges event = GitHub.offline()

0 commit comments

Comments
 (0)