From 624e5d995c2fa593fb517a99e4b8b5f775afbeaf Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Wed, 6 Apr 2016 21:25:41 -0700 Subject: Adding getLookupTable API. --- .../java/com/p4square/ccbapi/CCBAPIClientTest.java | 31 +++++++++++++-- .../model/ccb_lookup_table_list_response.xml | 45 ++++++++++++++++++++++ 2 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 src/test/resources/com/p4square/ccbapi/model/ccb_lookup_table_list_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 69f50c2..b7d32e1 100644 --- a/src/test/java/com/p4square/ccbapi/CCBAPIClientTest.java +++ b/src/test/java/com/p4square/ccbapi/CCBAPIClientTest.java @@ -9,12 +9,9 @@ import java.io.IOException; import java.io.InputStream; import java.net.URI; import java.time.LocalDate; -import java.util.Collections; -import java.util.Map; import org.easymock.EasyMock; import org.junit.Test; -import org.junit.rules.ExpectedException; import static org.junit.Assert.*; @@ -110,6 +107,34 @@ public class CCBAPIClientTest { client.getCustomFieldLabels(); } + @Test + public void testGetLookupTableListSuccess() throws Exception { + // Set expectation. + URI expectedURI = new URI("https://localhost:8080/api.php?srv=significant_event_list"); + InputStream is = getClass().getResourceAsStream("model/ccb_lookup_table_list_response.xml"); + EasyMock.expect(mockHttpClient.sendPostRequest(expectedURI, null)) + .andReturn(is); + EasyMock.replay(mockHttpClient); + + // Test significant_event_list. + GetLookupTableResponse response = client.getLookupTable( + new GetLookupTableRequest().withType(LookupTableType.SIGNIFICANT_EVENT)); + + // Verify results. + EasyMock.verify(mockHttpClient); + assertNull(response.getErrors()); + assertEquals(5, response.getItems().size()); + assertEquals(1, response.getItems().get(0).getId()); + assertEquals(1, response.getItems().get(0).getOrder()); + assertEquals("High School Graduation", response.getItems().get(0).getName()); + } + + @Test(expected = IllegalArgumentException.class) + public void testGetLookupTableListWithNullType() throws Exception { + // This should throw an IllegalArgumentException. + client.getLookupTable(new GetLookupTableRequest()); + } + @Test public void testGetIndividualProfilesById() throws Exception { // Set expectation. diff --git a/src/test/resources/com/p4square/ccbapi/model/ccb_lookup_table_list_response.xml b/src/test/resources/com/p4square/ccbapi/model/ccb_lookup_table_list_response.xml new file mode 100644 index 0000000..632b02c --- /dev/null +++ b/src/test/resources/com/p4square/ccbapi/model/ccb_lookup_table_list_response.xml @@ -0,0 +1,45 @@ + + + + + + + + + significant_event_list + execute + public + + + 1 + 1 + High School Graduation + 1 + + + 2 + 2 + College Graduation + 2 + + + 3 + 3 + Moved Into Town + 3 + + + 4 + 4 + Moved Out of Town + 4 + + + 5 + 5 + Dedicated at Baby Dedication + 5 + + + + \ No newline at end of file -- cgit v1.2.3