1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.test.service;
17
18 import org.junit.Test;
19 import org.kuali.rice.kim.bo.entity.KimEntity;
20 import org.kuali.rice.kim.bo.entity.KimEntityEntityType;
21 import org.kuali.rice.kim.bo.entity.KimPrincipal;
22 import org.kuali.rice.kim.service.IdentityService;
23 import org.kuali.rice.kim.service.KIMServiceLocator;
24 import org.kuali.rice.kim.test.KIMTestCase;
25
26
27
28
29
30 public class IdentityServiceImplTest extends KIMTestCase {
31
32 private IdentityService identityService;
33
34 public void setUp() throws Exception {
35 super.setUp();
36 identityService = (IdentityService) KIMServiceLocator.getBean("kimIdentityDelegateService");
37 }
38
39 @Test
40 public void testGetPrincipal() {
41 KimPrincipal principal = identityService.getPrincipal("KULUSER");
42 assertNotNull("principal must not be null", principal);
43 assertEquals("Principal name did not match expected result","kuluser", principal.getPrincipalName());
44 }
45
46 @Test
47 public void testGetPrincipalByPrincipalName() {
48 KimPrincipal principal = identityService.getPrincipalByPrincipalName("kuluser");
49 assertNotNull("principal must not be null", principal);
50 assertEquals("Principal ID did not match expected result","KULUSER", principal.getPrincipalId());
51 }
52
53 @Test
54 public void testGetContainedAttributes() {
55 KimPrincipal principal = identityService.getPrincipal("p1");
56
57 KimEntity entity = identityService.getEntityInfo( principal.getEntityId() );
58 assertNotNull( "Entity Must not be null", entity );
59 KimEntityEntityType eet = entity.getEntityType( "PERSON" );
60 assertNotNull( "PERSON EntityEntityType Must not be null", eet );
61 assertEquals( "there should be 1 email address", 1, eet.getEmailAddresses().size() );
62 assertEquals( "email address does not match", "p1@kuali.org", eet.getDefaultEmailAddress().getEmailAddressUnmasked() );
63 }
64
65 }