Search in sources :

Example 56 with ValueGeneratorDto

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

the class IdentityEmailGeneratorIntegrationTest method testGreenLineWithIdentityService.

@Test
public void testGreenLineWithIdentityService() {
    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 = identityService.save(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 57 with ValueGeneratorDto

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

the class IdentityEmailGeneratorIntegrationTest method testOrder.

@Test
public void testOrder() {
    String emailSuffix = "ex.tld";
    String emailSuffix1 = "@test.tld";
    String emailSuffix2 = "bcvsolutions.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();
    // first
    this.createGenerator(getDtoType(), getGeneratorType(), this.createConfiguration(generator.getFormDefinition(), ImmutableMap.of(IdentityEmailGenerator.EMAIL_SUFFIX, emailSuffix, IdentityEmailGenerator.GENERATE_FROM_USERNAME, Boolean.TRUE.toString())), 10, null);
    // second
    this.createGenerator(getDtoType(), getGeneratorType(), this.createConfiguration(generator.getFormDefinition(), ImmutableMap.of(IdentityEmailGenerator.EMAIL_SUFFIX, emailSuffix1, IdentityEmailGenerator.GENERATE_FROM_USERNAME, Boolean.TRUE.toString())), 20, null);
    // the last - this generator will be generate email
    this.createGenerator(getDtoType(), getGeneratorType(), this.createConfiguration(generator.getFormDefinition(), ImmutableMap.of(IdentityEmailGenerator.EMAIL_SUFFIX, emailSuffix2, IdentityEmailGenerator.GENERATE_FROM_USERNAME, Boolean.TRUE.toString())), 30, null);
    IdmIdentityDto generatedDto = valueGeneratorManager.generate(identityDto);
    assertNotNull(generatedDto.getEmail());
    assertEquals(username + "@" + emailSuffix2, 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 58 with ValueGeneratorDto

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

the class IdentityEmailGeneratorIntegrationTest method testUniqueEmail.

@Test
public void testUniqueEmail() {
    String emailSuffix = "@example.tld";
    IdmIdentityDto identityDto = new IdmIdentityDto();
    identityDto.setFirstName("firstname");
    identityDto.setLastName("lastname");
    identityDto.setUsername(getHelper().createName());
    ValueGeneratorDto generator = getGenerator();
    this.createGenerator(getDtoType(), getGeneratorType(), this.createConfiguration(generator.getFormDefinition(), ImmutableMap.of(IdentityEmailGenerator.EMAIL_SUFFIX, emailSuffix, // ~ firstname and lastname
    IdentityEmailGenerator.GENERATE_FROM_USERNAME, // ~ firstname and lastname
    Boolean.FALSE.toString(), IdentityEmailGenerator.PROPERTY_UNIQUE_EMAIL, Boolean.TRUE.toString())), 1, null);
    IdmIdentityDto identityOne = identityService.save(identityDto);
    Assert.assertNotNull(identityOne.getEmail());
    Assert.assertEquals(identityDto.getLastName() + identityDto.getFirstName() + emailSuffix, identityOne.getEmail());
    // 
    identityDto.setUsername(getHelper().createName());
    IdmIdentityDto identityTwo = identityService.save(identityDto);
    Assert.assertNotNull(identityTwo.getEmail());
    Assert.assertEquals(identityDto.getLastName() + identityDto.getFirstName() + 1 + emailSuffix, identityTwo.getEmail());
    // 
    identityDto.setUsername(getHelper().createName());
    IdmIdentityDto identityThree = identityService.save(identityDto);
    Assert.assertNotNull(identityThree.getEmail());
    Assert.assertEquals(identityDto.getLastName() + identityDto.getFirstName() + 2 + emailSuffix, identityThree.getEmail());
    // 
    identityDto.setUsername(getHelper().createName());
    IdmIdentityDto identityFour = identityService.save(identityDto);
    Assert.assertNotNull(identityFour.getEmail());
    Assert.assertEquals(identityDto.getLastName() + identityDto.getFirstName() + 3 + emailSuffix, identityFour.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 59 with ValueGeneratorDto

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

the class IdentityEmailGeneratorIntegrationTest method testDisable.

@Test
public void testDisable() {
    String emailSuffix = "ex.tld";
    String emailSuffix1 = "@test.tld";
    String emailSuffix2 = "bcvsolutions.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();
    // first - this generator will be generate email
    this.createGenerator(getDtoType(), getGeneratorType(), this.createConfiguration(generator.getFormDefinition(), ImmutableMap.of(IdentityEmailGenerator.EMAIL_SUFFIX, emailSuffix, IdentityEmailGenerator.GENERATE_FROM_USERNAME, Boolean.TRUE.toString())), 10, null);
    // second
    IdmGenerateValueDto createGenerator = this.createGenerator(getDtoType(), getGeneratorType(), this.createConfiguration(generator.getFormDefinition(), ImmutableMap.of(IdentityEmailGenerator.EMAIL_SUFFIX, emailSuffix1, IdentityEmailGenerator.GENERATE_FROM_USERNAME, Boolean.TRUE.toString())), 20, null);
    createGenerator.setDisabled(true);
    this.generatedAttributeService.save(createGenerator);
    // the last
    createGenerator = this.createGenerator(getDtoType(), getGeneratorType(), this.createConfiguration(generator.getFormDefinition(), ImmutableMap.of(IdentityEmailGenerator.EMAIL_SUFFIX, emailSuffix2)), 30, null);
    createGenerator.setDisabled(true);
    this.generatedAttributeService.save(createGenerator);
    IdmIdentityDto generatedDto = valueGeneratorManager.generate(identityDto);
    assertNotNull(generatedDto.getEmail());
    assertEquals(username + "@" + emailSuffix, generatedDto.getEmail());
}
Also used : ValueGeneratorDto(eu.bcvsolutions.idm.core.api.dto.ValueGeneratorDto) IdmGenerateValueDto(eu.bcvsolutions.idm.core.api.dto.IdmGenerateValueDto) 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