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
4539c4f9
Commit
4539c4f9
authored
Jun 09, 2019
by
Greg Messner
Browse files
Renamed FakeResponse -> MockResponse (#370).
parent
638327d3
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/test/java/org/gitlab4j/api/
Fake
Response.java
→
src/test/java/org/gitlab4j/api/
Mock
Response.java
View file @
4539c4f9
...
...
@@ -25,7 +25,7 @@ import javax.ws.rs.core.Response;
* Supports getXxxxx() methods that return a List of items, single items,
* Optional items, and Pagers of items.
*/
public
class
Fake
Response
extends
Response
{
public
class
Mock
Response
extends
Response
{
private
List
<?>
responseList
;
private
Object
responseItem
;
...
...
@@ -34,6 +34,13 @@ public class FakeResponse extends Response {
private
String
itemJson
;
private
String
listJson
;
public
MockResponse
()
{
}
public
<
T
>
MockResponse
(
Class
<
T
>
type
,
String
itemFilename
,
String
listFilename
)
throws
Exception
{
init
(
type
,
itemFilename
,
listFilename
);
}
public
<
T
>
void
init
(
Class
<
T
>
type
,
String
itemFilename
,
String
listFilename
)
throws
Exception
{
if
(
itemFilename
!=
null
)
{
...
...
src/test/java/org/gitlab4j/api/TestCommitDiscussionsApi.java
View file @
4539c4f9
...
...
@@ -27,12 +27,12 @@ public class TestCommitDiscussionsApi implements Constants {
@Mock
private
GitLabApi
gitLabApi
;
@Mock
private
GitLabApiClient
gitLabApiClient
;
@Captor
private
ArgumentCaptor
<
MultivaluedMap
<
String
,
String
>>
attributeCaptor
;
private
Fake
Response
response
=
new
FakeResponse
()
;
private
Mock
Response
response
;
@Before
public
void
setUp
()
throws
Exception
{
initMocks
(
this
);
response
.
init
(
Discussion
.
class
,
null
,
"commit-discussions.json"
);
response
=
new
MockResponse
(
Discussion
.
class
,
null
,
"commit-discussions.json"
);
when
(
gitLabApi
.
getApiClient
()).
thenReturn
(
gitLabApiClient
);
when
(
gitLabApiClient
.
validateSecretToken
(
any
())).
thenReturn
(
true
);
when
(
gitLabApiClient
.
get
(
attributeCaptor
.
capture
(),
Mockito
.<
Object
>
any
())).
thenReturn
(
response
);
...
...
src/test/java/org/gitlab4j/api/TestEpicDiscussionsApi.java
View file @
4539c4f9
...
...
@@ -26,12 +26,12 @@ public class TestEpicDiscussionsApi implements Constants {
@Mock
private
GitLabApi
gitLabApi
;
@Mock
private
GitLabApiClient
gitLabApiClient
;
@Captor
private
ArgumentCaptor
<
MultivaluedMap
<
String
,
String
>>
attributeCaptor
;
private
Fake
Response
response
=
new
FakeResponse
()
;
private
Mock
Response
response
;
@Before
public
void
setUp
()
throws
Exception
{
initMocks
(
this
);
response
.
init
(
Discussion
.
class
,
null
,
"epic-discussions.json"
);
response
=
new
MockResponse
(
Discussion
.
class
,
null
,
"epic-discussions.json"
);
when
(
gitLabApi
.
getApiClient
()).
thenReturn
(
gitLabApiClient
);
when
(
gitLabApiClient
.
validateSecretToken
(
any
())).
thenReturn
(
true
);
when
(
gitLabApiClient
.
get
(
attributeCaptor
.
capture
(),
Mockito
.<
Object
>
any
())).
thenReturn
(
response
);
...
...
src/test/java/org/gitlab4j/api/TestIssueDiscussionsApi.java
View file @
4539c4f9
...
...
@@ -26,12 +26,12 @@ public class TestIssueDiscussionsApi implements Constants {
@Mock
private
GitLabApi
gitLabApi
;
@Mock
private
GitLabApiClient
gitLabApiClient
;
@Captor
private
ArgumentCaptor
<
MultivaluedMap
<
String
,
String
>>
attributeCaptor
;
private
Fake
Response
response
=
new
FakeResponse
()
;
private
Mock
Response
response
;
@Before
public
void
setUp
()
throws
Exception
{
initMocks
(
this
);
response
.
init
(
Discussion
.
class
,
null
,
"issue-discussions.json"
);
response
=
new
MockResponse
(
Discussion
.
class
,
null
,
"issue-discussions.json"
);
when
(
gitLabApi
.
getApiClient
()).
thenReturn
(
gitLabApiClient
);
when
(
gitLabApiClient
.
validateSecretToken
(
any
())).
thenReturn
(
true
);
when
(
gitLabApiClient
.
get
(
attributeCaptor
.
capture
(),
Mockito
.<
Object
>
any
())).
thenReturn
(
response
);
...
...
src/test/java/org/gitlab4j/api/TestMergeRequestApi.java
View file @
4539c4f9
...
...
@@ -24,13 +24,13 @@ public class TestMergeRequestApi {
@Mock
private
GitLabApi
gitLabApi
;
@Mock
private
GitLabApiClient
gitLabApiClient
;
@Captor
private
ArgumentCaptor
<
MultivaluedMap
<
String
,
String
>>
attributeCaptor
;
private
Fake
Response
response
=
new
FakeResponse
()
;
private
Mock
Response
response
;
@SuppressWarnings
(
"deprecation"
)
@Before
public
void
setUp
()
throws
Exception
{
initMocks
(
this
);
response
.
init
(
MergeRequest
.
class
,
"merge-request.json"
,
null
);
response
=
new
MockResponse
(
MergeRequest
.
class
,
"merge-request.json"
,
null
);
when
(
gitLabApi
.
getApiClient
()).
thenReturn
(
gitLabApiClient
);
when
(
gitLabApiClient
.
validateSecretToken
(
any
())).
thenReturn
(
true
);
...
...
src/test/java/org/gitlab4j/api/TestMergeRequestDiscussionsApi.java
View file @
4539c4f9
...
...
@@ -26,12 +26,12 @@ public class TestMergeRequestDiscussionsApi implements Constants {
@Mock
private
GitLabApi
gitLabApi
;
@Mock
private
GitLabApiClient
gitLabApiClient
;
@Captor
private
ArgumentCaptor
<
MultivaluedMap
<
String
,
String
>>
attributeCaptor
;
private
Fake
Response
response
=
new
FakeResponse
()
;
private
Mock
Response
response
;
@Before
public
void
setUp
()
throws
Exception
{
initMocks
(
this
);
response
.
init
(
Discussion
.
class
,
null
,
"merge-request-discussions.json"
);
response
=
new
MockResponse
(
Discussion
.
class
,
null
,
"merge-request-discussions.json"
);
when
(
gitLabApi
.
getApiClient
()).
thenReturn
(
gitLabApiClient
);
when
(
gitLabApiClient
.
validateSecretToken
(
any
())).
thenReturn
(
true
);
when
(
gitLabApiClient
.
get
(
attributeCaptor
.
capture
(),
Mockito
.<
Object
>
any
())).
thenReturn
(
response
);
...
...
src/test/java/org/gitlab4j/api/TestSnippetDiscussionsApi.java
View file @
4539c4f9
...
...
@@ -26,12 +26,12 @@ public class TestSnippetDiscussionsApi implements Constants {
@Mock
private
GitLabApi
gitLabApi
;
@Mock
private
GitLabApiClient
gitLabApiClient
;
@Captor
private
ArgumentCaptor
<
MultivaluedMap
<
String
,
String
>>
attributeCaptor
;
private
Fake
Response
response
=
new
FakeResponse
()
;
private
Mock
Response
response
;
@Before
public
void
setUp
()
throws
Exception
{
initMocks
(
this
);
response
.
init
(
Discussion
.
class
,
null
,
"snippet-discussions.json"
);
response
=
new
MockResponse
(
Discussion
.
class
,
null
,
"snippet-discussions.json"
);
when
(
gitLabApi
.
getApiClient
()).
thenReturn
(
gitLabApiClient
);
when
(
gitLabApiClient
.
validateSecretToken
(
any
())).
thenReturn
(
true
);
when
(
gitLabApiClient
.
get
(
attributeCaptor
.
capture
(),
Mockito
.<
Object
>
any
())).
thenReturn
(
response
);
...
...
src/test/java/org/gitlab4j/api/TestStreams.java
View file @
4539c4f9
...
...
@@ -30,7 +30,7 @@ public class TestStreams implements Constants {
@Mock
private
GitLabApi
gitLabApi
;
@Mock
private
GitLabApiClient
gitLabApiClient
;
@Captor
private
ArgumentCaptor
<
MultivaluedMap
<
String
,
String
>>
attributeCaptor
;
private
Fake
Response
response
=
new
FakeResponse
()
;
private
Mock
Response
response
;
static
private
List
<
User
>
sortedUsers
;
...
...
@@ -45,7 +45,7 @@ public class TestStreams implements Constants {
@Before
public
void
setup
()
throws
Exception
{
initMocks
(
this
);
response
.
init
(
User
.
class
,
null
,
"user-list.json"
);
response
=
new
MockResponse
(
User
.
class
,
null
,
"user-list.json"
);
when
(
gitLabApi
.
getApiClient
()).
thenReturn
(
gitLabApiClient
);
when
(
gitLabApiClient
.
validateSecretToken
(
any
())).
thenReturn
(
true
);
when
(
gitLabApiClient
.
get
(
attributeCaptor
.
capture
(),
Mockito
.<
Object
>
any
())).
thenReturn
(
response
);
...
...
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