Skip to content

Commit 4539c4f

Browse files
committed
Renamed FakeResponse -> MockResponse (#370).
1 parent 638327d commit 4539c4f

File tree

8 files changed

+22
-15
lines changed

8 files changed

+22
-15
lines changed

src/test/java/org/gitlab4j/api/FakeResponse.java renamed to src/test/java/org/gitlab4j/api/MockResponse.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* Supports getXxxxx() methods that return a List of items, single items,
2626
* Optional items, and Pagers of items.
2727
*/
28-
public class FakeResponse extends Response {
28+
public class MockResponse extends Response {
2929

3030
private List<?> responseList;
3131
private Object responseItem;
@@ -34,6 +34,13 @@ public class FakeResponse extends Response {
3434
private String itemJson;
3535
private String listJson;
3636

37+
public MockResponse() {
38+
}
39+
40+
public <T> MockResponse(Class<T> type, String itemFilename, String listFilename) throws Exception {
41+
init(type, itemFilename, listFilename);
42+
}
43+
3744
public <T> void init(Class<T> type, String itemFilename, String listFilename) throws Exception {
3845

3946
if (itemFilename != null) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ public class TestCommitDiscussionsApi implements Constants {
2727
@Mock private GitLabApi gitLabApi;
2828
@Mock private GitLabApiClient gitLabApiClient;
2929
@Captor private ArgumentCaptor<MultivaluedMap<String, String>> attributeCaptor;
30-
private FakeResponse response = new FakeResponse();
30+
private MockResponse response;
3131

3232
@Before
3333
public void setUp() throws Exception {
3434
initMocks(this);
35-
response.init(Discussion.class, null, "commit-discussions.json");
35+
response = new MockResponse(Discussion.class, null, "commit-discussions.json");
3636
when(gitLabApi.getApiClient()).thenReturn(gitLabApiClient);
3737
when(gitLabApiClient.validateSecretToken(any())).thenReturn(true);
3838
when(gitLabApiClient.get(attributeCaptor.capture(), Mockito.<Object>any())).thenReturn(response);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ public class TestEpicDiscussionsApi implements Constants {
2626
@Mock private GitLabApi gitLabApi;
2727
@Mock private GitLabApiClient gitLabApiClient;
2828
@Captor private ArgumentCaptor<MultivaluedMap<String, String>> attributeCaptor;
29-
private FakeResponse response = new FakeResponse();
29+
private MockResponse response;
3030

3131
@Before
3232
public void setUp() throws Exception {
3333
initMocks(this);
34-
response.init(Discussion.class, null, "epic-discussions.json");
34+
response = new MockResponse(Discussion.class, null, "epic-discussions.json");
3535
when(gitLabApi.getApiClient()).thenReturn(gitLabApiClient);
3636
when(gitLabApiClient.validateSecretToken(any())).thenReturn(true);
3737
when(gitLabApiClient.get(attributeCaptor.capture(), Mockito.<Object>any())).thenReturn(response);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ public class TestIssueDiscussionsApi implements Constants {
2626
@Mock private GitLabApi gitLabApi;
2727
@Mock private GitLabApiClient gitLabApiClient;
2828
@Captor private ArgumentCaptor<MultivaluedMap<String, String>> attributeCaptor;
29-
private FakeResponse response = new FakeResponse();
29+
private MockResponse response;
3030

3131
@Before
3232
public void setUp() throws Exception {
3333
initMocks(this);
34-
response.init(Discussion.class, null, "issue-discussions.json");
34+
response = new MockResponse(Discussion.class, null, "issue-discussions.json");
3535
when(gitLabApi.getApiClient()).thenReturn(gitLabApiClient);
3636
when(gitLabApiClient.validateSecretToken(any())).thenReturn(true);
3737
when(gitLabApiClient.get(attributeCaptor.capture(), Mockito.<Object>any())).thenReturn(response);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ public class TestMergeRequestApi {
2424
@Mock private GitLabApi gitLabApi;
2525
@Mock private GitLabApiClient gitLabApiClient;
2626
@Captor private ArgumentCaptor<MultivaluedMap<String, String>> attributeCaptor;
27-
private FakeResponse response = new FakeResponse();
27+
private MockResponse response;
2828

2929
@SuppressWarnings("deprecation")
3030
@Before
3131
public void setUp() throws Exception {
3232
initMocks(this);
33-
response.init(MergeRequest.class, "merge-request.json", null);
33+
response = new MockResponse(MergeRequest.class, "merge-request.json", null);
3434
when(gitLabApi.getApiClient()).thenReturn(gitLabApiClient);
3535

3636
when(gitLabApiClient.validateSecretToken(any())).thenReturn(true);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ public class TestMergeRequestDiscussionsApi implements Constants {
2626
@Mock private GitLabApi gitLabApi;
2727
@Mock private GitLabApiClient gitLabApiClient;
2828
@Captor private ArgumentCaptor<MultivaluedMap<String, String>> attributeCaptor;
29-
private FakeResponse response = new FakeResponse();
29+
private MockResponse response;
3030

3131
@Before
3232
public void setUp() throws Exception {
3333
initMocks(this);
34-
response.init(Discussion.class, null, "merge-request-discussions.json");
34+
response = new MockResponse(Discussion.class, null, "merge-request-discussions.json");
3535
when(gitLabApi.getApiClient()).thenReturn(gitLabApiClient);
3636
when(gitLabApiClient.validateSecretToken(any())).thenReturn(true);
3737
when(gitLabApiClient.get(attributeCaptor.capture(), Mockito.<Object>any())).thenReturn(response);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ public class TestSnippetDiscussionsApi implements Constants {
2626
@Mock private GitLabApi gitLabApi;
2727
@Mock private GitLabApiClient gitLabApiClient;
2828
@Captor private ArgumentCaptor<MultivaluedMap<String, String>> attributeCaptor;
29-
private FakeResponse response = new FakeResponse();
29+
private MockResponse response;
3030

3131
@Before
3232
public void setUp() throws Exception {
3333
initMocks(this);
34-
response.init(Discussion.class, null, "snippet-discussions.json");
34+
response = new MockResponse(Discussion.class, null, "snippet-discussions.json");
3535
when(gitLabApi.getApiClient()).thenReturn(gitLabApiClient);
3636
when(gitLabApiClient.validateSecretToken(any())).thenReturn(true);
3737
when(gitLabApiClient.get(attributeCaptor.capture(), Mockito.<Object>any())).thenReturn(response);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class TestStreams implements Constants {
3030
@Mock private GitLabApi gitLabApi;
3131
@Mock private GitLabApiClient gitLabApiClient;
3232
@Captor private ArgumentCaptor<MultivaluedMap<String, String>> attributeCaptor;
33-
private FakeResponse response = new FakeResponse();
33+
private MockResponse response;
3434

3535
static private List<User> sortedUsers;
3636

@@ -45,7 +45,7 @@ public static void setupClass() throws Exception {
4545
@Before
4646
public void setup() throws Exception {
4747
initMocks(this);
48-
response.init(User.class, null, "user-list.json");
48+
response = new MockResponse(User.class, null, "user-list.json");
4949
when(gitLabApi.getApiClient()).thenReturn(gitLabApiClient);
5050
when(gitLabApiClient.validateSecretToken(any())).thenReturn(true);
5151
when(gitLabApiClient.get(attributeCaptor.capture(), Mockito.<Object>any())).thenReturn(response);

0 commit comments

Comments
 (0)