Skip to content

Commit cf58df4

Browse files
committed
Fix tests failed since ids migration from Integer to Long
1 parent 09ed795 commit cf58df4

18 files changed

+53
-50
lines changed

src/main/java/org/gitlab4j/api/AbstractApi.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ public AbstractApi(GitLabApi gitLabApi) {
3333
* Returns the project ID or path from the provided Integer, String, or Project instance.
3434
*
3535
* @param obj the object to determine the ID or path from
36-
* @return the project ID or path from the provided Integer, String, or Project instance
36+
* @return the project ID or path from the provided Long, String, or Project instance
3737
* @throws GitLabApiException if any exception occurs during execution
3838
*/
3939
public Object getProjectIdOrPath(Object obj) throws GitLabApiException {
4040

4141
if (obj == null) {
4242
throw (new RuntimeException("Cannot determine ID or path from null object"));
43-
} else if (obj instanceof Integer) {
43+
} else if (obj instanceof Long) {
4444
return (obj);
4545
} else if (obj instanceof String) {
4646
return (urlEncode(((String) obj).trim()));
@@ -60,22 +60,22 @@ public Object getProjectIdOrPath(Object obj) throws GitLabApiException {
6060

6161
} else {
6262
throw (new RuntimeException("Cannot determine ID or path from provided " + obj.getClass().getSimpleName() +
63-
" instance, must be Integer, String, or a Project instance"));
63+
" instance, must be Long, String, or a Project instance"));
6464
}
6565
}
6666

6767
/**
6868
* Returns the group ID or path from the provided Integer, String, or Group instance.
6969
*
7070
* @param obj the object to determine the ID or path from
71-
* @return the group ID or path from the provided Integer, String, or Group instance
71+
* @return the group ID or path from the provided Long, String, or Group instance
7272
* @throws GitLabApiException if any exception occurs during execution
7373
*/
7474
public Object getGroupIdOrPath(Object obj) throws GitLabApiException {
7575

7676
if (obj == null) {
7777
throw (new RuntimeException("Cannot determine ID or path from null object"));
78-
} else if (obj instanceof Integer) {
78+
} else if (obj instanceof Long) {
7979
return (obj);
8080
} else if (obj instanceof String) {
8181
return (urlEncode(((String) obj).trim()));
@@ -95,7 +95,7 @@ public Object getGroupIdOrPath(Object obj) throws GitLabApiException {
9595

9696
} else {
9797
throw (new RuntimeException("Cannot determine ID or path from provided " + obj.getClass().getSimpleName() +
98-
" instance, must be Integer, String, or a Group instance"));
98+
" instance, must be Long, String, or a Group instance"));
9999
}
100100
}
101101

