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; ...@@ -25,7 +25,7 @@ import javax.ws.rs.core.Response;
* Supports getXxxxx() methods that return a List of items, single items, * Supports getXxxxx() methods that return a List of items, single items,
* Optional items, and Pagers of items. * Optional items, and Pagers of items.
*/ */
public class FakeResponse extends Response { public class MockResponse extends Response {
private List<?> responseList; private List<?> responseList;
private Object responseItem; private Object responseItem;
...@@ -34,6 +34,13 @@ public class FakeResponse extends Response { ...@@ -34,6 +34,13 @@ public class FakeResponse extends Response {
private String itemJson; private String itemJson;
private String listJson; 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 { public <T> void init(Class<T> type, String itemFilename, String listFilename) throws Exception {
if (itemFilename != null) { if (itemFilename != null) {
......
...@@ -27,12 +27,12 @@ public class TestCommitDiscussionsApi implements Constants { ...@@ -27,12 +27,12 @@ public class TestCommitDiscussionsApi implements Constants {
@Mock private GitLabApi gitLabApi; @Mock private GitLabApi gitLabApi;
@Mock private GitLabApiClient gitLabApiClient; @Mock private GitLabApiClient gitLabApiClient;
@Captor private ArgumentCaptor<MultivaluedMap<String, String>> attributeCaptor; @Captor private ArgumentCaptor<MultivaluedMap<String, String>> attributeCaptor;
private FakeResponse response = new FakeResponse(); private MockResponse response;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
initMocks(this); 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(gitLabApi.getApiClient()).thenReturn(gitLabApiClient);
when(gitLabApiClient.validateSecretToken(any())).thenReturn(true); when(gitLabApiClient.validateSecretToken(any())).thenReturn(true);
when(gitLabApiClient.get(attributeCaptor.capture(), Mockito.<Object>any())).thenReturn(response); when(gitLabApiClient.get(attributeCaptor.capture(), Mockito.<Object>any())).thenReturn(response);
......
...@@ -26,12 +26,12 @@ public class TestEpicDiscussionsApi implements Constants { ...@@ -26,12 +26,12 @@ public class TestEpicDiscussionsApi implements Constants {
@Mock private GitLabApi gitLabApi; @Mock private GitLabApi gitLabApi;
@Mock private GitLabApiClient gitLabApiClient; @Mock private GitLabApiClient gitLabApiClient;
@Captor private ArgumentCaptor<MultivaluedMap<String, String>> attributeCaptor; @Captor private ArgumentCaptor<MultivaluedMap<String, String>> attributeCaptor;
private FakeResponse response = new FakeResponse(); private MockResponse response;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
initMocks(this); 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(gitLabApi.getApiClient()).thenReturn(gitLabApiClient);
when(gitLabApiClient.validateSecretToken(any())).thenReturn(true); when(gitLabApiClient.validateSecretToken(any())).thenReturn(true);
when(gitLabApiClient.get(attributeCaptor.capture(), Mockito.<Object>any())).thenReturn(response); when(gitLabApiClient.get(attributeCaptor.capture(), Mockito.<Object>any())).thenReturn(response);
......
...@@ -26,12 +26,12 @@ public class TestIssueDiscussionsApi implements Constants { ...@@ -26,12 +26,12 @@ public class TestIssueDiscussionsApi implements Constants {
@Mock private GitLabApi gitLabApi; @Mock private GitLabApi gitLabApi;
@Mock private GitLabApiClient gitLabApiClient; @Mock private GitLabApiClient gitLabApiClient;
@Captor private ArgumentCaptor<MultivaluedMap<String, String>> attributeCaptor; @Captor private ArgumentCaptor<MultivaluedMap<String, String>> attributeCaptor;
private FakeResponse response = new FakeResponse(); private MockResponse response;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
initMocks(this); 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(gitLabApi.getApiClient()).thenReturn(gitLabApiClient);
when(gitLabApiClient.validateSecretToken(any())).thenReturn(true); when(gitLabApiClient.validateSecretToken(any())).thenReturn(true);
when(gitLabApiClient.get(attributeCaptor.capture(), Mockito.<Object>any())).thenReturn(response); when(gitLabApiClient.get(attributeCaptor.capture(), Mockito.<Object>any())).thenReturn(response);
......
...@@ -24,13 +24,13 @@ public class TestMergeRequestApi { ...@@ -24,13 +24,13 @@ public class TestMergeRequestApi {
@Mock private GitLabApi gitLabApi; @Mock private GitLabApi gitLabApi;
@Mock private GitLabApiClient gitLabApiClient; @Mock private GitLabApiClient gitLabApiClient;
@Captor private ArgumentCaptor<MultivaluedMap<String, String>> attributeCaptor; @Captor private ArgumentCaptor<MultivaluedMap<String, String>> attributeCaptor;
private FakeResponse response = new FakeResponse(); private MockResponse response;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
initMocks(this); 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(gitLabApi.getApiClient()).thenReturn(gitLabApiClient);
when(gitLabApiClient.validateSecretToken(any())).thenReturn(true); when(gitLabApiClient.validateSecretToken(any())).thenReturn(true);
......
...@@ -26,12 +26,12 @@ public class TestMergeRequestDiscussionsApi implements Constants { ...@@ -26,12 +26,12 @@ public class TestMergeRequestDiscussionsApi implements Constants {
@Mock private GitLabApi gitLabApi; @Mock private GitLabApi gitLabApi;
@Mock private GitLabApiClient gitLabApiClient; @Mock private GitLabApiClient gitLabApiClient;
@Captor private ArgumentCaptor<MultivaluedMap<String, String>> attributeCaptor; @Captor private ArgumentCaptor<MultivaluedMap<String, String>> attributeCaptor;
private FakeResponse response = new FakeResponse(); private MockResponse response;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
initMocks(this); 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(gitLabApi.getApiClient()).thenReturn(gitLabApiClient);
when(gitLabApiClient.validateSecretToken(any())).thenReturn(true); when(gitLabApiClient.validateSecretToken(any())).thenReturn(true);
when(gitLabApiClient.get(attributeCaptor.capture(), Mockito.<Object>any())).thenReturn(response); when(gitLabApiClient.get(attributeCaptor.capture(), Mockito.<Object>any())).thenReturn(response);
......
...@@ -26,12 +26,12 @@ public class TestSnippetDiscussionsApi implements Constants { ...@@ -26,12 +26,12 @@ public class TestSnippetDiscussionsApi implements Constants {
@Mock private GitLabApi gitLabApi; @Mock private GitLabApi gitLabApi;
@Mock private GitLabApiClient gitLabApiClient; @Mock private GitLabApiClient gitLabApiClient;
@Captor private ArgumentCaptor<MultivaluedMap<String, String>> attributeCaptor; @Captor private ArgumentCaptor<MultivaluedMap<String, String>> attributeCaptor;
private FakeResponse response = new FakeResponse(); private MockResponse response;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
initMocks(this); 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(gitLabApi.getApiClient()).thenReturn(gitLabApiClient);
when(gitLabApiClient.validateSecretToken(any())).thenReturn(true); when(gitLabApiClient.validateSecretToken(any())).thenReturn(true);
when(gitLabApiClient.get(attributeCaptor.capture(), Mockito.<Object>any())).thenReturn(response); when(gitLabApiClient.get(attributeCaptor.capture(), Mockito.<Object>any())).thenReturn(response);
......
...@@ -30,7 +30,7 @@ public class TestStreams implements Constants { ...@@ -30,7 +30,7 @@ public class TestStreams implements Constants {
@Mock private GitLabApi gitLabApi; @Mock private GitLabApi gitLabApi;
@Mock private GitLabApiClient gitLabApiClient; @Mock private GitLabApiClient gitLabApiClient;
@Captor private ArgumentCaptor<MultivaluedMap<String, String>> attributeCaptor; @Captor private ArgumentCaptor<MultivaluedMap<String, String>> attributeCaptor;
private FakeResponse response = new FakeResponse(); private MockResponse response;
static private List<User> sortedUsers; static private List<User> sortedUsers;
...@@ -45,7 +45,7 @@ public class TestStreams implements Constants { ...@@ -45,7 +45,7 @@ public class TestStreams implements Constants {
@Before @Before
public void setup() throws Exception { public void setup() throws Exception {
initMocks(this); 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(gitLabApi.getApiClient()).thenReturn(gitLabApiClient);
when(gitLabApiClient.validateSecretToken(any())).thenReturn(true); when(gitLabApiClient.validateSecretToken(any())).thenReturn(true);
when(gitLabApiClient.get(attributeCaptor.capture(), Mockito.<Object>any())).thenReturn(response); 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