6
6
import org .gitlab4j .api .models .CommitRef ;
7
7
import org .gitlab4j .api .models .Diff ;
8
8
import org .gitlab4j .api .models .Project ;
9
+ import org .gitlab4j .api .utils .ISO8601 ;
9
10
import org .junit .Before ;
10
11
import org .junit .BeforeClass ;
11
12
import org .junit .FixMethodOrder ;
12
13
import org .junit .Test ;
13
14
import org .junit .runners .MethodSorters ;
14
15
15
16
import javax .ws .rs .core .Response ;
17
+
18
+ import java .text .ParseException ;
16
19
import java .util .Date ;
17
20
import java .util .List ;
18
21
@@ -75,6 +78,7 @@ public static void setup() {
75
78
}
76
79
77
80
if (problems .isEmpty ()) {
81
+
78
82
gitLabApi = new GitLabApi (ApiVersion .V4 , TEST_HOST_URL , TEST_PRIVATE_TOKEN );
79
83
80
84
try {
@@ -112,11 +116,11 @@ public void testDiff() throws GitLabApiException {
112
116
}
113
117
114
118
@ Test
115
- public void testComments () throws GitLabApiException {
119
+ public void testComments () throws GitLabApiException , ParseException {
116
120
117
121
assertNotNull (testProject );
118
122
119
- List <Commit > commits = gitLabApi .getCommitsApi ().getCommits (testProject .getId (), null , new Date ( 0 ), new Date ());
123
+ List <Commit > commits = gitLabApi .getCommitsApi ().getCommits (testProject .getId (), null , ISO8601 . toDate ( "2000-01-01" ), new Date ());
120
124
assertNotNull (commits );
121
125
assertTrue (commits .size () > 0 );
122
126
@@ -131,27 +135,28 @@ public void testComments() throws GitLabApiException {
131
135
}
132
136
133
137
@ Test
134
- public void testCommitsSince () throws GitLabApiException {
138
+ public void testCommitsSince () throws GitLabApiException , ParseException {
135
139
136
140
assertNotNull (testProject );
141
+ Date since = ISO8601 .toDate ("2000-01-01" );
137
142
138
143
List <Commit > commits = gitLabApi .getCommitsApi ().getCommits (testProject .getId (), null , new Date (), null );
139
144
assertNotNull (commits );
140
145
assertTrue (commits .isEmpty ());
141
146
142
- commits = gitLabApi .getCommitsApi ().getCommits (testProject .getId (), null , new Date ( 0 ) , new Date ());
147
+ commits = gitLabApi .getCommitsApi ().getCommits (testProject .getId (), null , since , new Date ());
143
148
assertNotNull (commits );
144
149
assertTrue (commits .size () > 0 );
145
150
146
- commits = gitLabApi .getCommitsApi ().getCommits (testProject .getId (), null , new Date ( 0 ) , new Date (), 1 , 10 );
151
+ commits = gitLabApi .getCommitsApi ().getCommits (testProject .getId (), null , since , new Date (), 1 , 10 );
147
152
assertNotNull (commits );
148
153
assertTrue (commits .size () > 0 );
149
154
150
155
Pager <Commit > pager = gitLabApi .getCommitsApi ().getCommits (testProject .getId (), null , new Date (), null , 10 );
151
156
assertNotNull (pager );
152
157
assertTrue (pager .getTotalItems () == 0 );
153
158
154
- pager = gitLabApi .getCommitsApi ().getCommits (testProject .getId (), null , new Date ( 0 ) , null , 10 );
159
+ pager = gitLabApi .getCommitsApi ().getCommits (testProject .getId (), null , since , null , 10 );
155
160
assertNotNull (pager );
156
161
assertTrue (pager .getTotalItems () > 0 );
157
162
}
@@ -170,12 +175,12 @@ public void testCommitRefs() throws GitLabApiException {
170
175
}
171
176
172
177
@ Test
173
- public void testCommitsSinceWithPath () throws GitLabApiException {
178
+ public void testCommitsSinceWithPath () throws GitLabApiException , ParseException {
174
179
175
180
assertNotNull (testProject );
176
181
177
182
List <Commit > commits = gitLabApi .getCommitsApi ().getCommits (
178
- testProject .getId (), null , new Date ( 0 ), new Date (), TEST_PROJECT_SUBDIRECTORY_PATH );
183
+ testProject .getId (), null , ISO8601 . toDate ( "2000-01-01" ), new Date (), TEST_PROJECT_SUBDIRECTORY_PATH );
179
184
assertNotNull (commits );
180
185
assertTrue (commits .size () > 0 );
181
186
}
0 commit comments