Commit 4539c4f9 authored by Greg Messner's avatar Greg Messner
Browse files

Renamed FakeResponse -> MockResponse (#370).

parent 638327d3
......@@ -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 FakeResponse extends Response {
public class MockResponse 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) {
......
......@@ -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 FakeResponse response = new FakeResponse();
private MockResponse 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);
......
......@@ -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 FakeResponse response = new FakeResponse();
private MockResponse 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);
......
......@@ -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 FakeResponse response = new FakeResponse();
private MockResponse 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);
......
......@@ -24,13 +24,13 @@ public class TestMergeRequestApi {
@Mock private GitLabApi gitLabApi;
@Mock private GitLabApiClient gitLabApiClient;
@Captor private ArgumentCaptor<MultivaluedMap<String, String>> attributeCaptor;
private FakeResponse response = new FakeResponse();
private MockResponse 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);
......
......@@ -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 FakeResponse response = new FakeResponse();
private MockResponse 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);
......
......@@ -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 FakeResponse response = new FakeResponse();
private MockResponse 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);
......
......@@ -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 FakeResponse response = new FakeResponse();
private MockResponse 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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment