summaryrefslogtreecommitdiff
path: root/src/test/java/com/p4square/ccbapi/model/GetIndividualProfilesResponseTest.java
blob: 743a9f7f729ecf77a0d4b302f30c7d331ea5fbf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.p4square.ccbapi.model;

import org.junit.Test;

import static org.junit.Assert.*;

/**
 * Tests for parsing GetIndividualProfilesResponse.
 */
public class GetIndividualProfilesResponseTest extends XmlBinderTestBase {

    /**
     * Assert that all of the fields bind appropriately for a single profile response.
     */
    @Test
    public void testGetIndividualProfilesResponse() throws Exception {
        final GetIndividualProfilesResponse response = parseFile("ccb_individual_profile_response.xml",
                GetIndividualProfilesResponse.class);

        assertNull("Response should not have errors", response.getErrors());
        assertNotNull(response.getIndividuals());
        assertEquals(1, response.getIndividuals().size());

        final IndividualProfile profile = response.getIndividuals().get(0);

        // IDs
        assertEquals(48, profile.getId());
        assertEquals(123, profile.getSyncId());
        assertEquals(456, profile.getOtherId());

        // Family
        assertEquals(36, profile.getFamily().getFamilyId());
        assertEquals("The Bob Family", profile.getFamily().getName());
        assertEquals("https://cdn3.ccbchurch.com/preSTABLE/images/group-default.gif", profile.getFamilyImageUrl());
        assertEquals(FamilyPosition.PRIMARY_CONTACT, profile.getFamilyPosition());
        assertEquals(1, profile.getFamilyMembers().size());

        // Mrs. Bob
        assertEquals(49, profile.getFamilyMembers().get(0).getIndividualReference().getIndividualId());
        assertEquals("Mrs. Bob", profile.getFamilyMembers().get(0).getIndividualReference().getName());
        assertEquals(FamilyPosition.SPOUSE, profile.getFamilyMembers().get(0).getFamilyPosition());

        // Names
        assertEquals("Mr.", profile.getSalutation());
        assertEquals("Larry", profile.getFirstName());
        assertEquals("", profile.getMiddleName());
        assertEquals("Bob", profile.getLastName());
        assertEquals("", profile.getSuffix());
        assertEquals("Larabar", profile.getLegalFirstName());
        assertEquals("Larry Bob", profile.getFullName());

        // Other Attributes
        assertEquals("https://cdn3.ccbchurch.com/preSTABLE/images/profile-default.gif", profile.getImageUrl());
        assertEquals("tsebastian@churchcommunitybuilder.com", profile.getEmail());
        assertEquals("", profile.getAllergies());
        assertEquals(true, profile.isConfirmedNoAllergies());
        assertEquals(Gender.MALE, profile.getGender());
        assertEquals("1990-04-05", profile.getBirthday().toString());
    }
}