diff options
Diffstat (limited to 'src/test')
3 files changed, 70 insertions, 0 deletions
diff --git a/src/test/java/com/p4square/ccbapi/CCBAPIClientTest.java b/src/test/java/com/p4square/ccbapi/CCBAPIClientTest.java index 9c7bbd6..22f9046 100644 --- a/src/test/java/com/p4square/ccbapi/CCBAPIClientTest.java +++ b/src/test/java/com/p4square/ccbapi/CCBAPIClientTest.java @@ -129,6 +129,24 @@ public class CCBAPIClientTest { assertEquals("High School Graduation", response.getItems().get(0).getName()); } + @Test + public void testGetCampusList() throws Exception { + // Set expectation. + URI expectedURI = new URI("https://localhost:8080/api.php?srv=campus_list"); + InputStream is = getClass().getResourceAsStream("model/ccb_campus_list_response.xml"); + EasyMock.expect(mockHttpClient.sendPostRequest(expectedURI, null)) + .andReturn(is); + EasyMock.replay(mockHttpClient); + + // Test significant_event_list. + GetCampusListResponse response = client.getCampusList(); + + // Verify results. + EasyMock.verify(mockHttpClient); + assertNull(response.getErrors()); + assertEquals(1, response.getCampuses().size()); + } + @Test(expected = IllegalArgumentException.class) public void testGetLookupTableListWithNullType() throws Exception { // This should throw an IllegalArgumentException. diff --git a/src/test/java/com/p4square/ccbapi/model/GetCampusListResponseTest.java b/src/test/java/com/p4square/ccbapi/model/GetCampusListResponseTest.java new file mode 100644 index 0000000..9b635db --- /dev/null +++ b/src/test/java/com/p4square/ccbapi/model/GetCampusListResponseTest.java @@ -0,0 +1,30 @@ +package com.p4square.ccbapi.model; + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Tests for parsing GetCampusListResponseTest. + */ +public class GetCampusListResponseTest extends XmlBinderTestBase { + + /** + * Assert that all of the fields bind appropriately. + */ + @Test + public void testGetCampusListResponse() throws Exception { + final GetCampusListResponse response = parseFile("ccb_campus_list_response.xml", + GetCampusListResponse.class); + + assertNull("Response should not have errors", response.getErrors()); + assertNotNull(response.getCampuses()); + assertEquals(1, response.getCampuses().size()); + + final Campus campus = response.getCampuses().get(0); + + assertEquals(1, campus.getId()); + assertEquals("Sample Church", campus.getName()); + assertEquals(true, campus.isActive()); + } +}
\ No newline at end of file diff --git a/src/test/resources/com/p4square/ccbapi/model/ccb_campus_list_response.xml b/src/test/resources/com/p4square/ccbapi/model/ccb_campus_list_response.xml new file mode 100644 index 0000000..d50d00e --- /dev/null +++ b/src/test/resources/com/p4square/ccbapi/model/ccb_campus_list_response.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ccb_api> + <request> + <parameters> + <argument value="campus_list" name="srv"/> + </parameters> + </request> + <response> + <service>campus_list</service> + <service_action>execute</service_action> + <availability>public</availability> + <campuses count="1"> + <campus id="1"> + <name>Sample Church</name> + <active>1</active> + <creator id="0">System User</creator> + <modifier id="12">System User</modifier> + <created>2015-10-22 16:52:44</created> + </campus> + </campuses> + </response> +</ccb_api> |