Search in sources :

Example 31 with ValueGeneratorDto

use of eu.bcvsolutions.idm.core.api.dto.ValueGeneratorDto in project CzechIdMng by bcvsolutions.

the class DefaultValueGeneratorManager method toDto.

/**
 * Transform {@link ValueGenerator} to {@link ValueGeneratorDto}.
 * {@link ValueGeneratorDto} was prepared for send to fronted agenda.
 *
 * @param valueGenerator
 * @return
 */
private ValueGeneratorDto toDto(ValueGenerator<?> valueGenerator) {
    ValueGeneratorDto valueGeneratorDto = new ValueGeneratorDto();
    valueGeneratorDto.setId(valueGenerator.getId());
    valueGeneratorDto.setDescription(valueGenerator.getDescription());
    valueGeneratorDto.setModule(valueGenerator.getModule());
    valueGeneratorDto.setDtoType(valueGenerator.getDtoClass().getCanonicalName());
    valueGeneratorDto.setDisabled(valueGenerator.isDisabled());
    valueGeneratorDto.setName(valueGenerator.getName());
    valueGeneratorDto.setGeneratorType(AopProxyUtils.ultimateTargetClass(valueGenerator).getCanonicalName());
    valueGeneratorDto.setFormDefinition(valueGenerator.getFormDefinition());
    // 
    return valueGeneratorDto;
}
Also used : ValueGeneratorDto(eu.bcvsolutions.idm.core.api.dto.ValueGeneratorDto)

Example 32 with ValueGeneratorDto

use of eu.bcvsolutions.idm.core.api.dto.ValueGeneratorDto in project CzechIdMng by bcvsolutions.

the class IdentityUsernameGeneratorTest method generateWithChangePosition.

