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 +++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'src/test/java/com/p4square/ccbapi/CCBAPIClientTest.java') 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. -- cgit v1.2.3