diff options
author | Jesse Morgan <jesse@jesterpm.net> | 2018-07-14 12:13:04 -0700 |
---|---|---|
committer | Jesse Morgan <jesse@jesterpm.net> | 2018-07-14 12:13:04 -0700 |
commit | 808c6323049c1efff52f20d872813f86e21c5b37 (patch) | |
tree | acf7ec4000631e5fa7d5d9a8155367070c23fffa /src/test/java/com/p4square/ccbapi/CCBAPIClientTest.java | |
parent | 35887b81ac23a389f123df529e45fd9c49ce7459 (diff) | |
parent | 633d0cebff548b6a54ac33e464447d93e800bf12 (diff) |
Merge branch 'groups-api'
Diffstat (limited to 'src/test/java/com/p4square/ccbapi/CCBAPIClientTest.java')
-rw-r--r-- | src/test/java/com/p4square/ccbapi/CCBAPIClientTest.java | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/test/java/com/p4square/ccbapi/CCBAPIClientTest.java b/src/test/java/com/p4square/ccbapi/CCBAPIClientTest.java index 71427b5..9c7bbd6 100644 --- a/src/test/java/com/p4square/ccbapi/CCBAPIClientTest.java +++ b/src/test/java/com/p4square/ccbapi/CCBAPIClientTest.java @@ -283,6 +283,71 @@ public class CCBAPIClientTest { // Expect exception. } + @Test + public void testGetGroupProfilesById() throws Exception { + // Set expectation. + URI expectedURI = new URI("https://localhost:8080/api.php?srv=group_profile_from_id&id=750"); + InputStream is = getClass().getResourceAsStream("model/ccb_group_profile_from_id_response.xml"); + EasyMock.expect(mockHttpClient.sendPostRequest(expectedURI, null)) + .andReturn(is); + EasyMock.replay(mockHttpClient); + + // Test group_profile_from_id. + GetGroupProfilesRequest request = new GetGroupProfilesRequest().withGroupId(750); + GetGroupProfilesResponse response = client.getGroupProfiles(request); + + // Verify results. + EasyMock.verify(mockHttpClient); + assertNull(response.getErrors()); + assertEquals(1, response.getGroups().size()); + assertEquals(750, response.getGroups().get(0).getId()); + } + + @Test + public void testGetAllGroupProfiles() throws Exception { + // Set expectation. + URI expectedURI = new URI("https://localhost:8080/api.php?srv=group_profiles"); + InputStream is = getClass().getResourceAsStream("model/ccb_group_profile_from_id_response.xml"); + EasyMock.expect(mockHttpClient.sendPostRequest(expectedURI, null)) + .andReturn(is); + EasyMock.replay(mockHttpClient); + + // Test group_profile_from_id. + GetGroupProfilesRequest request = new GetGroupProfilesRequest(); + GetGroupProfilesResponse response = client.getGroupProfiles(request); + + // Verify results. + EasyMock.verify(mockHttpClient); + assertNull(response.getErrors()); + assertEquals(1, response.getGroups().size()); + assertEquals(750, response.getGroups().get(0).getId()); + } + + @Test + public void testGetAllGroupProfilesWithOptions() throws Exception { + // Set expectation. + URI expectedURI = new URI("https://localhost:8080/api.php?srv=group_profiles&per_page=2&modified_since=2018-07-08&page=1&include_participants=false&include_image_link=true"); + InputStream is = getClass().getResourceAsStream("model/ccb_group_profile_from_id_response.xml"); + EasyMock.expect(mockHttpClient.sendPostRequest(expectedURI, null)) + .andReturn(is); + EasyMock.replay(mockHttpClient); + + // Test group_profile_from_id. + GetGroupProfilesRequest request = new GetGroupProfilesRequest() + .withIncludeParticipants(false) + .withIncludeImageUrl(true) + .withModifiedSince(LocalDate.parse("2018-07-08")) + .withPage(1) + .withPerPage(2); + GetGroupProfilesResponse response = client.getGroupProfiles(request); + + // Verify results. + EasyMock.verify(mockHttpClient); + assertNull(response.getErrors()); + assertEquals(1, response.getGroups().size()); + assertEquals(750, response.getGroups().get(0).getId()); + } + /** * Simple extension of CCBAPIClient to swap out the HTTPInterface with a mock. */ |