diff options
| author | Jesse Morgan <jesse@jesterpm.net> | 2018-07-08 09:34:59 -0700 | 
|---|---|---|
| committer | Jesse Morgan <jesse@jesterpm.net> | 2018-07-08 09:34:59 -0700 | 
| commit | 151f74ffa870561bbb3c857c0f07aeb4b27968f5 (patch) | |
| tree | fc81aefe1330750c9fcfef28f38d2c938b792cd4 /src/test/java | |
| parent | 35887b81ac23a389f123df529e45fd9c49ce7459 (diff) | |
Add Groups Service APIs
Diffstat (limited to 'src/test/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.       */ | 
