Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
cf58df40
Unverified
Commit
cf58df40
authored
Mar 15, 2022
by
Gautier de Saint Martin Lacaze
Browse files
Fix tests failed since ids migration from Integer to Long
parent
09ed795b
Changes
18
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/AbstractApi.java
View file @
cf58df40
...
...
@@ -33,14 +33,14 @@ public abstract class AbstractApi implements Constants {
* Returns the project ID or path from the provided Integer, String, or Project instance.
*
* @param obj the object to determine the ID or path from
* @return the project ID or path from the provided
Integer
, String, or Project instance
* @return the project ID or path from the provided
Long
, String, or Project instance
* @throws GitLabApiException if any exception occurs during execution
*/
public
Object
getProjectIdOrPath
(
Object
obj
)
throws
GitLabApiException
{
if
(
obj
==
null
)
{
throw
(
new
RuntimeException
(
"Cannot determine ID or path from null object"
));
}
else
if
(
obj
instanceof
Integer
)
{
}
else
if
(
obj
instanceof
Long
)
{
return
(
obj
);
}
else
if
(
obj
instanceof
String
)
{
return
(
urlEncode
(((
String
)
obj
).
trim
()));
...
...
@@ -60,7 +60,7 @@ public abstract class AbstractApi implements Constants {
}
else
{
throw
(
new
RuntimeException
(
"Cannot determine ID or path from provided "
+
obj
.
getClass
().
getSimpleName
()
+
" instance, must be
Integer
, String, or a Project instance"
));
" instance, must be
Long
, String, or a Project instance"
));
}
}
...
...
@@ -68,14 +68,14 @@ public abstract class AbstractApi implements Constants {
* Returns the group ID or path from the provided Integer, String, or Group instance.
*
* @param obj the object to determine the ID or path from
* @return the group ID or path from the provided
Integer
, String, or Group instance
* @return the group ID or path from the provided
Long
, String, or Group instance
* @throws GitLabApiException if any exception occurs during execution
*/
public
Object
getGroupIdOrPath
(
Object
obj
)
throws
GitLabApiException
{
if
(
obj
==
null
)
{
throw
(
new
RuntimeException
(
"Cannot determine ID or path from null object"
));
}
else
if
(
obj
instanceof
Integer
)
{
}
else
if
(
obj
instanceof
Long
)
{
return
(
obj
);
}
else
if
(
obj
instanceof
String
)
{
return
(
urlEncode
(((
String
)
obj
).
trim
()));
...
...
@@ -95,7 +95,7 @@ public abstract class AbstractApi implements Constants {
}
else
{
throw
(
new
RuntimeException
(
"Cannot determine ID or path from provided "
+
obj
.
getClass
().
getSimpleName
()
+
" instance, must be
Integer
, String, or a Group instance"
));
" instance, must be
Long
, String, or a Group instance"
));
}
}
...
...
@@ -110,7 +110,7 @@ public abstract class AbstractApi implements Constants {
if
(
obj
==
null
)
{
throw
(
new
RuntimeException
(
"Cannot determine ID or username from null object"
));
}
else
if
(
obj
instanceof
Integer
)
{
}
else
if
(
obj
instanceof
Long
)
{
return
(
obj
);
}
else
if
(
obj
instanceof
String
)
{
return
(
urlEncode
(((
String
)
obj
).
trim
()));
...
...
@@ -145,7 +145,7 @@ public abstract class AbstractApi implements Constants {
if
(
obj
==
null
)
{
throw
(
new
RuntimeException
(
"Cannot determine ID or name from null object"
));
}
else
if
(
obj
instanceof
Integer
)
{
}
else
if
(
obj
instanceof
Long
)
{
return
(
obj
);
}
else
if
(
obj
instanceof
String
)
{
return
(
urlEncode
(((
String
)
obj
).
trim
()));
...
...
src/main/java/org/gitlab4j/api/GroupApi.java
View file @
cf58df40
...
...
@@ -642,7 +642,7 @@ public class GroupApi extends AbstractApi {
* @return the created Group instance
* @throws GitLabApiException if any exception occurs
* @deprecated Will be removed in version 5.0, replaced by {@link #addGroup(String, String, String, Visibility,
* Boolean, Boolean,
Integer
)}
* Boolean, Boolean,
Long
)}
*/
@Deprecated
public
Group
addGroup
(
String
name
,
String
path
,
String
description
,
Boolean
membershipLock
,
...
...
@@ -683,7 +683,7 @@ public class GroupApi extends AbstractApi {
* @return the updated Group instance
* @throws GitLabApiException if any exception occurs
* @deprecated Will be removed in version 5.0, replaced by {@link #updateGroup(Object, String, String, String,
* Visibility, Boolean, Boolean,
Integer
)}
* Visibility, Boolean, Boolean,
Long
)}
*/
@Deprecated
public
Group
updateGroup
(
Object
groupIdOrPath
,
String
name
,
String
path
,
String
description
,
Boolean
membershipLock
,
...
...
src/main/java/org/gitlab4j/api/JobApi.java
View file @
cf58df40
...
...
@@ -140,7 +140,7 @@ public class JobApi extends AbstractApi implements Constants {
* @throws GitLabApiException if any exception occurs during execution
*/
public
List
<
Job
>
getJobsForPipeline
(
Object
projectIdOrPath
,
int
pipelineId
)
throws
GitLabApiException
{
Response
response
=
get
(
Response
.
Status
.
OK
,
getDefaultPerPageParam
(),
Response
response
=
get
(
Response
.
Status
.
OK
,
getDefaultPerPageParam
(),
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"pipelines"
,
pipelineId
,
"jobs"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Job
>>()
{}));
}
...
...
@@ -466,7 +466,7 @@ public class JobApi extends AbstractApi implements Constants {
* @param jobId the ID to cancel job
* @return job instance which just canceled
* @throws GitLabApiException if any exception occurs during execution
* @deprecated replaced by {@link #cancelJob(Object,
Integer
)}
* @deprecated replaced by {@link #cancelJob(Object,
Long
)}
*/
@Deprecated
public
Job
cancleJob
(
Object
projectIdOrPath
,
Long
jobId
)
throws
GitLabApiException
{
...
...
src/main/java/org/gitlab4j/api/NotesApi.java
View file @
cf58df40
...
...
@@ -24,7 +24,7 @@ public class NotesApi extends AbstractApi {
* @param issueIid the issue ID to get the notes for
* @return a list of the issues's notes
* @throws GitLabApiException if any exception occurs
* @deprecated As of release 4.7.0, replaced by {@link #getIssueNotes(Object,
Integer
)}
* @deprecated As of release 4.7.0, replaced by {@link #getIssueNotes(Object,
Long
)}
*/
@Deprecated
public
List
<
Note
>
getNotes
(
Object
projectIdOrPath
,
Long
issueIid
)
throws
GitLabApiException
{
...
...
@@ -42,7 +42,7 @@ public class NotesApi extends AbstractApi {
* @param perPage the number of notes per page
* @return the list of notes in the specified range
* @throws GitLabApiException if any exception occurs
* @deprecated As of release 4.7.0, replaced by {@link #getIssueNotes(Object,
Integer
, int, int)}
* @deprecated As of release 4.7.0, replaced by {@link #getIssueNotes(Object,
Long
, int, int)}
*/
@Deprecated
public
List
<
Note
>
getNotes
(
Object
projectIdOrPath
,
Long
issueIid
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
...
...
@@ -59,7 +59,7 @@ public class NotesApi extends AbstractApi {
* @param itemsPerPage the number of notes per page
* @return the list of notes in the specified range
* @throws GitLabApiException if any exception occurs
* @deprecated As of release 4.7.0, replaced by {@link #getIssueNotes(Object,
Integer
, int)}
* @deprecated As of release 4.7.0, replaced by {@link #getIssueNotes(Object,
Long
, int)}
*/
@Deprecated
public
Pager
<
Note
>
getNotes
(
Object
projectIdOrPath
,
Long
issueIid
,
int
itemsPerPage
)
throws
GitLabApiException
{
...
...
src/main/java/org/gitlab4j/api/ProjectApi.java
View file @
cf58df40
...
...
@@ -1163,7 +1163,7 @@ public class ProjectApi extends AbstractApi implements Constants {
* @param importUrl The Import URL for the project, otherwise null
* @return the GitLab Project
* @throws GitLabApiException if any exception occurs
* @deprecated As of release 4.2.0, replaced by {@link #createProject(String,
Integer
, String, Boolean, Boolean,
* @deprecated As of release 4.2.0, replaced by {@link #createProject(String,
Long
, String, Boolean, Boolean,
* Boolean, Boolean, Visibility, Integer, String)}
*/
@Deprecated
...
...
@@ -2268,7 +2268,7 @@ public class ProjectApi extends AbstractApi implements Constants {
* @param issueId the internal ID of a project's issue
* @return the specified Issue instance
* @throws GitLabApiException if any exception occurs
* @deprecated Will be removed in version 5.0, replaced by {@link IssuesApi#getIssue(Object,
Integer
)}
* @deprecated Will be removed in version 5.0, replaced by {@link IssuesApi#getIssue(Object,
Long
)}
*/
@Deprecated
public
Issue
getIssue
(
Object
projectIdOrPath
,
Long
issueId
)
throws
GitLabApiException
{
...
...
@@ -2284,7 +2284,7 @@ public class ProjectApi extends AbstractApi implements Constants {
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance, required
* @param issueId the internal ID of a project's issue
* @throws GitLabApiException if any exception occurs
* @deprecated Will be removed in version 5.0, replaced by {@link IssuesApi#deleteIssue(Object,
Integer
)}
* @deprecated Will be removed in version 5.0, replaced by {@link IssuesApi#deleteIssue(Object,
Long
)}
*/
@Deprecated
public
void
deleteIssue
(
Object
projectIdOrPath
,
Long
issueId
)
throws
GitLabApiException
{
...
...
@@ -2605,6 +2605,8 @@ public class ProjectApi extends AbstractApi implements Constants {
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance, required
* @param inputStream the data to upload, required
* @param filename The filename of the file to upload
* @param mediaType unused; will be removed in the next major version
* @return a FileUpload instance with information on the just uploaded file
* @throws GitLabApiException if any exception occurs
*/
...
...
src/main/java/org/gitlab4j/api/RunnersApi.java
View file @
cf58df40
...
...
@@ -476,7 +476,7 @@ public class RunnersApi extends AbstractApi {
/**
* Disable a specific runner from the project. It works only if the project isn't the only project associated with
* the specified runner. If so, an error is returned. Use the {@link #removeRunner(
Integer
)} instead.
* the specified runner. If so, an error is returned. Use the {@link #removeRunner(
Long
)} instead.
*
* <pre><code>GitLab Endpoint: DELETE /projects/:id/runners/:runner_id</code></pre>
*
...
...
src/main/java/org/gitlab4j/api/models/Issue.java
View file @
cf58df40
...
...
@@ -9,6 +9,7 @@ import org.gitlab4j.api.utils.JacksonJson;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.fasterxml.jackson.databind.node.IntNode
;
import
com.fasterxml.jackson.databind.node.LongNode
;
import
com.fasterxml.jackson.databind.node.TextNode
;
import
com.fasterxml.jackson.databind.node.ValueNode
;
...
...
@@ -145,7 +146,7 @@ public class Issue {
actualId
=
id
;
if
(
actualId
instanceof
TextNode
)
{
externalId
=
actualId
.
asText
();
}
else
if
(
actualId
instanceof
LongNode
)
{
}
else
if
(
actualId
instanceof
IntNode
||
actualId
instanceof
LongNode
)
{
this
.
id
=
actualId
.
asLong
();
}
}
...
...
src/test/java/org/gitlab4j/api/TestCommitDiscussionsApi.java
View file @
cf58df40
...
...
@@ -40,28 +40,28 @@ public class TestCommitDiscussionsApi implements Constants {
@Test
public
void
testGetCommitDiscussionsByList
()
throws
Exception
{
List
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getCommitDiscussions
(
1
,
COMMIT_SHA
);
List
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getCommitDiscussions
(
1
L
,
COMMIT_SHA
);
assertNotNull
(
discussions
);
assertTrue
(
compareJson
(
discussions
,
"commit-discussions.json"
));
}
@Test
public
void
testGetCommitDiscussionsByListWithMaxItems
()
throws
Exception
{
List
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getCommitDiscussions
(
1
,
COMMIT_SHA
,
20
);
List
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getCommitDiscussions
(
1
L
,
COMMIT_SHA
,
20
);
assertNotNull
(
discussions
);
assertTrue
(
compareJson
(
discussions
,
"commit-discussions.json"
));
}
@Test
public
void
testGetCommitDiscussionsByPager
()
throws
Exception
{
Pager
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getCommitDiscussionsPager
(
1
,
COMMIT_SHA
,
20
);
Pager
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getCommitDiscussionsPager
(
1
L
,
COMMIT_SHA
,
20
);
assertNotNull
(
discussions
);
assertTrue
(
compareJson
(
discussions
.
all
(),
"commit-discussions.json"
));
}
@Test
public
void
testGetCommitDiscussionsByStream
()
throws
Exception
{
Stream
<
Discussion
>
stream
=
new
DiscussionsApi
(
gitLabApi
).
getCommitDiscussionsStream
(
1
,
COMMIT_SHA
);
Stream
<
Discussion
>
stream
=
new
DiscussionsApi
(
gitLabApi
).
getCommitDiscussionsStream
(
1
L
,
COMMIT_SHA
);
assertNotNull
(
stream
);
List
<
Discussion
>
discussions
=
stream
.
collect
(
Collectors
.
toList
());
assertTrue
(
compareJson
(
discussions
,
"commit-discussions.json"
));
...
...
src/test/java/org/gitlab4j/api/TestEpicDiscussionsApi.java
View file @
cf58df40
...
...
@@ -39,28 +39,28 @@ public class TestEpicDiscussionsApi implements Constants {
@Test
public
void
testGetEpicDiscussionsByList
()
throws
Exception
{
List
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getEpicDiscussions
(
1
,
1L
);
List
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getEpicDiscussions
(
1
L
,
1L
);
assertNotNull
(
discussions
);
assertTrue
(
compareJson
(
discussions
,
"epic-discussions.json"
));
}
@Test
public
void
testGetEpicDiscussionsByListWithMaxItems
()
throws
Exception
{
List
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getEpicDiscussions
(
1
,
1L
,
20
);
List
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getEpicDiscussions
(
1
L
,
1L
,
20
);
assertNotNull
(
discussions
);
assertTrue
(
compareJson
(
discussions
,
"epic-discussions.json"
));
}
@Test
public
void
testGetEpicDiscussionsByPager
()
throws
Exception
{
Pager
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getEpicDiscussionsPager
(
1
,
1L
,
20
);
Pager
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getEpicDiscussionsPager
(
1
L
,
1L
,
20
);
assertNotNull
(
discussions
);
assertTrue
(
compareJson
(
discussions
.
all
(),
"epic-discussions.json"
));
}
@Test
public
void
testGetEpicDiscussionsByStream
()
throws
Exception
{
Stream
<
Discussion
>
stream
=
new
DiscussionsApi
(
gitLabApi
).
getEpicDiscussionsStream
(
1
,
1L
);
Stream
<
Discussion
>
stream
=
new
DiscussionsApi
(
gitLabApi
).
getEpicDiscussionsStream
(
1
L
,
1L
);
assertNotNull
(
stream
);
List
<
Discussion
>
discussions
=
stream
.
collect
(
Collectors
.
toList
());
assertTrue
(
compareJson
(
discussions
,
"epic-discussions.json"
));
...
...
src/test/java/org/gitlab4j/api/TestGitLabApiException.java
View file @
cf58df40
...
...
@@ -22,11 +22,11 @@ import org.junit.experimental.categories.Category;
/**
* In order for these tests to run you must set the following properties in ~/test-gitlab4j.properties
*
*
* TEST_NAMESPACE
* TEST_HOST_URL
* TEST_PRIVATE_TOKEN
*
*
* If any of the above are NULL, all tests in this class will be skipped.
*/
@Category
(
IntegrationTest
.
class
)
...
...
@@ -76,7 +76,7 @@ public class TestGitLabApiException extends AbstractIntegrationTest {
public
void
testNotFoundError
()
throws
GitLabApiException
{
try
{
gitLabApi
.
getProjectApi
().
getProject
(
123456789
);
gitLabApi
.
getProjectApi
().
getProject
(
123456789
L
);
fail
(
"GitLabApiException not thrown"
);
}
catch
(
GitLabApiException
gae
)
{
assertFalse
(
gae
.
hasValidationErrors
());
...
...
src/test/java/org/gitlab4j/api/TestGroupApi.java
View file @
cf58df40
...
...
@@ -189,7 +189,7 @@ public class TestGroupApi extends AbstractIntegrationTest {
assertTrue
(
optional
.
isPresent
());
assertEquals
(
testGroup
.
getId
(),
optional
.
get
().
getId
());
optional
=
gitLabApi
.
getGroupApi
().
getOptionalGroup
(
12345
);
optional
=
gitLabApi
.
getGroupApi
().
getOptionalGroup
(
12345
L
);
assertNotNull
(
optional
);
assertFalse
(
optional
.
isPresent
());
assertEquals
(
Response
.
Status
.
NOT_FOUND
.
getStatusCode
(),
GitLabApi
.
getOptionalException
(
optional
).
getHttpStatus
());
...
...
src/test/java/org/gitlab4j/api/TestIssueDiscussionsApi.java
View file @
cf58df40
...
...
@@ -39,28 +39,28 @@ public class TestIssueDiscussionsApi implements Constants {
@Test
public
void
testGetIssueDiscussionsByList
()
throws
Exception
{
List
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getIssueDiscussions
(
1
,
1L
);
List
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getIssueDiscussions
(
1
L
,
1L
);
assertNotNull
(
discussions
);
assertTrue
(
compareJson
(
discussions
,
"issue-discussions.json"
));
}
@Test
public
void
testGetIssueDiscussionsByListWithMaxItems
()
throws
Exception
{
List
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getIssueDiscussions
(
1
,
1L
,
20
);
List
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getIssueDiscussions
(
1
L
,
1L
,
20
);
assertNotNull
(
discussions
);
assertTrue
(
compareJson
(
discussions
,
"issue-discussions.json"
));
}
@Test
public
void
testGetIssueDiscussionsByPager
()
throws
Exception
{
Pager
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getIssueDiscussionsPager
(
1
,
1L
,
20
);
Pager
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getIssueDiscussionsPager
(
1
L
,
1L
,
20
);
assertNotNull
(
discussions
);
assertTrue
(
compareJson
(
discussions
.
all
(),
"issue-discussions.json"
));
}
@Test
public
void
testGetIssueDiscussionsByStream
()
throws
Exception
{
Stream
<
Discussion
>
stream
=
new
DiscussionsApi
(
gitLabApi
).
getIssueDiscussionsStream
(
1
,
1L
);
Stream
<
Discussion
>
stream
=
new
DiscussionsApi
(
gitLabApi
).
getIssueDiscussionsStream
(
1
L
,
1L
);
assertNotNull
(
stream
);
List
<
Discussion
>
discussions
=
stream
.
collect
(
Collectors
.
toList
());
assertTrue
(
compareJson
(
discussions
,
"issue-discussions.json"
));
...
...
src/test/java/org/gitlab4j/api/TestMergeRequestDiscussionsApi.java
View file @
cf58df40
...
...
@@ -39,28 +39,28 @@ public class TestMergeRequestDiscussionsApi implements Constants {
@Test
public
void
testGetMergeRequestDiscussionsByList
()
throws
Exception
{
List
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getMergeRequestDiscussions
(
1
,
1L
);
List
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getMergeRequestDiscussions
(
1
L
,
1L
);
assertNotNull
(
discussions
);
assertTrue
(
compareJson
(
discussions
,
"merge-request-discussions.json"
));
}
@Test
public
void
testGetMergeRequestDiscussionsByListMaxItems
()
throws
Exception
{
List
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getMergeRequestDiscussions
(
1
,
1L
,
20
);
List
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getMergeRequestDiscussions
(
1
L
,
1L
,
20
);
assertNotNull
(
discussions
);
assertTrue
(
compareJson
(
discussions
,
"merge-request-discussions.json"
));
}
@Test
public
void
testGetMergeRequestDiscussionsByPager
()
throws
Exception
{
Pager
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getMergeRequestDiscussionsPager
(
1
,
1L
,
20
);
Pager
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getMergeRequestDiscussionsPager
(
1
L
,
1L
,
20
);
assertNotNull
(
discussions
);
assertTrue
(
compareJson
(
discussions
.
all
(),
"merge-request-discussions.json"
));
}
@Test
public
void
testGetMergeRequestDiscussionsByStream
()
throws
Exception
{
Stream
<
Discussion
>
stream
=
new
DiscussionsApi
(
gitLabApi
).
getMergeRequestDiscussionsStream
(
1
,
1L
);
Stream
<
Discussion
>
stream
=
new
DiscussionsApi
(
gitLabApi
).
getMergeRequestDiscussionsStream
(
1
L
,
1L
);
assertNotNull
(
stream
);
List
<
Discussion
>
discussions
=
stream
.
collect
(
Collectors
.
toList
());
assertTrue
(
compareJson
(
discussions
,
"merge-request-discussions.json"
));
...
...
src/test/java/org/gitlab4j/api/TestPackageApi.java
View file @
cf58df40
...
...
@@ -40,8 +40,6 @@ public class TestPackageApi extends AbstractIntegrationTest {
.
withOrderBy
(
Constants
.
PackageOrderBy
.
CREATED_AT
)
.
withSortOder
(
Constants
.
SortOrder
.
DESC
);
Optional
<
Package
>
lastPackage
=
packagesApi
.
getPackagesStream
(
testProject
.
getId
(),
filter
).
findAny
();
assertTrue
(
lastPackage
.
isPresent
());
...
...
src/test/java/org/gitlab4j/api/TestProjectApi.java
View file @
cf58df40
...
...
@@ -638,7 +638,7 @@ public class TestProjectApi extends AbstractIntegrationTest {
assertFalse
(
optional
.
isPresent
());
assertEquals
(
Response
.
Status
.
NOT_FOUND
.
getStatusCode
(),
GitLabApi
.
getOptionalException
(
optional
).
getHttpStatus
());
optional
=
gitLabApi
.
getProjectApi
().
getOptionalProject
(
1234567
);
optional
=
gitLabApi
.
getProjectApi
().
getOptionalProject
(
1234567
L
);
assertNotNull
(
optional
);
assertFalse
(
optional
.
isPresent
());
assertEquals
(
Response
.
Status
.
NOT_FOUND
.
getStatusCode
(),
GitLabApi
.
getOptionalException
(
optional
).
getHttpStatus
());
...
...
src/test/java/org/gitlab4j/api/TestResourceStateEventsApi.java
View file @
cf58df40
...
...
@@ -5,6 +5,7 @@ import org.gitlab4j.api.models.IssueEvent;
import
org.gitlab4j.api.models.Project
;
import
org.junit.AfterClass
;
import
org.junit.BeforeClass
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.junit.experimental.categories.Category
;
...
...
@@ -37,6 +38,7 @@ public class TestResourceStateEventsApi extends AbstractIntegrationTest {
deleteAllTestIssues
();
}
@Ignore
(
"should be enabled when CI tests will be run against GitLab 13.2+"
)
@Test
public
void
testGetCloseReopenIssueEvents
()
throws
GitLabApiException
{
Long
projectId
=
testProject
.
getId
();
...
...
src/test/java/org/gitlab4j/api/TestSnippetDiscussionsApi.java
View file @
cf58df40
...
...
@@ -39,28 +39,28 @@ public class TestSnippetDiscussionsApi implements Constants {
@Test
public
void
testGetSnippetDiscussionsByList
()
throws
Exception
{
List
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getSnippetDiscussions
(
1
,
1L
);
List
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getSnippetDiscussions
(
1
L
,
1L
);
assertNotNull
(
discussions
);
assertTrue
(
compareJson
(
discussions
,
"snippet-discussions.json"
));
}
@Test
public
void
testGetSnippetDiscussionsByListWithMaxItems
()
throws
Exception
{
List
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getSnippetDiscussions
(
1
,
1L
,
20
);
List
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getSnippetDiscussions
(
1
L
,
1L
,
20
);
assertNotNull
(
discussions
);
assertTrue
(
compareJson
(
discussions
,
"snippet-discussions.json"
));
}
@Test
public
void
testGetSnippetDiscussionsByPager
()
throws
Exception
{
Pager
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getSnippetDiscussionsPager
(
1
,
1L
,
20
);
Pager
<
Discussion
>
discussions
=
new
DiscussionsApi
(
gitLabApi
).
getSnippetDiscussionsPager
(
1
L
,
1L
,
20
);
assertNotNull
(
discussions
);
assertTrue
(
compareJson
(
discussions
.
all
(),
"snippet-discussions.json"
));
}
@Test
public
void
testGetSnippetDiscussionsByStream
()
throws
Exception
{
Stream
<
Discussion
>
stream
=
new
DiscussionsApi
(
gitLabApi
).
getSnippetDiscussionsStream
(
1
,
1L
);
Stream
<
Discussion
>
stream
=
new
DiscussionsApi
(
gitLabApi
).
getSnippetDiscussionsStream
(
1
L
,
1L
);
assertNotNull
(
stream
);
List
<
Discussion
>
discussions
=
stream
.
collect
(
Collectors
.
toList
());
assertTrue
(
compareJson
(
discussions
,
"snippet-discussions.json"
));
...
...
src/test/java/org/gitlab4j/api/TestUnitMergeRequestApi.java
View file @
cf58df40
...
...
@@ -39,14 +39,14 @@ public class TestUnitMergeRequestApi {
@Test
public
void
whenAllArgumentsNull_thenNoAttributesSent
()
throws
Exception
{
new
MergeRequestApi
(
mockGitLabApi
).
updateMergeRequest
(
1
,
2L
,
null
,
null
,
null
,
null
,
null
,
null
,
new
MergeRequestApi
(
mockGitLabApi
).
updateMergeRequest
(
1
L
,
2L
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
);
assertEquals
(
0
,
attributeCaptor
.
getValue
().
size
());
}
@Test
public
void
falseBooleansAreSerializedCorrectly
()
throws
Exception
{
new
MergeRequestApi
(
mockGitLabApi
).
updateMergeRequest
(
1
,
2L
,
null
,
null
,
null
,
null
,
null
,
null
,
new
MergeRequestApi
(
mockGitLabApi
).
updateMergeRequest
(
1
L
,
2L
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
false
);
assertThat
(
attributeCaptor
.
getValue
(),
hasEntry
(
"allow_collaboration"
,
Collections
.
singletonList
(
"false"
)));
...
...
@@ -54,7 +54,7 @@ public class TestUnitMergeRequestApi {
@Test
public
void
trueBooleansAreSerializedCorrectly
()
throws
Exception
{
new
MergeRequestApi
(
mockGitLabApi
).
updateMergeRequest
(
1
,
2L
,
null
,
null
,
null
,
null
,
null
,
null
,
new
MergeRequestApi
(
mockGitLabApi
).
updateMergeRequest
(
1
L
,
2L
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
true
);
assertThat
(
attributeCaptor
.
getValue
(),
hasEntry
(
"allow_collaboration"
,
Collections
.
singletonList
(
"true"
)));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment