View Javadoc
1   /**
2    * Copyright 2005-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kim.test.service;
17  
18  import org.joda.time.DateTime;
19  import org.joda.time.format.DateTimeFormat;
20  import org.joda.time.format.DateTimeFormatter;
21  import org.junit.Ignore;
22  import org.junit.Test;
23  import org.kuali.rice.core.api.membership.MemberType;
24  import org.kuali.rice.core.api.util.type.KualiDecimal;
25  import org.kuali.rice.kew.api.WorkflowDocument;
26  import org.kuali.rice.kew.api.WorkflowDocumentFactory;
27  import org.kuali.rice.kim.api.KimConstants;
28  import org.kuali.rice.kim.api.identity.IdentityService;
29  import org.kuali.rice.kim.api.identity.Person;
30  import org.kuali.rice.kim.api.identity.address.EntityAddressContract;
31  import org.kuali.rice.kim.api.identity.affiliation.EntityAffiliation;
32  import org.kuali.rice.kim.api.identity.email.EntityEmailContract;
33  import org.kuali.rice.kim.api.identity.employment.EntityEmploymentContract;
34  import org.kuali.rice.kim.api.identity.entity.Entity;
35  import org.kuali.rice.kim.api.identity.name.EntityNameContract;
36  import org.kuali.rice.kim.api.identity.phone.EntityPhoneContract;
37  import org.kuali.rice.kim.api.identity.principal.PrincipalContract;
38  import org.kuali.rice.kim.api.identity.type.EntityTypeContactInfo;
39  import org.kuali.rice.kim.api.role.RoleMember;
40  import org.kuali.rice.kim.api.role.RoleMemberContract;
41  import org.kuali.rice.kim.api.services.KimApiServiceLocator;
42  import org.kuali.rice.kim.bo.ui.KimDocumentRoleMember;
43  import org.kuali.rice.kim.bo.ui.PersonDocumentAddress;
44  import org.kuali.rice.kim.bo.ui.PersonDocumentAffiliation;
45  import org.kuali.rice.kim.bo.ui.PersonDocumentEmail;
46  import org.kuali.rice.kim.bo.ui.PersonDocumentEmploymentInfo;
47  import org.kuali.rice.kim.bo.ui.PersonDocumentName;
48  import org.kuali.rice.kim.bo.ui.PersonDocumentPhone;
49  import org.kuali.rice.kim.bo.ui.PersonDocumentPrivacy;
50  import org.kuali.rice.kim.bo.ui.PersonDocumentRole;
51  import org.kuali.rice.kim.document.IdentityManagementPersonDocument;
52  import org.kuali.rice.kim.framework.type.KimTypeService;
53  import org.kuali.rice.kim.impl.identity.address.EntityAddressTypeBo;
54  import org.kuali.rice.kim.impl.identity.affiliation.EntityAffiliationTypeBo;
55  import org.kuali.rice.kim.impl.identity.email.EntityEmailTypeBo;
56  import org.kuali.rice.kim.impl.identity.name.EntityNameTypeBo;
57  import org.kuali.rice.kim.impl.identity.phone.EntityPhoneTypeBo;
58  import org.kuali.rice.kim.impl.identity.privacy.EntityPrivacyPreferencesBo;
59  import org.kuali.rice.kim.impl.role.RoleMemberBo;
60  import org.kuali.rice.kim.impl.type.KimTypeAttributeBo;
61  import org.kuali.rice.kim.impl.type.KimTypeBo;
62  import org.kuali.rice.kim.service.KIMServiceLocatorInternal;
63  import org.kuali.rice.kim.service.UiDocumentService;
64  import org.kuali.rice.kim.test.KIMTestCase;
65  import org.kuali.rice.kns.kim.type.DataDictionaryTypeServiceBase;
66  import org.kuali.rice.krad.service.KRADServiceLocator;
67  import org.kuali.rice.test.BaselineTestCase;
68  
69  import java.lang.reflect.Field;
70  import java.util.ArrayList;
71  import java.util.Arrays;
72  import java.util.HashMap;
73  import java.util.List;
74  import java.util.Map;
75  
76  import static org.junit.Assert.*;
77  
78  /**
79   * This is a description of what this class does - shyu don't forget to fill this in.
80   *
81   * @author Kuali Rice Team (rice.collab@kuali.org)
82   *
83   */
84  @BaselineTestCase.BaselineMode(BaselineTestCase.Mode.CLEAR_DB)
85  public class UiDocumentServiceImplTest extends KIMTestCase {
86  
87  	private UiDocumentService uiDocumentService;
88  
89      @Override
90  	public void setUp() throws Exception {
91  		super.setUp();
92  		uiDocumentService = KIMServiceLocatorInternal.getUiDocumentService();
93  	}
94  
95  	@Test
96  	public void testSaveToEntity() {
97  	    Person adminPerson = KimApiServiceLocator.getPersonService().getPersonByPrincipalName("admin");
98  		IdentityManagementPersonDocument personDoc = initPersonDoc();
99  
100 		/*try {*/
101             //personDoc.getDocumentHeader().setWorkflowDocument(KRADServiceLocatorWeb.getWorkflowDocumentService().createWorkflowDocument("TestDocumentType", adminPerson));
102             WorkflowDocument document = WorkflowDocumentFactory.createDocument(adminPerson.getPrincipalId(),"TestDocumentType");
103             personDoc.getDocumentHeader().setWorkflowDocument(document);
104         /*} catch (WorkflowException e) {
105             e.printStackTrace();
106         }*/
107 		uiDocumentService.saveEntityPerson(personDoc);
108         Map<String, String> criteria = new HashMap<String, String>();
109         criteria.put("id", "entity124eId");
110         criteria.put("entityTypeCode", "PERSON");
111 
112 		Entity entity = KimApiServiceLocator.getIdentityService().getEntity(personDoc.getEntityId());
113         EntityTypeContactInfo entityType = entity.getEntityTypeContactInfos().get(0);
114         personDoc.getExternalIdentifiers();
115 		assertAddressTrue((PersonDocumentAddress)personDoc.getAddrs().get(0), entityType.getAddresses().get(0));
116 		assertPhoneTrue((PersonDocumentPhone)personDoc.getPhones().get(0), entityType.getPhoneNumbers().get(0));
117 		assertEmailTrue((PersonDocumentEmail)personDoc.getEmails().get(0), entityType.getEmailAddresses().get(0));
118 		assertNameTrue((PersonDocumentName) personDoc.getNames().get(0), entity.getNames().get(0));
119 		assertPrincipalTrue(personDoc, entity.getPrincipals().get(0));
120 
121 		assertAffiliationTrue(personDoc.getAffiliations().get(0), entity.getAffiliations().get(0));
122 		assertEmpInfoTrue(personDoc.getAffiliations().get(0).getEmpInfos().get(0), entity.getEmploymentInformation().get(0));
123 
124 		//verify that update doesn't cause external identifier to be encrypted twice
125 		// and that update doesn't cause any problems
126 		uiDocumentService.saveEntityPerson(personDoc);
127 		Entity entity2 = ((IdentityService) KIMServiceLocatorInternal.getService("kimIdentityDelegateService")).getEntity(
128                 personDoc.getEntityId());
129         EntityTypeContactInfo entityType2 = entity2.getEntityTypeContactInfos().get(0);
130         personDoc.getExternalIdentifiers();
131         assertAddressTrue((PersonDocumentAddress)personDoc.getAddrs().get(0), entityType2.getAddresses().get(0));
132         assertPhoneTrue((PersonDocumentPhone)personDoc.getPhones().get(0), entityType2.getPhoneNumbers().get(0));
133         assertEmailTrue((PersonDocumentEmail)personDoc.getEmails().get(0), entityType2.getEmailAddresses().get(0));
134         assertNameTrue((PersonDocumentName)personDoc.getNames().get(0), entity2.getNames().get(0));
135         assertPrincipalTrue(personDoc, entity2.getPrincipals().get(0));
136 
137 
138 
139 		//		List<String> groupIds = groupService.getDirectMemberGroupIds("g1");
140 //		System.out.println( groupIds );
141 //		assertTrue( "g1 must contain group g2", groupIds.contains( "g2" ) );
142 //		assertFalse( "g1 must not contain group g3", groupIds.contains( "g3" ) );
143 //
144 //		groupIds = groupService.getDirectMemberGroupIds("g2");
145 //		System.out.println( groupIds );
146 //		assertTrue( "g2 must contain group g3", groupIds.contains( "g3" ) );
147 //		assertFalse( "g2 must not contain group g4 (inactive)", groupIds.contains( "g4" ) );
148 
149 	}
150 
151 	@Test
152 	public void testLoadToPersonDocument() {
153 
154 		Entity entity = KimApiServiceLocator.getIdentityService().getEntity("entity123eId");
155 		assertNotNull(entity);
156 		IdentityManagementPersonDocument personDoc = new IdentityManagementPersonDocument();
157 		uiDocumentService.loadEntityToPersonDoc(personDoc, "entity123pId");
158         EntityTypeContactInfo entityType = entity.getEntityTypeContactInfos().get(0);
159         personDoc.getExternalIdentifiers();
160 		assertAddressTrue((PersonDocumentAddress)personDoc.getAddrs().get(0), entityType.getAddresses().get(0));
161 		assertPhoneTrue((PersonDocumentPhone)personDoc.getPhones().get(0), entityType.getPhoneNumbers().get(0));
162 		assertEmailTrue((PersonDocumentEmail)personDoc.getEmails().get(0), entityType.getEmailAddresses().get(0));
163 		assertNameTrue((PersonDocumentName)personDoc.getNames().get(0), entity.getNames().get(0));
164 		//assertPrincipalTrue(personDoc, identity.getPrincipals().get(0));
165 		assertAffiliationTrue(personDoc.getAffiliations().get(0), entity.getAffiliations().get(0));
166 		assertEmpInfoTrue(personDoc.getAffiliations().get(0).getEmpInfos().get(0), entity.getEmploymentInformation().get(0));
167 
168 	}
169 
170 	// test principal membership
171 	@Test
172 	@Ignore
173 	public void testSetAttributeEntry() throws Exception {
174 		PersonDocumentRole personDocRole = initPersonDocRole();
175         KimTypeService kimTypeService = (DataDictionaryTypeServiceBase) KIMServiceLocatorInternal.getService(personDocRole.getKimRoleType().getServiceName());
176 		personDocRole.setDefinitions(kimTypeService.getAttributeDefinitions(personDocRole.getKimTypeId()));
177 
178 		personDocRole.setAttributeEntry( uiDocumentService.getAttributeEntries( personDocRole.getDefinitions() ) );
179 		for (Object key : personDocRole.getAttributeEntry().keySet()) {
180 			if (key.equals(KimConstants.AttributeConstants.NAMESPACE_CODE)) {
181 				Map value = (Map)personDocRole.getAttributeEntry().get(key);
182 				assertEquals("Parameter Namespace Code", value.get("label"));
183 				assertEquals("Nmspc Cd", value.get("shortLabel"));
184 				assertEquals(new Integer(20), value.get("maxLength"));
185 			} else if (key.equals("campusCode")) {
186 				Map value = (Map)personDocRole.getAttributeEntry().get(key);
187 				assertEquals("Campus Code", value.get("label"));
188 				assertEquals("Campus Code", value.get("shortLabel"));
189 				assertEquals(new Integer(2), value.get("maxLength"));
190 			} else {
191 				assertFalse("Should not have this key "+key, true);
192 			}
193 		}
194 	}
195 
196 	private PersonDocumentRole initPersonDocRole() throws Exception {
197 //		Map pkMap = new HashMap();
198 //		pkMap.put("roleId", "r1");
199 //		PersonDocumentRole docRole = (PersonDocumentRole)uiDocumentService.getBusinessObjectService().findByPrimaryKey(PersonDocumentRole.class, pkMap);
200 		PersonDocumentRole docRole = new PersonDocumentRole();
201 		docRole.setKimTypeId("roleType1");
202 		docRole.setRoleId("r1");
203 		KimTypeBo kimType = new KimTypeBo();
204 		kimType.setId("roleType1");
205 		kimType.setServiceName("kimRoleTypeService");
206 		List<KimTypeAttributeBo> attributeDefinitions = new ArrayList<KimTypeAttributeBo>();
207 		Map pkMap = new HashMap();
208 		pkMap.put("kimTypeAttributeId", "kimAttr3");
209 		KimTypeAttributeBo attr1 = (KimTypeAttributeBo) KRADServiceLocator.getBusinessObjectService().findByPrimaryKey(KimTypeAttributeBo.class, pkMap);
210 
211 //		attr1.setKimAttributeId("kimAttrDefn2");
212 //		attr1.setSortCode("a");
213 //		attr1.setKimTypeAttributeId("kimAttr3");
214 
215 		attributeDefinitions.add(attr1);
216 //		attr1 = new KimTypeAttributeBo();
217 //		attr1.setKimAttributeId("kimAttrDefn3");
218 //		attr1.setSortCode("b");
219 //		attr1.setKimTypeAttributeId("kimAttr4");
220 
221 		pkMap.put("kimTypeAttributeId", "kimAttr4");
222 		KimTypeAttributeBo attr2 = (KimTypeAttributeBo) KRADServiceLocator.getBusinessObjectService().findByPrimaryKey(KimTypeAttributeBo.class, pkMap);
223 
224 		attributeDefinitions.add(attr2);
225 		kimType.setAttributeDefinitions(attributeDefinitions);
226 
227         Field fld = PersonDocumentRole.class.getField("kimRoleType");
228         fld.set(docRole, kimType);
229 
230 		return docRole;
231 	}
232 
233 	// init section
234 	private IdentityManagementPersonDocument initPersonDoc() {
235 		IdentityManagementPersonDocument personDoc = new IdentityManagementPersonDocument();
236 		personDoc.setEntityId("ent123");
237 		personDoc.setDocumentNumber("1");
238 		personDoc.setPrincipalId("pid123");
239 		personDoc.setPrincipalName("quickTest");
240 //		personDoc.setUnivId("1234567890");
241 		personDoc.setAffiliations(initAffiliations());
242 		personDoc.setNames(initNames());
243 		personDoc.setAddrs(initAddresses());
244 		//personDoc.setRoles(initRoles());
245 		//personDoc.setGroups();
246 		personDoc.setPhones(initPhones());
247 		personDoc.setEmails(initEmails());
248 		return personDoc;
249 	}
250 
251 	private List<PersonDocumentName> initNames() {
252 		List<PersonDocumentName> docNames = new ArrayList<PersonDocumentName>();
253 			PersonDocumentName docName = new PersonDocumentName();
254 			docName.setEntityNameId("nameId123");
255 			docName.setNameCode("PRFR");
256             docName.setEntityNameType(
257                     EntityNameTypeBo.from(KimApiServiceLocator.getIdentityService().getNameType("PRFR")));
258 			docName.setFirstName("John");
259 			docName.setLastName("Doe");
260 			docName.setMiddleName("M");
261 			docName.setNamePrefix("Mr");
262 			docName.setNameSuffix("Jr");
263 			docName.setActive(true);
264 			docName.setDflt(true);
265 			docNames.add(docName);
266 		return docNames;
267 	}
268 
269 	private List<PersonDocumentAffiliation> initAffiliations() {
270 		List<PersonDocumentAffiliation> docAffiliations = new ArrayList<PersonDocumentAffiliation>();
271 			PersonDocumentAffiliation docAffiliation = new PersonDocumentAffiliation();
272 			docAffiliation.setAffiliationTypeCode("FCLTY");
273             docAffiliation.setAffiliationType(
274                     EntityAffiliationTypeBo.from(KimApiServiceLocator.getIdentityService().getAffiliationType("FCLTY")));
275 			docAffiliation.setEntityAffiliationId("aflID123");
276 			docAffiliation.setCampusCode("BL");
277 			docAffiliation.setActive(true);
278 			docAffiliation.setDflt(true);
279 
280 			// EntityAffiliationImpl does not define empinfos as collection
281 			docAffiliations.add(docAffiliation);
282 			List<PersonDocumentEmploymentInfo> docEmploymentInformations = new ArrayList<PersonDocumentEmploymentInfo>();
283 				PersonDocumentEmploymentInfo docEmpInfo = new PersonDocumentEmploymentInfo();
284 				docEmpInfo.setEmployeeId("12345");
285 				docEmpInfo.setEntityAffiliationId(docAffiliation.getEntityAffiliationId());
286 				docEmpInfo.setEntityEmploymentId("empId123");
287 				docEmpInfo.setEmploymentRecordId("1");
288 				docEmpInfo.setBaseSalaryAmount(new KualiDecimal(8000));
289 				docEmpInfo.setPrimaryDepartmentCode("BL-CHEM");
290 				docEmpInfo.setEmploymentStatusCode("A");
291 				docEmpInfo.setEmploymentTypeCode("P");
292 				docEmpInfo.setActive(true);
293 				docEmploymentInformations.add(docEmpInfo);
294 			docAffiliation.setEmpInfos(docEmploymentInformations);
295 
296 		return docAffiliations;
297 
298 	}
299 
300 	private PersonDocumentPrivacy initPrivacyReferences(EntityPrivacyPreferencesBo privacyPreferences) {
301 		PersonDocumentPrivacy docPrivacy = new PersonDocumentPrivacy();
302 		docPrivacy.setSuppressAddress(true);
303 		docPrivacy.setSuppressEmail(false);
304 		docPrivacy.setSuppressName(false);
305 		docPrivacy.setSuppressPhone(false);
306 		docPrivacy.setSuppressPersonal(true);
307 		return docPrivacy;
308 	}
309 	private List<PersonDocumentPhone> initPhones() {
310 		List<PersonDocumentPhone> docPhones = new ArrayList<PersonDocumentPhone>();
311 			PersonDocumentPhone docPhone = new PersonDocumentPhone();
312 			docPhone.setPhoneTypeCode("HM");
313             docPhone.setPhoneType(EntityPhoneTypeBo.from(KimApiServiceLocator.getIdentityService().getPhoneType("HM")));
314 			docPhone.setEntityPhoneId("phoneId123");
315 			docPhone.setEntityTypeCode("PERSON");
316 			docPhone.setPhoneNumber("123-45'6789");
317 			docPhone.setExtensionNumber("123");
318 			docPhone.setActive(true);
319 			docPhone.setDflt(true);
320 			docPhones.add(docPhone);
321 		return  docPhones;
322 
323 	}
324 
325 	private List<PersonDocumentEmail> initEmails() {
326 		List<PersonDocumentEmail> emails = new ArrayList<PersonDocumentEmail>();
327 			PersonDocumentEmail docEmail = new PersonDocumentEmail();
328 			//docEmail.setEntityId(email.getEntityId());
329 			docEmail.setEntityEmailId("emailId123");
330 			docEmail.setEntityTypeCode("PERSON");
331 			docEmail.setEmailTypeCode("HM");
332             docEmail.setEmailType(
333                     EntityEmailTypeBo.from(KimApiServiceLocator.getIdentityService().getEmailType("HM")));
334 			docEmail.setEmailAddress("test@abc.com");
335 			docEmail.setActive(true);
336 			docEmail.setDflt(true);
337 			emails.add(docEmail);
338 		return emails;
339 	}
340 
341 	private  List<PersonDocumentAddress> initAddresses() {
342 		List<PersonDocumentAddress> docAddresses = new ArrayList<PersonDocumentAddress>();
343 			PersonDocumentAddress docAddress = new PersonDocumentAddress();
344 			docAddress.setEntityTypeCode("PERSON");
345 			docAddress.setEntityAddressId("addrId123");
346 			docAddress.setAddressTypeCode("HM");
347             docAddress.setAddressType(EntityAddressTypeBo.from(KimApiServiceLocator.getIdentityService().getAddressType("HM")));
348 			docAddress.setLine1("PO box 123");
349 			docAddress.setStateProvinceCode("IN");
350 			docAddress.setPostalCode("46123");
351 			docAddress.setCountryCode("US");
352 			docAddress.setCity("Indianapolis");
353 			docAddress.setActive(true);
354 			docAddress.setDflt(true);
355 			docAddresses.add(docAddress);
356 		return docAddresses;
357 	}
358 
359 // assert section
360 
361 	private void assertPrincipalTrue(IdentityManagementPersonDocument personDoc, PrincipalContract principal) {
362 		assertEquals(personDoc.getPrincipalId(), principal.getPrincipalId());
363 		assertEquals(personDoc.getPrincipalName(), principal.getPrincipalName());
364 	}
365 
366 	private void assertAddressTrue(PersonDocumentAddress docAddress, EntityAddressContract entityAddress) {
367 
368 		assertEquals(docAddress.getAddressTypeCode(), entityAddress.getAddressType().getCode());
369 		assertEquals(docAddress.getCountryCode(), entityAddress.getCountryCode());
370 		assertEquals(docAddress.getLine1(), entityAddress.getLine1());
371 		assertEquals(docAddress.getCity(), entityAddress.getCity());
372 		assertEquals(docAddress.getPostalCode(), entityAddress.getPostalCode());
373 		assertEquals(docAddress.getStateProvinceCode(), entityAddress.getStateProvinceCode());
374 	}
375 
376 	private void assertEmailTrue(PersonDocumentEmail docEmail, EntityEmailContract entityEmail) {
377 		assertEquals(docEmail.getEntityEmailId(), entityEmail.getId());
378 		assertEquals(docEmail.getEmailAddress(), entityEmail.getEmailAddressUnmasked());
379 		assertEquals(docEmail.getEmailTypeCode(), entityEmail.getEmailType().getCode());
380 	}
381 
382 	private void assertPhoneTrue(PersonDocumentPhone docPhone, EntityPhoneContract entityPhone) {
383 		assertEquals(docPhone.getEntityPhoneId(), entityPhone.getId());
384 		assertEquals(docPhone.getCountryCode(), entityPhone.getCountryCode());
385 		assertEquals(docPhone.getPhoneNumber(), entityPhone.getPhoneNumber());
386 		assertEquals(docPhone.getExtensionNumber(), entityPhone.getExtensionNumber());
387 		assertEquals(docPhone.getPhoneTypeCode(), entityPhone.getPhoneType().getCode());
388 	}
389 
390 	private void assertNameTrue(PersonDocumentName docName, EntityNameContract entityName) {
391 		assertEquals(docName.getEntityNameId(), entityName.getId());
392 		assertEquals(docName.getFirstName(), entityName.getFirstName());
393 		assertEquals(docName.getLastName(), entityName.getLastName());
394 		assertEquals(docName.getNameCode(), entityName.getNameType().getCode());
395 		assertEquals(docName.getNameSuffix(), entityName.getNameSuffix());
396 		assertEquals(docName.getNamePrefix(), entityName.getNamePrefix());
397 	}
398 
399 	private void assertAffiliationTrue(PersonDocumentAffiliation docAffln, EntityAffiliation entityAffln) {
400 		assertEquals(docAffln.getAffiliationTypeCode(), entityAffln.getAffiliationType().getCode());
401 		assertEquals(docAffln.getCampusCode(), entityAffln.getCampusCode());
402 		assertEquals(docAffln.getEntityAffiliationId(), entityAffln.getId());
403 	}
404 
405 	private void assertEmpInfoTrue(PersonDocumentEmploymentInfo docEmpInfo, EntityEmploymentContract entityEmpInfo) {
406 		assertEquals(docEmpInfo.getEmployeeId(), entityEmpInfo.getEmployeeId());
407 		assertEquals(docEmpInfo.getEmploymentTypeCode(), entityEmpInfo.getEmployeeType().getCode());
408 		assertEquals(docEmpInfo.getEmploymentStatusCode(), entityEmpInfo.getEmployeeStatus().getCode());
409 		assertEquals(docEmpInfo.getEmploymentRecordId(), entityEmpInfo.getEmploymentRecordId());
410 		assertEquals(docEmpInfo.getBaseSalaryAmount(), entityEmpInfo.getBaseSalaryAmount());
411 	}
412 
413     @Test
414     public void test_KimDocumentRoleMember_copyProperties() {
415         //
416         // KimDocumentRoleMember.copyProperties is called by the UiDocumentServiceImpl.getRoleMembers
417         // method.  This test verifies that KimDocumentRoleMember.copyProperties is working as
418         // expected and also will fail if fields are added to KimDocumentRoleMember to ensure that
419         // KimDocumentRoleMember.copyProperties is kept up to date.
420         //
421 
422         DateTimeFormatter FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
423         String ROLE_MEMBER_ID = "1";
424         String ROLE_ID = "23";
425         Map<String, String> ATTRIBUTES = new HashMap<String, String>();
426         String MEMBER_NAME = "WorkflowAdmin";
427         String MEMBER_NAMESPACE_CODE = "KR-WKFLW";
428         String MEMBER_ID = "1";
429         MemberType MEMBER_TYPE = MemberType.GROUP;
430         String ACTIVE_FROM_STRING = "2011-01-01 12:00:00";
431         DateTime ACTIVE_FROM = new DateTime(FORMATTER.parseDateTime(ACTIVE_FROM_STRING));
432         String ACTIVE_TO_STRING = "2115-01-01 12:00:00";
433         DateTime ACTIVE_TO = new DateTime(FORMATTER.parseDateTime(ACTIVE_TO_STRING));
434         String OBJ_ID = "123";
435         long VER_NUM = 4;
436 
437         KimDocumentRoleMember newKimDocumentRoleMember = new KimDocumentRoleMember();
438 
439         RoleMemberContract rmc = RoleMember.Builder.create(ROLE_ID, ROLE_MEMBER_ID, MEMBER_ID, MEMBER_TYPE, ACTIVE_FROM,
440                 ACTIVE_TO, ATTRIBUTES, MEMBER_NAME, MEMBER_NAMESPACE_CODE).build();
441         RoleMember rm = RoleMember.Builder.create(rmc).build();
442         RoleMemberBo roleMemberBo = RoleMemberBo.from(rm);
443         roleMemberBo.setObjectId(OBJ_ID);
444         roleMemberBo.setVersionNumber(VER_NUM);
445 
446         KimDocumentRoleMember.copyProperties(newKimDocumentRoleMember, roleMemberBo);
447 
448         assertTrue("newKimDocumentRoleMember should have a roleId of " + ROLE_ID,
449                 newKimDocumentRoleMember.getRoleId().equals(ROLE_ID));
450         assertTrue("newKimDocumentRoleMember should have a MemberId of " + MEMBER_ID,
451                 newKimDocumentRoleMember.getMemberId().equals(MEMBER_ID));
452         assertTrue("newKimDocumentRoleMember should have a MemberName of " + MEMBER_NAME,
453                 newKimDocumentRoleMember.getMemberName().equals(MEMBER_NAME));
454         assertTrue("newKimDocumentRoleMember should have a MemberNamespaceCode of " + MEMBER_NAMESPACE_CODE,
455                 newKimDocumentRoleMember.getMemberNamespaceCode().equals(MEMBER_NAMESPACE_CODE));
456         assertTrue("newKimDocumentRoleMember should be active.",
457                 newKimDocumentRoleMember.isActive());
458         assertTrue("newKimDocumentRoleMember should have a ActiveToDate of " + MEMBER_NAMESPACE_CODE,
459                 newKimDocumentRoleMember.getActiveToDate().equals(roleMemberBo.getActiveToDateValue()));
460         assertTrue("newKimDocumentRoleMember should have a ActiveFromDate of " + ACTIVE_FROM_STRING,
461                 newKimDocumentRoleMember.getActiveFromDate().equals(roleMemberBo.getActiveFromDateValue()));
462         assertTrue("newKimDocumentRoleMember should have a VersionNumber of " + VER_NUM,
463                 newKimDocumentRoleMember.getVersionNumber().equals(VER_NUM));
464         assertTrue("newKimDocumentRoleMember should have a ObjectId of " + OBJ_ID,
465                 newKimDocumentRoleMember.getObjectId().equals(OBJ_ID));
466 
467         Class<?> c = newKimDocumentRoleMember.getClass();
468         Field[] fields = c.getDeclaredFields();
469         List<Field> fieldsList = Arrays.asList(fields);
470 
471         int numberOfFieldsInKimDocumentRoleMember = 11;
472         assertTrue("KimDocumentRoleMember.copyProperties may need to be updated if the number of fields"
473                 + "in KimDocumentRoleMember does not equal " + numberOfFieldsInKimDocumentRoleMember + ".  Size is " +
474                 fieldsList.size(), fieldsList.size() == numberOfFieldsInKimDocumentRoleMember);
475     }
476 }