Search in sources :

Example 26 with ValueGeneratorDto

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

the class ContractPositionNameGeneratorTest method testGreenLineWithSave.

@Test
public void testGreenLineWithSave() {
    IdmIdentityDto identityDto = getHelper().createIdentity();
    IdmIdentityContractDto contractDto = new IdmIdentityContractDto();
    contractDto.setIdentity(identityDto.getId());
    String prefix = "prefix" + System.currentTimeMillis();
    String suffix = "suffix" + System.currentTimeMillis();
    ValueGeneratorDto generator = getGenerator();
    this.createGenerator(getDtoType(), getGeneratorType(), this.createConfiguration(generator.getFormDefinition(), ImmutableMap.of(ContractPositionNameGenerator.POSITION_NAME_PREFIX, prefix, ContractPositionNameGenerator.POSITION_NAME_SUFFIX, suffix)), 1, null);
    IdmIdentityContractDto generated = identityContractService.save(contractDto);
    assertNotNull(generated);
    assertEquals(prefix + identityDto.getUsername() + suffix, generated.getPosition());
}
Also used : ValueGeneratorDto(eu.bcvsolutions.idm.core.api.dto.ValueGeneratorDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Test(org.junit.Test) AbstractGeneratorTest(eu.bcvsolutions.idm.core.api.generator.AbstractGeneratorTest)

Example 27 with ValueGeneratorDto

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

the class ContractPositionNameGeneratorTest method testWithoutSuffix.

@Test
public void testWithoutSuffix() {
    IdmIdentityDto identityDto = getHelper().createIdentity();
    IdmIdentityContractDto contractDto = new IdmIdentityContractDto();
    contractDto.setIdentity(identityDto.getId());
    String prefix = "prefix" + System.currentTimeMillis();
    ValueGeneratorDto generator = getGenerator();
    this.createGenerator(getDtoType(), getGeneratorType(), this.createConfiguration(generator.getFormDefinition(), ImmutableMap.of(ContractPositionNameGenerator.POSITION_NAME_PREFIX, prefix)), 1, null);
    IdmIdentityContractDto generated = valueGeneratorManager.generate(contractDto);
    assertNotNull(generated);
    assertEquals(prefix + identityDto.getUsername(), generated.getPosition());
}
Also used : ValueGeneratorDto(eu.bcvsolutions.idm.core.api.dto.ValueGeneratorDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Test(org.junit.Test) AbstractGeneratorTest(eu.bcvsolutions.idm.core.api.generator.AbstractGeneratorTest)

Example 28 with ValueGeneratorDto

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

the class ContractPositionNameGeneratorTest method testWithoutPrefixAndSuffix.

@Test
public void testWithoutPrefixAndSuffix() {
    IdmIdentityDto identityDto = getHelper().createIdentity();
    IdmIdentityContractDto contractDto = new IdmIdentityContractDto();
    contractDto.setIdentity(identityDto.getId());
    ValueGeneratorDto generator = getGenerator();
    this.createGenerator(getDtoType(), getGeneratorType(), this.createConfiguration(generator.getFormDefinition(), null), 1, null);
    IdmIdentityContractDto generated = valueGeneratorManager.generate(contractDto);
    assertNotNull(generated);
    assertEquals(identityDto.getUsername(), generated.getPosition());
}
Also used : ValueGeneratorDto(eu.bcvsolutions.idm.core.api.dto.ValueGeneratorDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Test(org.junit.Test) AbstractGeneratorTest(eu.bcvsolutions.idm.core.api.generator.AbstractGeneratorTest)

Example 29 with ValueGeneratorDto

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

the class ContractPositionNameGeneratorTest method testGreenLine.

@Test
public void testGreenLine() {
    IdmIdentityDto identityDto = getHelper().createIdentity();
    IdmIdentityContractDto contractDto = new IdmIdentityContractDto();
    contractDto.setIdentity(identityDto.getId());
    String prefix = "prefix" + System.currentTimeMillis();
    String suffix = "suffix" + System.currentTimeMillis();
    ValueGeneratorDto generator = getGenerator();
    this.createGenerator(getDtoType(), getGeneratorType(), this.createConfiguration(generator.getFormDefinition(), ImmutableMap.of(ContractPositionNameGenerator.POSITION_NAME_PREFIX, prefix, ContractPositionNameGenerator.POSITION_NAME_SUFFIX, suffix)), 1, null);
    IdmIdentityContractDto generated = valueGeneratorManager.generate(contractDto);
    assertNotNull(generated);
    assertEquals(prefix + identityDto.getUsername() + suffix, generated.getPosition());
}
Also used : ValueGeneratorDto(eu.bcvsolutions.idm.core.api.dto.ValueGeneratorDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Test(org.junit.Test) AbstractGeneratorTest(eu.bcvsolutions.idm.core.api.generator.AbstractGeneratorTest)

Example 30 with ValueGeneratorDto

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

the class DefaultValueGeneratorManagerTest method testGeneratorTypesForIdentity.

@Test
public void testGeneratorTypesForIdentity() {
    List<ValueGeneratorDto> generators = valueGeneratorManager.getAvailableGenerators(IdmIdentityDto.class);
    for (ValueGeneratorDto generator : generators) {
        try {
            Class.forName(generator.getDtoType());
            Class.forName(generator.getGeneratorType());
            assertEquals(IdmIdentityDto.class.getCanonicalName(), generator.getDtoType());
        } catch (ClassNotFoundException e) {
            fail(e.getMessage());
        }
    }
}
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