Search in sources :

Example 16 with ValueGeneratorDto

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

the class IdentityFormDefaultValueGeneratorTest method testNoDefaultValues.

@Test
public void testNoDefaultValues() {
    // prepare identity
    IdmIdentityDto identity = new IdmIdentityDto();
    identity.setUsername(getHelper().createName());
    // prepare new form definition
    UUID formDefinitionId = createFormDefinition().getId();
    // prepare form attribute 1
    String attrCode1 = getHelper().createName();
    IdmFormAttributeDto att1 = createAttribute(attrCode1, null, PersistentType.UUID, formDefinitionId);
    // prepare form attribute 2
    String attrCode2 = getHelper().createName();
    IdmFormAttributeDto att2 = createAttribute(attrCode2, null, PersistentType.INT, formDefinitionId);
    // check eav before
    List<IdmFormInstanceDto> eavs = identity.getEavs();
    assertTrue(eavs.isEmpty());
    // create generator
    ValueGeneratorDto generator = getGenerator();
    this.createGenerator(getDtoType(), getGeneratorType(), this.createConfiguration(generator.getFormDefinition(), null), 1, null);
    IdmFormInstanceDto formInstance = new IdmFormInstanceDto();
    IdmFormDefinitionDto formDefinition = formDefinitionService.get(formDefinitionId);
    formInstance.setFormDefinition(formDefinition);
    // create identity with given one EAV
    String givenNewValue = UUID.randomUUID().toString();
    List<IdmFormValueDto> givenValues = new ArrayList<>();
    IdmFormValueDto givenValue = new IdmFormValueDto(att1);
    givenValue.setValue(givenNewValue);
    givenValues.add(givenValue);
    formInstance.setValues(givenValues);
    eavs.add(formInstance);
    identity.setEavs(eavs);
    // generate and check values after
    identity = identityService.save(identity);
    eavs = identity.getEavs();
    assertFalse(eavs.isEmpty());
    // get newly generated eav only for given form definition
    IdmFormInstanceDto generatedEav = eavs.stream().filter(eav -> eav.getFormDefinition().getCode().equals(formDefinition.getCode())).findFirst().orElse(null);
    assertNotNull(generatedEav);
    // check values
    List<IdmFormValueDto> values = generatedEav.getValues().stream().filter(val -> val.getFormAttribute().equals(att1.getId())).collect(Collectors.toList());
    assertEquals(1, values.size());
    IdmFormValueDto value = values.get(0);
    // we check manually given
    assertEquals(givenNewValue, value.getValue().toString());
    // for second value doesn't exist default value
    values = generatedEav.getValues().stream().filter(val -> val.getFormAttribute().equals(att2.getId())).collect(Collectors.toList());
    assertEquals(0, values.size());
}
Also used : IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) ArrayList(java.util.ArrayList) PersistentType(eu.bcvsolutions.idm.core.eav.api.domain.PersistentType) AbstractDto(eu.bcvsolutions.idm.core.api.dto.AbstractDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) After(org.junit.After) IdmFormAttributeService(eu.bcvsolutions.idm.core.eav.api.service.IdmFormAttributeService) IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) ImmutableMap(com.google.common.collect.ImmutableMap) Assert.assertNotNull(org.junit.Assert.assertNotNull) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmCacheManager(eu.bcvsolutions.idm.core.api.service.IdmCacheManager) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) List(java.util.List) IdmFormDefinitionService(eu.bcvsolutions.idm.core.eav.api.service.IdmFormDefinitionService) Assert.assertFalse(org.junit.Assert.assertFalse) IdentityFormDefaultValueGenerator(eu.bcvsolutions.idm.core.generator.identity.IdentityFormDefaultValueGenerator) AbstractGeneratorTest(eu.bcvsolutions.idm.core.api.generator.AbstractGeneratorTest) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) Assert.assertEquals(org.junit.Assert.assertEquals) ValueGeneratorDto(eu.bcvsolutions.idm.core.api.dto.ValueGeneratorDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) ValueGeneratorDto(eu.bcvsolutions.idm.core.api.dto.ValueGeneratorDto) ArrayList(java.util.ArrayList) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) UUID(java.util.UUID) Test(org.junit.Test) AbstractGeneratorTest(eu.bcvsolutions.idm.core.api.generator.AbstractGeneratorTest)

