From 151f74ffa870561bbb3c857c0f07aeb4b27968f5 Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Sun, 8 Jul 2018 09:34:59 -0700 Subject: Add Groups Service APIs --- .../java/com/p4square/ccbapi/CCBAPIClientTest.java | 65 ++++++++++++ .../model/ccb_group_profile_from_id_response.xml | 113 +++++++++++++++++++++ 2 files changed, 178 insertions(+) create mode 100644 src/test/resources/com/p4square/ccbapi/model/ccb_group_profile_from_id_response.xml (limited to 'src/test') 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. */ diff --git a/src/test/resources/com/p4square/ccbapi/model/ccb_group_profile_from_id_response.xml b/src/test/resources/com/p4square/ccbapi/model/ccb_group_profile_from_id_response.xml new file mode 100644 index 0000000..566f656 --- /dev/null +++ b/src/test/resources/com/p4square/ccbapi/model/ccb_group_profile_from_id_response.xml @@ -0,0 +1,113 @@ + + + + + + + + + + group_profile_from_id + execute + public + + + Adamant by Lisa Bevere Book Study + What is the truth? + + This has become the defining question of our time. But while everyone has an opinion, truth, it seems, is getting harder and harder to find. Perhaps that's because we are searching for something when we should be looking for someone. + + Truth has a name. + + More ancient than time and more present than this moment, the truth is not a river that changes with the cultural currents, but a rock--immovable, invincible, unshakeable--and the cornerstone of all we are and ever dream to be. + + Theologically deep yet intimately accessible. Adamant will be an anchor for your soul in a raging sea of opinions, giving you a clear sense of direction in a wandering world. + Every Other Tuesday Beginning in September 2018 + + Example Church + + Jane + Doe + Jane Doe + jane.doe@example.com + + +12068675309 + + + + + John + Doe + John Doe + john.doe@example.com + + + + + + Jeff + Doe + Jeff Doe + jeff.doe@example.com + + + + + + Community + Adults + Puyallup + webcal://example.ccbchurch.com/group_calendar.ics?id=750&tk=764EFA883DDA1E11DB47671C4A3BBD9E + + 1 + Unlimited + +
+ + 1234 Example St + Puyallup + WA + + -122.000000 + 47.000000 + 1234 Example St + Puyallup, WA +
+
+ Tuesday + 7:00 pm + false + Members Interact + Invitation or Request Required + true + + + udf_1 + + Female only + false + + + udf_2 + + Marrieds & Single + false + + + udf_3 + + Learning + false + + + true + true + false + Larry Cucumber + Larry Cucumber + 2018-06-28 22:43:40 + 2018-06-28 22:44:25 +
+
+
+
\ No newline at end of file -- cgit v1.2.3