@Test
 public void testGetEntityWithNameChangeDate() {
   String principalName = "testuser7";
   Entity info = identityService.getEntityByPrincipalName(principalName);
   List<EntityName> names = info.getNames();
   for (EntityName name : names) {
     assertNotNull(
         "nameChangeDate should have been set for PrincipalName " + principalName,
         name.getNameChangedDate());
   }
 }
 @Test
 public void testLookupEntityInfo() {
   String principalIdToTest = "p1";
   List<Entity> results =
       identityService.findEntities(setUpEntityLookupCriteria(principalIdToTest)).getResults();
   assertNotNull("Lookup results should never be null", results);
   assertEquals("Lookup result count is invalid", 1, results.size());
   for (Entity kimEntityInfo : results) {
     assertEquals(
         "Entity should have only one principal for this test",
         1,
         kimEntityInfo.getPrincipals().size());
     assertEquals(
         "Principal Ids should match",
         principalIdToTest,
         kimEntityInfo.getPrincipals().get(0).getPrincipalId());
   }
 }
 @Test
 public void testGetEntityByPrincipalName() {
   String principalName = "kuluser";
   Entity info = identityService.getEntityByPrincipalName(principalName);
   assertNotNull("entity must not be null", info);
   assertNotNull("entity principals must not be null", info.getPrincipals());
   assertEquals("entity must have exactly 1 principal", 1, info.getPrincipals().size());
   for (Principal principalInfo : info.getPrincipals()) {
     assertEquals("Wrong principal name", principalName, principalInfo.getPrincipalName());
   }
   assertTrue(
       "entity external identifiers must not be null",
       (info.getExternalIdentifiers() == null) || info.getExternalIdentifiers().isEmpty());
   assertTrue(
       "entity residencies must not be null",
       (info.getResidencies() == null) || info.getResidencies().isEmpty());
 }