@@ -110,7 +110,7 @@ public Object getUserIdOrUsername(Object obj) throws GitLabApiException {
110110

111111
if (obj == null) {
112112
throw (new RuntimeException("Cannot determine ID or username from null object"));
113-
} else if (obj instanceof Integer) {
113+
} else if (obj instanceof Long) {
114114
return (obj);
115115
} else if (obj instanceof String) {
116116
return (urlEncode(((String) obj).trim()));
@@ -145,7 +145,7 @@ public Object getLabelIdOrName(Object obj) throws GitLabApiException {
145145

146146
if (obj == null) {
147147
throw (new RuntimeException("Cannot determine ID or name from null object"));
148-
} else if (obj instanceof Integer) {
148+
} else if (obj instanceof Long) {
149149
return (obj);
150150
} else if (obj instanceof String) {
151151
return (urlEncode(((String) obj).trim()));

src/main/java/org/gitlab4j/api/GroupApi.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ public Group updateGroup(Object groupIdOrPath, String name, String path, String
642642
* @return the created Group instance
643643
* @throws GitLabApiException if any exception occurs
644644
* @deprecated Will be removed in version 5.0, replaced by {@link #addGroup(String, String, String, Visibility,
645-
* Boolean, Boolean, Integer)}
645+
* Boolean, Boolean, Long)}
646646
*/
647647
@Deprecated
648648
public Group addGroup(String name, String path, String description, Boolean membershipLock,
@@ -683,7 +683,7 @@ public Group addGroup(String name, String path, String description, Boolean memb
683683
* @return the updated Group instance
684684
* @throws GitLabApiException if any exception occurs
685685
* @deprecated Will be removed in version 5.0, replaced by {@link #updateGroup(Object, String, String, String,
686-
* Visibility, Boolean, Boolean, Integer)}
686+
* Visibility, Boolean, Boolean, Long)}
687687
*/
688688
@Deprecated
689689
public Group updateGroup(Object groupIdOrPath, String name, String path, String description, Boolean membershipLock,

src/main/java/org/gitlab4j/api/JobApi.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public Stream<Job> getJobsStream(Object projectIdOrPath, JobScope scope) throws
140140
* @throws GitLabApiException if any exception occurs during execution
141141
*/
142142
public List<Job> getJobsForPipeline(Object projectIdOrPath, int pipelineId) throws GitLabApiException {
143-
Response response = get(Response.Status.OK, getDefaultPerPageParam(),
143+
Response response = get(Response.Status.OK, getDefaultPerPageParam(),
144144
"projects", getProjectIdOrPath(projectIdOrPath), "pipelines", pipelineId, "jobs");
145145
return (response.readEntity(new GenericType<List<Job>>() {}));
146146
}
@@ -466,7 +466,7 @@ public String getTrace(Object projectIdOrPath, Long jobId) throws GitLabApiExcep
466466
* @param jobId the ID to cancel job
467467
* @return job instance which just canceled
468468
* @throws GitLabApiException if any exception occurs during execution
469-
* @deprecated replaced by {@link #cancelJob(Object, Integer)}
469+
* @deprecated replaced by {@link #cancelJob(Object, Long)}
470470
*/
471471
@Deprecated
472472
public Job cancleJob(Object projectIdOrPath, Long jobId) throws GitLabApiException {

src/main/java/org/gitlab4j/api/NotesApi.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public NotesApi(GitLabApi gitLabApi) {
2424
* @param issueIid the issue ID to get the notes for
2525
* @return a list of the issues's notes
2626
* @throws GitLabApiException if any exception occurs
27-
* @deprecated As of release 4.7.0, replaced by {@link #getIssueNotes(Object, Integer)}
27+
* @deprecated As of release 4.7.0, replaced by {@link #getIssueNotes(Object, Long)}
2828
*/
2929
@Deprecated
3030
public List<Note> getNotes(Object projectIdOrPath, Long issueIid) throws GitLabApiException {
@@ -42,7 +42,7 @@ public List<Note> getNotes(Object projectIdOrPath, Long issueIid) throws GitLabA
4242
* @param perPage the number of notes per page
4343
* @return the list of notes in the specified range
4444
* @throws GitLabApiException if any exception occurs
45-
* @deprecated As of release 4.7.0, replaced by {@link #getIssueNotes(Object, Integer, int, int)}
45+
* @deprecated As of release 4.7.0, replaced by {@link #getIssueNotes(Object, Long, int, int)}
4646
*/
4747
@Deprecated
4848
public List<Note> getNotes(Object projectIdOrPath, Long issueIid, int page, int perPage) throws GitLabApiException {
@@ -59,7 +59,7 @@ public List<Note> getNotes(Object projectIdOrPath, Long issueIid, int page, int
5959
* @param itemsPerPage the number of notes per page
6060
* @return the list of notes in the specified range
6161
* @throws GitLabApiException if any exception occurs
62-
* @deprecated As of release 4.7.0, replaced by {@link #getIssueNotes(Object, Integer, int)}
62+
* @deprecated As of release 4.7.0, replaced by {@link #getIssueNotes(Object, Long, int)}
6363
*/
6464
@Deprecated
6565
public Pager<Note> getNotes(Object projectIdOrPath, Long issueIid, int itemsPerPage) throws GitLabApiException {

src/main/java/org/gitlab4j/api/ProjectApi.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,7 @@ public Project createProject(String name, Long namespaceId, String description,
11631163
* @param importUrl The Import URL for the project, otherwise null
11641164
* @return the GitLab Project
11651165
* @throws GitLabApiException if any exception occurs
1166-
* @deprecated As of release 4.2.0, replaced by {@link #createProject(String, Integer, String, Boolean, Boolean,
1166+
* @deprecated As of release 4.2.0, replaced by {@link #createProject(String, Long, String, Boolean, Boolean,
11671167
* Boolean, Boolean, Visibility, Integer, String)}
11681168
*/
11691169
@Deprecated
@@ -2268,7 +2268,7 @@ public Stream<Issue> getIssuesStream(Object projectIdOrPath) throws GitLabApiExc
22682268
* @param issueId the internal ID of a project's issue
22692269
* @return the specified Issue instance
22702270
* @throws GitLabApiException if any exception occurs
2271-
* @deprecated Will be removed in version 5.0, replaced by {@link IssuesApi#getIssue(Object, Integer)}
2271+
* @deprecated Will be removed in version 5.0, replaced by {@link IssuesApi#getIssue(Object, Long)}
22722272
*/
22732273
@Deprecated
22742274
public Issue getIssue(Object projectIdOrPath, Long issueId) throws GitLabApiException {
@@ -2284,7 +2284,7 @@ public Issue getIssue(Object projectIdOrPath, Long issueId) throws GitLabApiExce
22842284
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance, required
22852285
* @param issueId the internal ID of a project's issue
22862286
* @throws GitLabApiException if any exception occurs
2287-
* @deprecated Will be removed in version 5.0, replaced by {@link IssuesApi#deleteIssue(Object, Integer)}
2287+
* @deprecated Will be removed in version 5.0, replaced by {@link IssuesApi#deleteIssue(Object, Long)}
22882288
*/
22892289
@Deprecated
22902290
public void deleteIssue(Object projectIdOrPath, Long issueId) throws GitLabApiException {
@@ -2605,6 +2605,8 @@ public FileUpload uploadFile(Object projectIdOrPath, File fileToUpload, String m
26052605
*
26062606
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance, required
26072607
* @param inputStream the data to upload, required
2608+
* @param filename The filename of the file to upload
2609+
* @param mediaType unused; will be removed in the next major version
26082610
* @return a FileUpload instance with information on the just uploaded file
26092611
* @throws GitLabApiException if any exception occurs
26102612
*/

src/main/java/org/gitlab4j/api/RunnersApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ public Runner enableRunner(Object projectIdOrPath, Long runnerId) throws GitLabA
476476

477477
/**
478478
* Disable a specific runner from the project. It works only if the project isn't the only project associated with
479-
* the specified runner. If so, an error is returned. Use the {@link #removeRunner(Integer)} instead.
479+
* the specified runner. If so, an error is returned. Use the {@link #removeRunner(Long)} instead.
480480
*
481481
* <pre><code>GitLab Endpoint: DELETE /projects/:id/runners/:runner_id</code></pre>
482482
*

src/main/java/org/gitlab4j/api/models/Issue.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import com.fasterxml.jackson.annotation.JsonIgnore;
1111
import com.fasterxml.jackson.annotation.JsonProperty;
12+
import com.fasterxml.jackson.databind.node.IntNode;
1213
import com.fasterxml.jackson.databind.node.LongNode;
1314
import com.fasterxml.jackson.databind.node.TextNode;
1415
import com.fasterxml.jackson.databind.node.ValueNode;
@@ -145,7 +146,7 @@ public void setActualId(ValueNode id) {
145146
actualId = id;
146147
if (actualId instanceof TextNode) {
147148
externalId = actualId.asText();
148-
} else if (actualId instanceof LongNode) {
149+
} else if (actualId instanceof IntNode || actualId instanceof LongNode) {
149150
this.id = actualId.asLong();
150151
}
151152
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,28 @@ public void setUp() throws Exception {
4040

4141
@Test
4242
public void testGetCommitDiscussionsByList() throws Exception {
43-
List<Discussion> discussions = new DiscussionsApi(gitLabApi).getCommitDiscussions(1, COMMIT_SHA);
43+
List<Discussion> discussions = new DiscussionsApi(gitLabApi).getCommitDiscussions(1L, COMMIT_SHA);
4444
assertNotNull(discussions);
4545
assertTrue(compareJson(discussions, "commit-discussions.json"));
4646
}
4747

4848
@Test
4949
public void testGetCommitDiscussionsByListWithMaxItems() throws Exception {
50-
List<Discussion> discussions = new DiscussionsApi(gitLabApi).getCommitDiscussions(1, COMMIT_SHA, 20);
50+
List<Discussion> discussions = new DiscussionsApi(gitLabApi).getCommitDiscussions(1L, COMMIT_SHA, 20);
5151
assertNotNull(discussions);
5252
assertTrue(compareJson(discussions, "commit-discussions.json"));
5353
}
5454

5555
@Test
5656
public void testGetCommitDiscussionsByPager() throws Exception {
57-
Pager<Discussion> discussions = new DiscussionsApi(gitLabApi).getCommitDiscussionsPager(1, COMMIT_SHA, 20);
57+
Pager<Discussion> discussions = new DiscussionsApi(gitLabApi).getCommitDiscussionsPager(1L, COMMIT_SHA, 20);
5858
assertNotNull(discussions);
5959
assertTrue(compareJson(discussions.all(), "commit-discussions.json"));
6060
}
6161

6262
@Test
6363
public void testGetCommitDiscussionsByStream() throws Exception {
64-
Stream<Discussion> stream = new DiscussionsApi(gitLabApi).getCommitDiscussionsStream(1, COMMIT_SHA);
64+
Stream<Discussion> stream = new DiscussionsApi(gitLabApi).getCommitDiscussionsStream(1L, COMMIT_SHA);
6565
assertNotNull(stream);
6666
List<Discussion> discussions = stream.collect(Collectors.toList());
6767
assertTrue(compareJson(discussions, "commit-discussions.json"));

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,28 +39,28 @@ public void setUp() throws Exception {
3939

4040
@Test
4141
public void testGetEpicDiscussionsByList() throws Exception {
42-
List<Discussion> discussions = new DiscussionsApi(gitLabApi).getEpicDiscussions(1, 1L);
42+
List<Discussion> discussions = new DiscussionsApi(gitLabApi).getEpicDiscussions(1L, 1L);
4343
assertNotNull(discussions);
4444
assertTrue(compareJson(discussions, "epic-discussions.json"));
4545
}
4646

4747
@Test
4848
public void testGetEpicDiscussionsByListWithMaxItems() throws Exception {
49-
List<Discussion> discussions = new DiscussionsApi(gitLabApi).getEpicDiscussions(1, 1L, 20);
49+
List<Discussion> discussions = new DiscussionsApi(gitLabApi).getEpicDiscussions(1L, 1L, 20);
5050
assertNotNull(discussions);
5151
assertTrue(compareJson(discussions, "epic-discussions.json"));
5252
}
5353

5454
@Test
5555
public void testGetEpicDiscussionsByPager() throws Exception {
56-
Pager<Discussion> discussions = new DiscussionsApi(gitLabApi).getEpicDiscussionsPager(1, 1L, 20);
56+
Pager<Discussion> discussions = new DiscussionsApi(gitLabApi).getEpicDiscussionsPager(1L, 1L, 20);
5757
assertNotNull(discussions);
5858
assertTrue(compareJson(discussions.all(), "epic-discussions.json"));
5959
}
6060

6161
@Test
6262
public void testGetEpicDiscussionsByStream() throws Exception {
63-
Stream<Discussion> stream = new DiscussionsApi(gitLabApi).getEpicDiscussionsStream(1, 1L);
63+
Stream<Discussion> stream = new DiscussionsApi(gitLabApi).getEpicDiscussionsStream(1L, 1L);
6464
assertNotNull(stream);
6565
List<Discussion> discussions = stream.collect(Collectors.toList());
6666
assertTrue(compareJson(discussions, "epic-discussions.json"));

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222

2323
/**
2424
* In order for these tests to run you must set the following properties in ~/test-gitlab4j.properties
25-
*
25+
*
2626
* TEST_NAMESPACE
2727
* TEST_HOST_URL
2828
* TEST_PRIVATE_TOKEN
29-
*
29+
*
3030
* If any of the above are NULL, all tests in this class will be skipped.
3131
*/
3232
@Category(IntegrationTest.class)
@@ -76,7 +76,7 @@ public void beforeMethod() {
7676
public void testNotFoundError() throws GitLabApiException {
7777

7878
try {
79-
gitLabApi.getProjectApi().getProject(123456789);
79+
gitLabApi.getProjectApi().getProject(123456789L);
8080
fail("GitLabApiException not thrown");
8181
} catch (GitLabApiException gae) {
8282
assertFalse(gae.hasValidationErrors());

0 commit comments

Comments
 (0)