44import org .apache .commons .io .IOUtils ;
55import org .junit .Assert ;
66import org .junit .Test ;
7- import org .kohsuke .github .GHRepositoryCloneTraffic .DayInfo ;
8- import org .kohsuke .github .GHRepositoryViewTraffic .Daily ;
97import org .mockito .Mockito ;
108
119import java .io .IOException ;
@@ -22,29 +20,29 @@ public class RepositoryTrafficTest {
2220 final private String login = "kohsuke" , repositoryName = "github-api" ;
2321
2422 @ SuppressWarnings ("unchecked" )
25- private <T extends GHRepositoryTrafficInfo > void checkResponse (T expected , T actual ){
23+ private <T extends GHRepositoryTraffic > void checkResponse (T expected , T actual ){
2624 Assert .assertEquals (expected .getCount (), actual .getCount ());
2725 Assert .assertEquals (expected .getUniques (), actual .getUniques ());
2826
29- List <? extends GHRepositoryTrafficInfo . DayInfo > expectedList = expected .getDailyInfo ();
30- List <? extends GHRepositoryTrafficInfo . DayInfo > actualList = actual .getDailyInfo ();
31- Iterator <? extends GHRepositoryTrafficInfo . DayInfo > expectedIt ;
32- Iterator <? extends GHRepositoryTrafficInfo . DayInfo > actualIt ;
27+ List <? extends DailyInfo > expectedList = expected .getDailyInfo ();
28+ List <? extends DailyInfo > actualList = actual .getDailyInfo ();
29+ Iterator <? extends DailyInfo > expectedIt ;
30+ Iterator <? extends DailyInfo > actualIt ;
3331
3432 Assert .assertEquals (expectedList .size (), actualList .size ());
3533 expectedIt = expectedList .iterator ();
3634 actualIt = actualList .iterator ();
3735
3836 while (expectedIt .hasNext () && actualIt .hasNext ()) {
39- GHRepositoryTrafficInfo . DayInfo expectedDayInfo = expectedIt .next ();
40- GHRepositoryTrafficInfo . DayInfo actualDayInfo = actualIt .next ();
41- Assert .assertEquals (expectedDayInfo .getCount (), actualDayInfo .getCount ());
42- Assert .assertEquals (expectedDayInfo .getUniques (), actualDayInfo .getUniques ());
43- Assert .assertEquals (expectedDayInfo .getTimestamp (), actualDayInfo .getTimestamp ());
37+ DailyInfo expectedDailyInfo = expectedIt .next ();
38+ DailyInfo actualDailyInfo = actualIt .next ();
39+ Assert .assertEquals (expectedDailyInfo .getCount (), actualDailyInfo .getCount ());
40+ Assert .assertEquals (expectedDailyInfo .getUniques (), actualDailyInfo .getUniques ());
41+ Assert .assertEquals (expectedDailyInfo .getTimestamp (), actualDailyInfo .getTimestamp ());
4442 }
4543 }
4644
47- private <T extends GHRepositoryTrafficInfo > void testTraffic (T expectedResult ) throws IOException {
45+ private <T extends GHRepositoryTraffic > void testTraffic (T expectedResult ) throws IOException {
4846 SimpleDateFormat dateFormat =new SimpleDateFormat ("yyyy-MM-dd'T'HH:mm:ss'Z'" );
4947 dateFormat .setTimeZone (TimeZone .getTimeZone ("GMT" ));
5048 ObjectMapper mapper = new ObjectMapper ().setDateFormat (dateFormat );
@@ -101,21 +99,21 @@ public void testGetViews() throws IOException{
10199 21523359 ,
102100 65534 ,
103101 Arrays .asList (
104- new Daily ("2016-10-10T00:00:00Z" , 3 , 2 ),
105- new Daily ("2016-10-11T00:00:00Z" , 9 , 4 ),
106- new Daily ("2016-10-12T00:00:00Z" , 27 , 8 ),
107- new Daily ("2016-10-13T00:00:00Z" , 81 , 16 ),
108- new Daily ("2016-10-14T00:00:00Z" , 243 , 32 ),
109- new Daily ("2016-10-15T00:00:00Z" , 729 , 64 ),
110- new Daily ("2016-10-16T00:00:00Z" , 2187 , 128 ),
111- new Daily ("2016-10-17T00:00:00Z" , 6561 , 256 ),
112- new Daily ("2016-10-18T00:00:00Z" , 19683 , 512 ),
113- new Daily ("2016-10-19T00:00:00Z" , 59049 , 1024 ),
114- new Daily ("2016-10-20T00:00:00Z" , 177147 , 2048 ),
115- new Daily ("2016-10-21T00:00:00Z" , 531441 , 4096 ),
116- new Daily ("2016-10-22T00:00:00Z" , 1594323 , 8192 ),
117- new Daily ("2016-10-23T00:00:00Z" , 4782969 , 16384 ),
118- new Daily ("2016-10-24T00:00:00Z" , 14348907 , 32768 )
102+ new GHRepositoryViewTraffic . DailyInfo ("2016-10-10T00:00:00Z" , 3 , 2 ),
103+ new GHRepositoryViewTraffic . DailyInfo ("2016-10-11T00:00:00Z" , 9 , 4 ),
104+ new GHRepositoryViewTraffic . DailyInfo ("2016-10-12T00:00:00Z" , 27 , 8 ),
105+ new GHRepositoryViewTraffic . DailyInfo ("2016-10-13T00:00:00Z" , 81 , 16 ),
106+ new GHRepositoryViewTraffic . DailyInfo ("2016-10-14T00:00:00Z" , 243 , 32 ),
107+ new GHRepositoryViewTraffic . DailyInfo ("2016-10-15T00:00:00Z" , 729 , 64 ),
108+ new GHRepositoryViewTraffic . DailyInfo ("2016-10-16T00:00:00Z" , 2187 , 128 ),
109+ new GHRepositoryViewTraffic . DailyInfo ("2016-10-17T00:00:00Z" , 6561 , 256 ),
110+ new GHRepositoryViewTraffic . DailyInfo ("2016-10-18T00:00:00Z" , 19683 , 512 ),
111+ new GHRepositoryViewTraffic . DailyInfo ("2016-10-19T00:00:00Z" , 59049 , 1024 ),
112+ new GHRepositoryViewTraffic . DailyInfo ("2016-10-20T00:00:00Z" , 177147 , 2048 ),
113+ new GHRepositoryViewTraffic . DailyInfo ("2016-10-21T00:00:00Z" , 531441 , 4096 ),
114+ new GHRepositoryViewTraffic . DailyInfo ("2016-10-22T00:00:00Z" , 1594323 , 8192 ),
115+ new GHRepositoryViewTraffic . DailyInfo ("2016-10-23T00:00:00Z" , 4782969 , 16384 ),
116+ new GHRepositoryViewTraffic . DailyInfo ("2016-10-24T00:00:00Z" , 14348907 , 32768 )
119117 )
120118 );
121119 testTraffic (expectedResult );
@@ -127,21 +125,21 @@ public void testGetClones() throws IOException{
127125 1500 ,
128126 455 ,
129127 Arrays .asList (
130- new DayInfo ("2016-10-10T00:00:00Z" , 10 ,3 ),
131- new DayInfo ("2016-10-11T00:00:00Z" , 20 ,6 ),
132- new DayInfo ("2016-10-12T00:00:00Z" , 30 ,5 ),
133- new DayInfo ("2016-10-13T00:00:00Z" , 40 ,7 ),
134- new DayInfo ("2016-10-14T00:00:00Z" , 50 ,11 ),
135- new DayInfo ("2016-10-15T00:00:00Z" , 60 ,12 ),
136- new DayInfo ("2016-10-16T00:00:00Z" , 70 ,19 ),
137- new DayInfo ("2016-10-17T00:00:00Z" , 170 ,111 ),
138- new DayInfo ("2016-10-18T00:00:00Z" , 180 ,70 ),
139- new DayInfo ("2016-10-19T00:00:00Z" , 190 ,10 ),
140- new DayInfo ("2016-10-20T00:00:00Z" , 200 ,18 ),
141- new DayInfo ("2016-10-21T00:00:00Z" , 210 ,8 ),
142- new DayInfo ("2016-10-22T00:00:00Z" , 220 ,168 ),
143- new DayInfo ("2016-10-23T00:00:00Z" , 5 ,2 ),
144- new DayInfo ("2016-10-24T00:00:00Z" , 45 ,5 )
128+ new GHRepositoryCloneTraffic . DailyInfo ("2016-10-10T00:00:00Z" , 10 ,3 ),
129+ new GHRepositoryCloneTraffic . DailyInfo ("2016-10-11T00:00:00Z" , 20 ,6 ),
130+ new GHRepositoryCloneTraffic . DailyInfo ("2016-10-12T00:00:00Z" , 30 ,5 ),
131+ new GHRepositoryCloneTraffic . DailyInfo ("2016-10-13T00:00:00Z" , 40 ,7 ),
132+ new GHRepositoryCloneTraffic . DailyInfo ("2016-10-14T00:00:00Z" , 50 ,11 ),
133+ new GHRepositoryCloneTraffic . DailyInfo ("2016-10-15T00:00:00Z" , 60 ,12 ),
134+ new GHRepositoryCloneTraffic . DailyInfo ("2016-10-16T00:00:00Z" , 70 ,19 ),
135+ new GHRepositoryCloneTraffic . DailyInfo ("2016-10-17T00:00:00Z" , 170 ,111 ),
136+ new GHRepositoryCloneTraffic . DailyInfo ("2016-10-18T00:00:00Z" , 180 ,70 ),
137+ new GHRepositoryCloneTraffic . DailyInfo ("2016-10-19T00:00:00Z" , 190 ,10 ),
138+ new GHRepositoryCloneTraffic . DailyInfo ("2016-10-20T00:00:00Z" , 200 ,18 ),
139+ new GHRepositoryCloneTraffic . DailyInfo ("2016-10-21T00:00:00Z" , 210 ,8 ),
140+ new GHRepositoryCloneTraffic . DailyInfo ("2016-10-22T00:00:00Z" , 220 ,168 ),
141+ new GHRepositoryCloneTraffic . DailyInfo ("2016-10-23T00:00:00Z" , 5 ,2 ),
142+ new GHRepositoryCloneTraffic . DailyInfo ("2016-10-24T00:00:00Z" , 45 ,5 )
145143 )
146144 );
147145 testTraffic (expectedResult );
0 commit comments