diff options
author | Jesse Morgan <jesse@jesterpm.net> | 2016-04-06 21:25:41 -0700 |
---|---|---|
committer | Jesse Morgan <jesse@jesterpm.net> | 2016-04-06 21:26:19 -0700 |
commit | 624e5d995c2fa593fb517a99e4b8b5f775afbeaf (patch) | |
tree | c6080ebbf909fb45fb055930abe64bbfb62a41f0 /src/test | |
parent | 7367968483e4ddfedfa47598c508b343b44fc852 (diff) |
Adding getLookupTable API.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/com/p4square/ccbapi/CCBAPIClientTest.java | 31 | ||||
-rw-r--r-- | src/test/resources/com/p4square/ccbapi/model/ccb_lookup_table_list_response.xml | 45 |
2 files changed, 73 insertions, 3 deletions
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.*; @@ -111,6 +108,34 @@ public class CCBAPIClientTest { } @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. URI expectedURI = new URI("https://localhost:8080/api.php?srv=individual_profile_from_id&individual_id=48"); 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ccb_api> + <request> + <parameters> + <argument value="significant_event_list" name="srv"/> + </parameters> + </request> + <response> + <service>significant_event_list</service> + <service_action>execute</service_action> + <availability>public</availability> + <items count="5"> + <item> + <item_id type="significant_event">1</item_id> + <id>1</id> + <name>High School Graduation</name> + <order>1</order> + </item> + <item> + <item_id type="significant_event">2</item_id> + <id>2</id> + <name>College Graduation</name> + <order>2</order> + </item> + <item> + <item_id type="significant_event">3</item_id> + <id>3</id> + <name>Moved Into Town</name> + <order>3</order> + </item> + <item> + <item_id type="significant_event">4</item_id> + <id>4</id> + <name>Moved Out of Town</name> + <order>4</order> + </item> + <item> + <item_id type="significant_event">5</item_id> + <id>5</id> + <name>Dedicated at Baby Dedication</name> + <order>5</order> + </item> + </items> + </response> +</ccb_api>
\ No newline at end of file |