diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/com/p4square/ccbapi/CCBAPIClientTest.java | 65 | ||||
-rw-r--r-- | src/test/resources/com/p4square/ccbapi/model/ccb_group_profile_from_id_response.xml | 113 |
2 files changed, 178 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. */ 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ccb_api> + <request> + <parameters> + <argument value="group_profile_from_id" name="srv"/> + <argument value="750" name="id"/> + </parameters> + </request> + <response> + <service>group_profile_from_id</service> + <service_action>execute</service_action> + <availability>public</availability> + <groups count="1"> + <group id="750"> + <name>Adamant by Lisa Bevere Book Study</name> + <description>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</description> + <image></image> + <campus id="1">Example Church</campus> + <main_leader id="26102"> + <first_name>Jane</first_name> + <last_name>Doe</last_name> + <full_name>Jane Doe</full_name> + <email>jane.doe@example.com</email> + <phones> + <phone type="contact">+12068675309</phone> + </phones> + </main_leader> + <leaders/> + <coach id="29"> + <first_name>John</first_name> + <last_name>Doe</last_name> + <full_name>John Doe</full_name> + <email>john.doe@example.com</email> + <phones type="contact"> + <phone></phone> + </phones> + </coach> + <director id="33082"> + <first_name>Jeff</first_name> + <last_name>Doe</last_name> + <full_name>Jeff Doe</full_name> + <email>jeff.doe@example.com</email> + <phones type="contact"> + <phone></phone> + </phones> + </director> + <participants/> + <group_type id="4">Community</group_type> + <department id="13">Adults</department> + <area id="18">Puyallup</area> + <calendar_feed>webcal://example.ccbchurch.com/group_calendar.ics?id=750&tk=764EFA883DDA1E11DB47671C4A3BBD9E</calendar_feed> + <registration_forms/> + <current_members>1</current_members> + <group_capacity>Unlimited</group_capacity> + <addresses> + <address type="meeting"> + <name></name> + <street_address>1234 Example St</street_address> + <city>Puyallup</city> + <state>WA</state> + <zip></zip> + <longitude>-122.000000</longitude> + <latitude>47.000000</latitude> + <line_1>1234 Example St</line_1> + <line_2>Puyallup, WA</line_2> + </address> + </addresses> + <meeting_day id="4">Tuesday</meeting_day> + <meeting_time id="33">7:00 pm</meeting_time> + <childcare_provided>false</childcare_provided> + <interaction_type>Members Interact</interaction_type> + <membership_type>Invitation or Request Required</membership_type> + <notification>true</notification> + <user_defined_fields> + <user_defined_field> + <name>udf_1</name> + <label>Gender</label> + <selection id="2">Female only</selection> + <admin_only>false</admin_only> + </user_defined_field> + <user_defined_field> + <name>udf_2</name> + <label>Marital status</label> + <selection id="3">Marrieds & Single</selection> + <admin_only>false</admin_only> + </user_defined_field> + <user_defined_field> + <name>udf_3</name> + <label>Group Category</label> + <selection id="1">Learning</selection> + <admin_only>false</admin_only> + </user_defined_field> + </user_defined_fields> + <listed>true</listed> + <public_search_listed>true</public_search_listed> + <inactive>false</inactive> + <creator id="12">Larry Cucumber</creator> + <modifier id="12">Larry Cucumber</modifier> + <created>2018-06-28 22:43:40</created> + <modified>2018-06-28 22:44:25</modified> + </group> + </groups> + </response> +</ccb_api>
\ No newline at end of file |