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());
}
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);
}
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);
}
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());
}
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());
}
Aggregations