@Test
public void generateWithChangePosition() {
    String firstName = "firstName" + System.currentTimeMillis();
    String lastName = "lastName" + System.currentTimeMillis();
    ValueGeneratorDto generator = getGenerator();
    this.createGenerator(getDtoType(), getGeneratorType(), this.createConfiguration(generator.getFormDefinition(), ImmutableMap.of(IdentityUsernameGenerator.FIRST_NAME_FIRST, Boolean.FALSE.toString())), 1, null);
    IdmIdentityDto identityDto = new IdmIdentityDto();
    identityDto.setFirstName(firstName.toString());
    identityDto.setLastName(lastName.toString());
    IdmIdentityDto generatedDto = identityService.save(identityDto);
    assertEquals(identityDto.getLastName(), generatedDto.getLastName());
    assertEquals(identityDto.getFirstName(), generatedDto.getFirstName());
    assertNotNull(generatedDto.getUsername());
    assertEquals(lastName.toLowerCase() + firstName.toLowerCase(), generatedDto.getUsername());
}
Also used : ValueGeneratorDto(eu.bcvsolutions.idm.core.api.dto.ValueGeneratorDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Test(org.junit.Test) AbstractGeneratorTest(eu.bcvsolutions.idm.core.api.generator.AbstractGeneratorTest)

Example 33 with ValueGeneratorDto

use of eu.bcvsolutions.idm.core.api.dto.ValueGeneratorDto in project CzechIdMng by bcvsolutions.

the class IdentityUsernameGeneratorTest method generateShorterProperties.

@Test
public void generateShorterProperties() {
    String firstName = "firstName";
    String lastName = "lastName";
    String newFirstName = "first";
    String newLastName = "last";
    ValueGeneratorDto generator = getGenerator();
    this.createGenerator(getDtoType(), getGeneratorType(), this.createConfiguration(generator.getFormDefinition(), ImmutableMap.of(IdentityUsernameGenerator.FIRST_NAME_CHARACTERS_COUNT, "5", IdentityUsernameGenerator.LAST_NAME_CHARACTERS_COUNT, "4", IdentityUsernameGenerator.FIRST_NAME_FIRST, Boolean.TRUE.toString())), 1, null);
    IdmIdentityDto identityDto = new IdmIdentityDto();
    identityDto.setFirstName(firstName);
    identityDto.setLastName(lastName);
    IdmIdentityDto generatedDto = valueGeneratorManager.generate(identityDto);
    assertEquals(identityDto.getLastName(), generatedDto.getLastName());
    assertEquals(identityDto.getFirstName(), generatedDto.getFirstName());
    assertNotNull(generatedDto.getUsername());
    assertEquals(newFirstName + newLastName, generatedDto.getUsername());
}
Also used : ValueGeneratorDto(eu.bcvsolutions.idm.core.api.dto.ValueGeneratorDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Test(org.junit.Test) AbstractGeneratorTest(eu.bcvsolutions.idm.core.api.generator.AbstractGeneratorTest)

Example 34 with ValueGeneratorDto

use of eu.bcvsolutions.idm.core.api.dto.ValueGeneratorDto in project CzechIdMng by bcvsolutions.

the class IdentityUsernameGeneratorTest method generateMissingLastName.

@Test
public void generateMissingLastName() {
    String firstName = "firstName-" + System.currentTimeMillis();
    ValueGeneratorDto generator = getGenerator();
    this.createGenerator(getDtoType(), getGeneratorType(), this.createConfiguration(generator.getFormDefinition(), ImmutableMap.of(IdentityUsernameGenerator.FIRST_NAME_FIRST, Boolean.TRUE.toString())), 1, null);
    IdmIdentityDto identityDto = new IdmIdentityDto();
    identityDto.setFirstName(firstName);
    IdmIdentityDto generatedDto = valueGeneratorManager.generate(identityDto);
    assertEquals(identityDto.getLastName(), generatedDto.getLastName());
    assertEquals(identityDto.getUsername(), generatedDto.getUsername());
    assertEquals(identityDto.getFirstName(), generatedDto.getFirstName());
    assertNull(generatedDto.getUsername());
}
Also used : ValueGeneratorDto(eu.bcvsolutions.idm.core.api.dto.ValueGeneratorDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Test(org.junit.Test) AbstractGeneratorTest(eu.bcvsolutions.idm.core.api.generator.AbstractGeneratorTest)

Example 35 with ValueGeneratorDto

use of eu.bcvsolutions.idm.core.api.dto.ValueGeneratorDto in project CzechIdMng by bcvsolutions.

the class IdentityUsernameGeneratorTest method testWhiteSpacesWithCharacterSpace.

@Test
public void testWhiteSpacesWithCharacterSpace() {
    String firstName = "  first Nam   e";
    String lastName = "last Na me ";
    ValueGeneratorDto generator = getGenerator();
    this.createGenerator(getDtoType(), getGeneratorType(), this.createConfiguration(generator.getFormDefinition(), ImmutableMap.of(IdentityUsernameGenerator.REPLACE_WHITE_SPACES_CHARACTER, " ", IdentityUsernameGenerator.FIRST_NAME_FIRST, Boolean.TRUE.toString())), 1, null);
    IdmIdentityDto identityDto = new IdmIdentityDto();
    identityDto.setFirstName(firstName.toString());
    identityDto.setLastName(lastName.toString());
    IdmIdentityDto generatedDto = identityService.save(identityDto);
    assertEquals(identityDto.getLastName(), generatedDto.getLastName());
    assertEquals(identityDto.getFirstName(), generatedDto.getFirstName());
    assertNotNull(generatedDto.getUsername());
    assertEquals(firstName.toLowerCase() + lastName.toLowerCase(), generatedDto.getUsername());
}
Also used : ValueGeneratorDto(eu.bcvsolutions.idm.core.api.dto.ValueGeneratorDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Test(org.junit.Test) AbstractGeneratorTest(eu.bcvsolutions.idm.core.api.generator.AbstractGeneratorTest)

Aggregations

ValueGeneratorDto (eu.bcvsolutions.idm.core.api.dto.ValueGeneratorDto)59 AbstractGeneratorTest (eu.bcvsolutions.idm.core.api.generator.AbstractGeneratorTest)56 Test (org.junit.Test)56 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)54 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)9 AbstractDto (eu.bcvsolutions.idm.core.api.dto.AbstractDto)8 ImmutableMap (com.google.common.collect.ImmutableMap)7 IdmCacheManager (eu.bcvsolutions.idm.core.api.service.IdmCacheManager)7 IdmIdentityService (eu.bcvsolutions.idm.core.api.service.IdmIdentityService)7 PersistentType (eu.bcvsolutions.idm.core.eav.api.domain.PersistentType)7 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)7 IdmFormInstanceDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto)7 IdmFormValueDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto)7 FormService (eu.bcvsolutions.idm.core.eav.api.service.FormService)7 IdmFormAttributeService (eu.bcvsolutions.idm.core.eav.api.service.IdmFormAttributeService)7 IdmFormDefinitionService (eu.bcvsolutions.idm.core.eav.api.service.IdmFormDefinitionService)7 IdentityFormDefaultValueGenerator (eu.bcvsolutions.idm.core.generator.identity.IdentityFormDefaultValueGenerator)7 IdmIdentity (eu.bcvsolutions.idm.core.model.entity.IdmIdentity)7 ArrayList (java.util.ArrayList)7 List (java.util.List)7