Example 17 with ValueGeneratorDto

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

the class IdentityFormDefaultValueGeneratorTest method testMoreDefinition.

@Test
public void testMoreDefinition() {
    // prepare identity
    IdmIdentityDto identity = new IdmIdentityDto();
    identity.setUsername(getHelper().createName());
    // prepare new form definition
    IdmFormDefinitionDto formDefinition = createFormDefinition("defOne");
    IdmFormDefinitionDto formDefinition2 = createFormDefinition("defTwo");
    // prepare form attribute 1 for first definition
    String attrCode1 = "defOneAttOne";
    String attrDefaultValue1 = UUID.randomUUID().toString();
    IdmFormAttributeDto att1 = createAttribute(attrCode1, attrDefaultValue1, PersistentType.UUID, formDefinition.getId());
    // prepare form attribute 2 for first definition
    String attrCode2 = "defOneAttTwo";
    String attrDefaultValue2 = "100";
    IdmFormAttributeDto att2 = createAttribute(attrCode2, attrDefaultValue2, PersistentType.INT, formDefinition.getId());
    // prepare form attribute 1 for second definition
    String attrCode3 = "defTwoAttThree";
    String attrDefaultValue3 = UUID.randomUUID().toString();
    IdmFormAttributeDto att3 = createAttribute(attrCode3, attrDefaultValue3, PersistentType.SHORTTEXT, formDefinition2.getId());
    // prepare form attribute 2 for second definition
    String attrCode4 = "defTwoAttFour";
    String attrDefaultValue4 = getHelper().createName() + getHelper().createName() + getHelper().createName();
    IdmFormAttributeDto att4 = createAttribute(attrCode4, attrDefaultValue4, PersistentType.TEXT, formDefinition2.getId());
    // check eav before
    List<IdmFormInstanceDto> eavs = identity.getEavs();
    assertTrue(eavs.isEmpty());
    // create generator
    ValueGeneratorDto generator = getGenerator();
    this.createGenerator(getDtoType(), getGeneratorType(), this.createConfiguration(generator.getFormDefinition(), null), 1, Boolean.TRUE);
    IdmFormInstanceDto formInstance = new IdmFormInstanceDto();
    formInstance.setFormDefinition(formDefinition);
    // create identity with given one EAV
    String givenNewValue = UUID.randomUUID().toString();
    List<IdmFormValueDto> givenValues = new ArrayList<>();
    IdmFormValueDto givenValue = new IdmFormValueDto(att1);
    givenValue.setValue(givenNewValue);
    givenValues.add(givenValue);
    formInstance.setValues(givenValues);
    eavs.add(formInstance);
    // create second value from second form definition
    IdmFormInstanceDto formInstance2 = new IdmFormInstanceDto();
    formInstance2.setFormDefinition(formDefinition2);
    // create identity with given one EAV
    String givenNewValue2 = String.valueOf(System.currentTimeMillis());
    List<IdmFormValueDto> givenValues2 = new ArrayList<>();
    IdmFormValueDto givenValue2 = new IdmFormValueDto(att4);
    givenValue2.setValue(givenNewValue2);
    givenValues2.add(givenValue2);
    formInstance2.setValues(givenValues2);
    eavs.add(formInstance2);
    identity.setEavs(eavs);
    // generate and check values after
    identity = valueGeneratorManager.generate(identity);
    eavs = identity.getEavs();
    assertFalse(eavs.isEmpty());
    // get newly generated eav only for given form definition
    IdmFormInstanceDto generatedEav = eavs.stream().filter(eav -> eav.getFormDefinition().getCode().equals(formDefinition.getCode())).findFirst().orElse(null);
    assertNotNull(generatedEav);
    // check values
    List<IdmFormValueDto> values = generatedEav.getValues().stream().filter(val -> val.getFormAttribute().equals(att1.getId())).collect(Collectors.toList());
    assertEquals(1, values.size());
    @SuppressWarnings("unused") IdmFormValueDto value = values.get(0);
    // ///////////////////////////////////assertEquals(givenNewValue, value.getValue().toString());
    values = generatedEav.getValues().stream().filter(val -> val.getFormAttribute().equals(att2.getId())).collect(Collectors.toList());
    assertEquals(1, values.size());
    value = values.get(0);
    // assertEquals(attrDefaultValue2, value.getValue().toString());
    // check second form
    generatedEav = eavs.stream().filter(eav -> eav.getFormDefinition().getCode().equals(formDefinition2.getCode())).findFirst().orElse(null);
    assertNotNull(generatedEav);
    // check values
    values = generatedEav.getValues().stream().filter(val -> val.getFormAttribute().equals(att3.getId())).collect(Collectors.toList());
    assertEquals(1, values.size());
    value = values.get(0);
    // assertEquals(attrDefaultValue3, value.getValue().toString());
    values = generatedEav.getValues().stream().filter(val -> val.getFormAttribute().equals(att4.getId())).collect(Collectors.toList());
    assertEquals(1, values.size());
    value = values.get(0);
// assertEquals(givenNewValue2, value.getValue().toString());
}
Also used : IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) ArrayList(java.util.ArrayList) PersistentType(eu.bcvsolutions.idm.core.eav.api.domain.PersistentType) AbstractDto(eu.bcvsolutions.idm.core.api.dto.AbstractDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) After(org.junit.After) IdmFormAttributeService(eu.bcvsolutions.idm.core.eav.api.service.IdmFormAttributeService) IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) ImmutableMap(com.google.common.collect.ImmutableMap) Assert.assertNotNull(org.junit.Assert.assertNotNull) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmCacheManager(eu.bcvsolutions.idm.core.api.service.IdmCacheManager) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) List(java.util.List) IdmFormDefinitionService(eu.bcvsolutions.idm.core.eav.api.service.IdmFormDefinitionService) Assert.assertFalse(org.junit.Assert.assertFalse) IdentityFormDefaultValueGenerator(eu.bcvsolutions.idm.core.generator.identity.IdentityFormDefaultValueGenerator) AbstractGeneratorTest(eu.bcvsolutions.idm.core.api.generator.AbstractGeneratorTest) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) Assert.assertEquals(org.junit.Assert.assertEquals) ValueGeneratorDto(eu.bcvsolutions.idm.core.api.dto.ValueGeneratorDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) ValueGeneratorDto(eu.bcvsolutions.idm.core.api.dto.ValueGeneratorDto) ArrayList(java.util.ArrayList) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Test(org.junit.Test) AbstractGeneratorTest(eu.bcvsolutions.idm.core.api.generator.AbstractGeneratorTest)

