Package org.kuali.rice.kim.impl.identity.entity

Examples of org.kuali.rice.kim.impl.identity.entity.EntityBo


   */
  protected void createPrincipal(String principalName, String affiliationCode, String namesFromUser) {
    SequenceAccessorService sas = KRADServiceLocator.getSequenceAccessorService();
    Long entityId = sas.getNextAvailableSequenceNumber(KimConstants.SequenceNames.KRIM_ENTITY_ID_S,
            EntityBo.class);
    EntityBo entityBo = new EntityBo();
    entityBo.setActive(true);
    entityBo.setId(String.valueOf(entityId));
   
    Long entityNameId = sas.getNextAvailableSequenceNumber(
        "KRIM_ENTITY_NM_ID_S", EntityNameBo.class);
    EntityNameBo name = new EntityNameBo();
    name.setActive(true);
    name.setId(String.valueOf(entityNameId));
    name.setEntityId(entityBo.getId());
    // must be in krim_ent_nm_typ_t.ent_nm_typ_cd
    name.setNameCode("PRFR");
    name.setFirstName(getFirstName(namesFromUser));
    name.setMiddleName(getMiddleName(namesFromUser));
    name.setLastName(getLastName(namesFromUser));
    name.setDefaultValue(true);

    Long entityAffilId = sas.getNextAvailableSequenceNumber("KRIM_ENTITY_AFLTN_ID_S", EntityAffiliationBo.class);
    EntityAffiliationBo affilBo = new EntityAffiliationBo();
    affilBo.setActive(true);
    affilBo.setDefaultValue(true);
    affilBo.setId(String.valueOf(entityAffilId));
    affilBo.setAffiliationTypeCode(affiliationCode);
    affilBo.setEntityId(entityBo.getId());
   
    List<EntityTypeContactInfoBo> entityTypes = new ArrayList<EntityTypeContactInfoBo>();
    EntityTypeContactInfoBo entityType = new EntityTypeContactInfoBo();
    entityType.setEntityId(entityBo.getId());
    entityType.setEntityTypeCode(KimConstants.EntityTypes.PERSON);
    entityType.setActive(true);
    entityTypes.add(entityType);
    entityBo.setEntityTypeContactInfos(entityTypes);
   
    KimApiServiceLocator.getIdentityService().createEntity(EntityBo.to(entityBo));
    getBusinessObjectService().save(affilBo);
    getBusinessObjectService().save(name);
   
View Full Code Here


    successHandler.setEntityInfoService(entityInfoSvc);
    String expected = "Email address '" + emailFromOpenId + "' is not associated with an existing user :(";
    assertEquals("entity should not be found", expected, successHandler.getActivationMessage());
   
    // provide a mock entity object
    EntityBo entity = new EntityBo();
    EntityNameBo defaultName = new EntityNameBo();
    defaultName.setActive(true);
    defaultName.setDefaultValue(true);
    final String firstName = "Karani";
    defaultName.setFirstName(firstName);
    entity.getNames().add(defaultName);
    when(entityInfoSvc.getEntityByEmail(emailFromOpenId)).thenReturn(entity);
    // prepare the entity email to be found and so that the mock entity can be returned
    EntityEmailBo emailBo = new EntityEmailBo();
    final String entityId = "entity1";
    emailBo.setEntityId(entityId);
    List<EntityEmailBo> result = new ArrayList<EntityEmailBo>();
    result.add(emailBo);
    when(boSvc.findMatching(same(EntityEmailBo.class), anyMapOf(String.class, String.class))).thenReturn(result);
   
    // test that only active users with staff affiliation can log in
    // entity.setActive(true); - does not matter
    List<EntityAffiliationBo> affils = new ArrayList<EntityAffiliationBo>();
    entity.setAffiliations(affils);
    expected = "You are not affiliated as a staff :(";
    assertEquals("no affilitiations", expected, successHandler.getActivationMessage());
   
    // test that only active, affiliated users can log in
    EntityAffiliationBo affil = new EntityAffiliationBo();
    EntityAffiliationTypeBo affilType = mock(EntityAffiliationTypeBo.class);
    when(affilType.isEmploymentAffiliationType()).thenReturn(true);
    when(affilType.isActive()).thenReturn(true);
    affil.setAffiliationType(affilType);
    affils.add(affil);
    entity.setActive(false);
    expected = "Your account is not active :(";
    assertEquals("account inactive", expected, successHandler.getActivationMessage());
   
    entity.setActive(true);
   
    // simulate that email configs and other properties are present are ok
    ConfigurationService cfgSvc = mock(ConfigurationService.class);
    when(cfgSvc.getPropertyValueAsString(anyString())).thenReturn("niko");
    final String sendingEmail = "mlaw.unt@mlaw.co.ke";
View Full Code Here

TOP

Related Classes of org.kuali.rice.kim.impl.identity.entity.EntityBo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.