Skip to content

Commit 7268fef

Browse files
committed
Fixed issue with since dates being too old.
1 parent 0cc484f commit 7268fef

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/test/java/org/gitlab4j/api/TestCommitsApi.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@
66
import org.gitlab4j.api.models.CommitRef;
77
import org.gitlab4j.api.models.Diff;
88
import org.gitlab4j.api.models.Project;
9+
import org.gitlab4j.api.utils.ISO8601;
910
import org.junit.Before;
1011
import org.junit.BeforeClass;
1112
import org.junit.FixMethodOrder;
1213
import org.junit.Test;
1314
import org.junit.runners.MethodSorters;
1415

1516
import javax.ws.rs.core.Response;
17+
18+
import java.text.ParseException;
1619
import java.util.Date;
1720
import java.util.List;
1821

@@ -75,6 +78,7 @@ public static void setup() {
7578
}
7679

7780
if (problems.isEmpty()) {
81+
7882
gitLabApi = new GitLabApi(ApiVersion.V4, TEST_HOST_URL, TEST_PRIVATE_TOKEN);
7983

8084
try {
@@ -112,11 +116,11 @@ public void testDiff() throws GitLabApiException {
112116
}
113117

114118
@Test
115-
public void testComments() throws GitLabApiException {
119+
public void testComments() throws GitLabApiException, ParseException {
116120

117121
assertNotNull(testProject);
118122

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());
120124
assertNotNull(commits);
121125
assertTrue(commits.size() > 0);
122126

@@ -131,27 +135,28 @@ public void testComments() throws GitLabApiException {
131135
}
132136

133137
@Test
134-
public void testCommitsSince() throws GitLabApiException {
138+
public void testCommitsSince() throws GitLabApiException, ParseException {
135139

136140
assertNotNull(testProject);
141+
Date since = ISO8601.toDate("2000-01-01");
137142

138143
List<Commit> commits = gitLabApi.getCommitsApi().getCommits(testProject.getId(), null, new Date(), null);
139144
assertNotNull(commits);
140145
assertTrue(commits.isEmpty());
141146

142-
commits = gitLabApi.getCommitsApi().getCommits(testProject.getId(), null, new Date(0), new Date());
147+
commits = gitLabApi.getCommitsApi().getCommits(testProject.getId(), null, since, new Date());
143148
assertNotNull(commits);
144149
assertTrue(commits.size() > 0);
145150

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);
147152
assertNotNull(commits);
148153
assertTrue(commits.size() > 0);
149154

150155
Pager<Commit> pager = gitLabApi.getCommitsApi().getCommits(testProject.getId(), null, new Date(), null, 10);
151156
assertNotNull(pager);
152157
assertTrue(pager.getTotalItems() == 0);
153158

154-
pager = gitLabApi.getCommitsApi().getCommits(testProject.getId(), null, new Date(0), null, 10);
159+
pager = gitLabApi.getCommitsApi().getCommits(testProject.getId(), null, since, null, 10);
155160
assertNotNull(pager);
156161
assertTrue(pager.getTotalItems() > 0);
157162
}
@@ -170,12 +175,12 @@ public void testCommitRefs() throws GitLabApiException {
170175
}
171176

172177
@Test
173-
public void testCommitsSinceWithPath() throws GitLabApiException {
178+
public void testCommitsSinceWithPath() throws GitLabApiException, ParseException {
174179

175180
assertNotNull(testProject);
176181

177182
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);
179184
assertNotNull(commits);
180185
assertTrue(commits.size() > 0);
181186
}

0 commit comments

Comments
 (0)