Search in sources :

Example 11 with ValueGeneratorDto

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

the class IdentityEmailGeneratorIntegrationTest method testGreenLineWithoutAt.

@Test
public void testGreenLineWithoutAt() {
    String emailSuffix = "example.tld";
    String username = this.getHelper().createName();
    IdmIdentityDto identityDto = new IdmIdentityDto();
    identityDto.setFirstName(this.getHelper().createName());
    identityDto.setLastName(this.getHelper().createName());
    identityDto.setUsername(username);
    ValueGeneratorDto generator = getGenerator();
    this.createGenerator(getDtoType(), getGeneratorType(), this.createConfiguration(generator.getFormDefinition(), ImmutableMap.of(IdentityEmailGenerator.EMAIL_SUFFIX, emailSuffix, IdentityEmailGenerator.GENERATE_FROM_USERNAME, Boolean.TRUE.toString())), 1, null);
    IdmIdentityDto generatedDto = valueGeneratorManager.generate(identityDto);
    assertNotNull(generatedDto.getEmail());
    assertEquals(username + "@" + emailSuffix, generatedDto.getEmail());
}
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 12 with ValueGeneratorDto

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

the class IdentityScriptValueGeneratorTest method testMissingScript.

@Test(expected = ResultCodeException.class)
public void testMissingScript() {
    String username = this.getHelper().createName();
    IdmIdentityDto identityDto = new IdmIdentityDto();
    identityDto.setFirstName(this.getHelper().createName());
    identityDto.setLastName(this.getHelper().createName());
    identityDto.setUsername(username);
    ValueGeneratorDto generator = getGenerator();
    this.createGenerator(getDtoType(), getGeneratorType(), this.createConfiguration(generator.getFormDefinition(), ImmutableMap.of(IdentityScriptValueGenerator.SCRIPT_CODE, this.getHelper().createName())), 1, null);
    identityService.save(identityDto);
}
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 13 with ValueGeneratorDto

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

the class IdentityScriptValueGeneratorTest method testScriptReturnNull.

@Test(expected = ResultCodeException.class)
public void testScriptReturnNull() {
    IdmScriptDto script = createScript("");
    script.setScript("return null;");
    scriptService.save(script);
    String username = this.getHelper().createName();
    IdmIdentityDto identityDto = new IdmIdentityDto();
    identityDto.setFirstName(this.getHelper().createName());
    identityDto.setLastName(this.getHelper().createName());
    identityDto.setUsername(username);
    ValueGeneratorDto generator = getGenerator();
    this.createGenerator(getDtoType(), getGeneratorType(), this.createConfiguration(generator.getFormDefinition(), ImmutableMap.of(IdentityScriptValueGenerator.SCRIPT_CODE, script.getCode())), 1, null);
    identityService.save(identityDto);
}
Also used : ValueGeneratorDto(eu.bcvsolutions.idm.core.api.dto.ValueGeneratorDto) IdmScriptDto(eu.bcvsolutions.idm.core.api.dto.IdmScriptDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Test(org.junit.Test) AbstractGeneratorTest(eu.bcvsolutions.idm.core.api.generator.AbstractGeneratorTest)

Example 14 with ValueGeneratorDto

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

the class IdentityUsernameGeneratorTest method generateWithNoRegenerate.

@Test
public void generateWithNoRegenerate() {
    String firstName = "firstName" + System.currentTimeMillis();
    String lastName = "lastName" + System.currentTimeMillis();
    String username = "username---" + System.currentTimeMillis();
    ValueGeneratorDto generator = getGenerator();
    this.createGenerator(getDtoType(), getGeneratorType(), this.createConfiguration(generator.getFormDefinition(), ImmutableMap.of(IdentityUsernameGenerator.FIRST_NAME_CHARACTERS_COUNT, "1", IdentityUsernameGenerator.LAST_NAME_CHARACTERS_COUNT, "1", IdentityUsernameGenerator.CONNECTING_CHARACTER, "--", IdentityUsernameGenerator.FIRST_NAME_FIRST, Boolean.TRUE.toString())), 1, Boolean.FALSE);
    IdmIdentityDto identityDto = new IdmIdentityDto();
    identityDto.setFirstName(firstName.toString());
    identityDto.setLastName(lastName.toString());
    identityDto.setUsername(username);
    IdmIdentityDto generatedDto = identityService.save(identityDto);
    assertEquals(identityDto.getLastName(), generatedDto.getLastName());
    assertEquals(identityDto.getFirstName(), generatedDto.getFirstName());
    assertNotNull(generatedDto.getUsername());
    assertEquals(username, 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 15 with ValueGeneratorDto

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

the class IdentityUsernameGeneratorTest method generateMoreThan255.

@Test
public void generateMoreThan255() {
    StringBuilder firstName = new StringBuilder();
    for (int index = 0; index < 130; index++) {
        firstName.append("F");
    }
    StringBuilder lastName = new StringBuilder();
    for (int index = 0; index < 130; index++) {
        lastName.append("L");
    }
    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.toString());
    identityDto.setLastName(lastName.toString());
    IdmIdentityDto generatedDto = valueGeneratorManager.generate(identityDto);
    assertEquals(identityDto.getLastName(), generatedDto.getLastName());
    assertEquals(identityDto.getFirstName(), generatedDto.getFirstName());
    assertNotNull(generatedDto.getUsername());
    assertEquals(255, generatedDto.getUsername().length());
}
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