Example 18 with ValueGeneratorDto

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

the class IdentityFormDefaultValueGeneratorTest method testGreenLineWithSave.

@Test
public void testGreenLineWithSave() {
    // prepare identity
    IdmIdentityDto identity = new IdmIdentityDto();
    identity.setUsername(getHelper().createName());
    // prepare new form definition
    IdmFormDefinitionDto formDefinition = createFormDefinition();
    // prepare form attribute 1
    String attrCode1 = getHelper().createName();
    String attrDefaultValue1 = "true";
    IdmFormAttributeDto att1 = createAttribute(attrCode1, attrDefaultValue1, PersistentType.BOOLEAN, formDefinition.getId());
    // prepare form attribute 2
    String attrCode2 = getHelper().createName();
    String attrDefaultValue2 = "A";
    IdmFormAttributeDto att2 = createAttribute(attrCode2, attrDefaultValue2, PersistentType.CHAR, formDefinition.getId());
    // check eav before
    List<IdmFormInstanceDto> eavs = identity.getEavs();
    assertTrue(eavs.isEmpty());
    // create generator
    ValueGeneratorDto generator = getGenerator();
    this.createGenerator(getDtoType(), getGeneratorType(), this.createConfiguration(generator.getFormDefinition(), null), 1, null);
    // generate and check values after
    identity = identityService.save(identity);
    eavs = identity.getEavs();
    assertFalse(eavs.isEmpty());
    // get newly generated eav only for given form definition
    IdmFormInstanceDto generatedEav = eavs.stream().filter(eav -> eav.getFormDefinition().getCode().equals(formDefinition.getCode())).findFirst().orElse(null);
    assertNotNull(generatedEav);
    // check values
    List<IdmFormValueDto> values = generatedEav.getValues().stream().filter(val -> val.getFormAttribute().equals(att1.getId())).collect(Collectors.toList());
    assertEquals(1, values.size());
    IdmFormValueDto value = values.get(0);
    assertEquals(attrDefaultValue1, value.getValue().toString());
    values = generatedEav.getValues().stream().filter(val -> val.getFormAttribute().equals(att2.getId())).collect(Collectors.toList());
    assertEquals(1, values.size());
    value = values.get(0);
    assertEquals(attrDefaultValue2, value.getValue().toString());
}
Also used : IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) ArrayList(java.util.ArrayList) PersistentType(eu.bcvsolutions.idm.core.eav.api.domain.PersistentType) AbstractDto(eu.bcvsolutions.idm.core.api.dto.AbstractDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) After(org.junit.After) IdmFormAttributeService(eu.bcvsolutions.idm.core.eav.api.service.IdmFormAttributeService) IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) ImmutableMap(com.google.common.collect.ImmutableMap) Assert.assertNotNull(org.junit.Assert.assertNotNull) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmCacheManager(eu.bcvsolutions.idm.core.api.service.IdmCacheManager) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) List(java.util.List) IdmFormDefinitionService(eu.bcvsolutions.idm.core.eav.api.service.IdmFormDefinitionService) Assert.assertFalse(org.junit.Assert.assertFalse) IdentityFormDefaultValueGenerator(eu.bcvsolutions.idm.core.generator.identity.IdentityFormDefaultValueGenerator) AbstractGeneratorTest(eu.bcvsolutions.idm.core.api.generator.AbstractGeneratorTest) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) Assert.assertEquals(org.junit.Assert.assertEquals) ValueGeneratorDto(eu.bcvsolutions.idm.core.api.dto.ValueGeneratorDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) ValueGeneratorDto(eu.bcvsolutions.idm.core.api.dto.ValueGeneratorDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Test(org.junit.Test) AbstractGeneratorTest(eu.bcvsolutions.idm.core.api.generator.AbstractGeneratorTest)

Example 19 with ValueGeneratorDto

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

the class IdentityFormDefaultValueGeneratorTest method testRegenerateOff.

@Test
public void testRegenerateOff() {
    // prepare identity
    IdmIdentityDto identity = new IdmIdentityDto();
    identity.setUsername(getHelper().createName());
    // prepare new form definition
    UUID formDefinitionId = createFormDefinition().getId();
    // prepare form attribute 1
    String attrCode1 = getHelper().createName();
    String attrDefaultValue1 = "true";
    IdmFormAttributeDto att1 = createAttribute(attrCode1, attrDefaultValue1, PersistentType.BOOLEAN, formDefinitionId);
    // prepare form attribute 2
    String attrCode2 = getHelper().createName();
    String attrDefaultValue2 = "A";
    IdmFormAttributeDto att2 = createAttribute(attrCode2, attrDefaultValue2, PersistentType.CHAR, formDefinitionId);
    // check eav before
    List<IdmFormInstanceDto> eavs = identity.getEavs();
    assertTrue(eavs.isEmpty());
    // create generator
    ValueGeneratorDto generator = getGenerator();
    this.createGenerator(getDtoType(), getGeneratorType(), this.createConfiguration(generator.getFormDefinition(), null), 1, Boolean.FALSE);
    IdmFormDefinitionDto formDefinition = formDefinitionService.get(formDefinitionId);
    IdmFormInstanceDto formInstance = new IdmFormInstanceDto();
    formInstance.setFormDefinition(formDefinition);
    // create identity with given one EAV
    String givenNewValue = "false";
    List<IdmFormValueDto> givenValues = new ArrayList<>();
    IdmFormValueDto givenValue = new IdmFormValueDto(att1);
    givenValue.setValue(givenNewValue);
    givenValues.add(givenValue);
    formInstance.setValues(givenValues);
    eavs.add(formInstance);
    identity.setEavs(eavs);
    // generate and check values after
    identity = identityService.save(identity);
    eavs = identity.getEavs();
    assertFalse(eavs.isEmpty());
    // get newly generated eav only for given form definition
    IdmFormInstanceDto generatedEav = eavs.stream().filter(eav -> eav.getFormDefinition().getCode().equals(formDefinition.getCode())).findFirst().orElse(null);
    assertNotNull(generatedEav);
    // check values
    List<IdmFormValueDto> values = generatedEav.getValues().stream().filter(val -> val.getFormAttribute().equals(att1.getId())).collect(Collectors.toList());
    assertEquals(1, values.size());
    IdmFormValueDto value = values.get(0);
    // we check manualy given
    assertEquals(givenNewValue, value.getValue().toString());
    values = generatedEav.getValues().stream().filter(val -> val.getFormAttribute().equals(att2.getId())).collect(Collectors.toList());
    assertEquals(1, values.size());
    value = values.get(0);
    assertEquals(attrDefaultValue2, value.getValue().toString());
}
Also used : IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) ArrayList(java.util.ArrayList) PersistentType(eu.bcvsolutions.idm.core.eav.api.domain.PersistentType) AbstractDto(eu.bcvsolutions.idm.core.api.dto.AbstractDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) After(org.junit.After) IdmFormAttributeService(eu.bcvsolutions.idm.core.eav.api.service.IdmFormAttributeService) IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) ImmutableMap(com.google.common.collect.ImmutableMap) Assert.assertNotNull(org.junit.Assert.assertNotNull) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmCacheManager(eu.bcvsolutions.idm.core.api.service.IdmCacheManager) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) List(java.util.List) IdmFormDefinitionService(eu.bcvsolutions.idm.core.eav.api.service.IdmFormDefinitionService) Assert.assertFalse(org.junit.Assert.assertFalse) IdentityFormDefaultValueGenerator(eu.bcvsolutions.idm.core.generator.identity.IdentityFormDefaultValueGenerator) AbstractGeneratorTest(eu.bcvsolutions.idm.core.api.generator.AbstractGeneratorTest) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) Assert.assertEquals(org.junit.Assert.assertEquals) ValueGeneratorDto(eu.bcvsolutions.idm.core.api.dto.ValueGeneratorDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) ValueGeneratorDto(eu.bcvsolutions.idm.core.api.dto.ValueGeneratorDto) ArrayList(java.util.ArrayList) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) UUID(java.util.UUID) Test(org.junit.Test) AbstractGeneratorTest(eu.bcvsolutions.idm.core.api.generator.AbstractGeneratorTest)

Example 20 with ValueGeneratorDto

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

the class IdentityUsernameGeneratorTest method testWhiteSpacesNoCharacter.

@Test
public void testWhiteSpacesNoCharacter() {
    String firstName = "  first Nam   e";
    String lastName = "last Na me ";
    ValueGeneratorDto generator = getGenerator();
    this.createGenerator(getDtoType(), getGeneratorType(), this.createConfiguration(generator.getFormDefinition(), ImmutableMap.of(IdentityUsernameGenerator.FIRST_NAME_FIRST, Boolean.FALSE.toString())), 1, null);
    IdmIdentityDto identityDto = new IdmIdentityDto();
    identityDto.setFirstName(firstName.toString());
    identityDto.setLastName(lastName.toString());
    IdmIdentityDto generatedDto = identityService.save(identityDto);
    assertEquals(identityDto.getLastName(), generatedDto.getLastName());
    assertEquals(identityDto.getFirstName(), generatedDto.getFirstName());
    assertNotNull(generatedDto.getUsername());
    assertEquals(StringUtils.trimAllWhitespace(lastName).toLowerCase() + StringUtils.trimAllWhitespace(firstName).toLowerCase(), 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)

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