Search in sources :

Example 1 with ValueGeneratorDto

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

the class DefaultValueGeneratorManagerTest method testCreateGenerator.

@Test
public void testCreateGenerator() {
    Set<Class<? extends AbstractDto>> supportedTypes = valueGeneratorManager.getSupportedTypes();
    // 
    supportedTypes.forEach(supportedType -> {
        List<ValueGeneratorDto> availableGenerators = valueGeneratorManager.getAvailableGenerators(supportedType);
        availableGenerators.forEach(generator -> {
            IdmFormDefinitionDto formDefinition = generator.getFormDefinition();
            // 
            createGenerator(supportedType, generator.getGeneratorType(), createConfiguration(formDefinition, ImmutableMap.of()), null, null);
        });
    });
}
Also used : ValueGeneratorDto(eu.bcvsolutions.idm.core.api.dto.ValueGeneratorDto) AbstractDto(eu.bcvsolutions.idm.core.api.dto.AbstractDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) Test(org.junit.Test) AbstractGeneratorTest(eu.bcvsolutions.idm.core.api.generator.AbstractGeneratorTest)

Example 2 with ValueGeneratorDto

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

the class DefaultValueGeneratorManagerTest method testGeneratorTypes.

@Test
public void testGeneratorTypes() {
    List<ValueGeneratorDto> generators = valueGeneratorManager.getAvailableGenerators(null);
    for (ValueGeneratorDto generator : generators) {
        try {
            Class.forName(generator.getDtoType());
            Class.forName(generator.getGeneratorType());
        } catch (ClassNotFoundException e) {
            fail(e.getMessage());
        }
    }
}
Also used : ValueGeneratorDto(eu.bcvsolutions.idm.core.api.dto.ValueGeneratorDto) Test(org.junit.Test) AbstractGeneratorTest(eu.bcvsolutions.idm.core.api.generator.AbstractGeneratorTest)

Example 3 with ValueGeneratorDto

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

the class ContractPositionNameGeneratorTest method testRegenerateOff.

@Test
public void testRegenerateOff() {
    IdmIdentityDto identityDto = getHelper().createIdentity();
    IdmIdentityContractDto contractDto = new IdmIdentityContractDto();
    contractDto.setIdentity(identityDto.getId());
    String positionName = "positionName" + System.currentTimeMillis();
    String prefix = "prefix" + System.currentTimeMillis();
    String suffix = "suffix" + System.currentTimeMillis();
    contractDto.setPosition(positionName);
    ValueGeneratorDto generator = getGenerator();
    this.createGenerator(getDtoType(), getGeneratorType(), this.createConfiguration(generator.getFormDefinition(), ImmutableMap.of(ContractPositionNameGenerator.POSITION_NAME_PREFIX, prefix, ContractPositionNameGenerator.POSITION_NAME_SUFFIX, suffix)), 1, Boolean.FALSE);
    IdmIdentityContractDto generated = valueGeneratorManager.generate(contractDto);
    assertNotNull(generated);
    assertEquals(positionName, 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 4 with ValueGeneratorDto

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

the class ContractPositionNameGeneratorTest method testWithoutPrefix.

@Test
public void testWithoutPrefix() {
    IdmIdentityDto identityDto = getHelper().createIdentity();
    IdmIdentityContractDto contractDto = new IdmIdentityContractDto();
    contractDto.setIdentity(identityDto.getId());
    String suffix = "suffix" + System.currentTimeMillis();
    ValueGeneratorDto generator = getGenerator();
    this.createGenerator(getDtoType(), getGeneratorType(), this.createConfiguration(generator.getFormDefinition(), ImmutableMap.of(ContractPositionNameGenerator.POSITION_NAME_SUFFIX, suffix)), 1, null);
    IdmIdentityContractDto generated = valueGeneratorManager.generate(contractDto);
    assertNotNull(generated);
    assertEquals(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 5 with ValueGeneratorDto

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

the class AbstractGeneratorTest method getGenerator.

/**
 * Get generator for curent implementation given from method entity type and generator type
 *
 * @return
 */
protected ValueGeneratorDto getGenerator() {
    ValueGeneratorDto generator = this.getGenerator(getDtoType(), getGeneratorType());
    assertNotNull(generator);
    return generator;
}
Also used : ValueGeneratorDto(eu.bcvsolutions.idm.core.api.dto.ValueGeneratorDto)

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