test_class.declarator: formDefinitionService
test_class.modifier: @Autowired
  	private
test_class.original_string: @Autowired
  	private IdmFormDefinitionService formDefinitionService;
test_class.type: IdmFormDefinitionService
test_class.var_name: formDefinitionService
test_class.declarator: formAttributeService
test_class.modifier: @Autowired
  	private
test_class.original_string: @Autowired
  	private IdmFormAttributeService formAttributeService;
test_class.type: IdmFormAttributeService
test_class.var_name: formAttributeService
test_class.declarator: roleService
test_class.modifier: @Autowired
  	private
test_class.original_string: @Autowired
  	private IdmRoleService roleService;
test_class.type: IdmRoleService
test_class.var_name: roleService
test_class.declarator: generateValueService
test_class.modifier: @Autowired
  	private
test_class.original_string: @Autowired
  	private IdmGenerateValueService generateValueService;
test_class.type: IdmGenerateValueService
test_class.var_name: generateValueService
test_class.declarator: identityRoleService
test_class.modifier: @Autowired
  	private
test_class.original_string: @Autowired
  	private IdmIdentityRoleService identityRoleService;
test_class.type: IdmIdentityRoleService
test_class.var_name: identityRoleService
test_class.declarator: roleFormAttributeService
test_class.modifier: @Autowired
  	private
test_class.original_string: @Autowired
  	private IdmRoleFormAttributeService roleFormAttributeService;
test_class.type: IdmRoleFormAttributeService
test_class.var_name: roleFormAttributeService
test_class.file: Realization/backend/core/core-impl/src/test/java/eu/bcvsolutions/idm/core/generator/role/IdentityRoleFormDefaultValueGeneratorTest.java
test_class.identifier: IdentityRoleFormDefaultValueGeneratorTest
test_class.superclass: extends AbstractGeneratorTest
test_case.body: @Test
  	public void testGivenValue() {
  		String overrideValue = "text-" + System.currentTimeMillis();
  		// prepare identity
  		IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
  		IdmRoleDto role = getHelper().createRole();
  		IdmIdentityContractDto primeContract = getHelper().getPrimeContract(identity);
  
  		// prepare new form definition
  		IdmFormDefinitionDto formDefinition = createFormDefinition();
  		role.setIdentityRoleAttributeDefinition(formDefinition.getId());
  		role = roleService.save(role);
  
  		// prepare form attribute 1
  		String attrCode1 = getHelper().createName();
  		String attrDefaultValue1 = "666";
  		IdmFormAttributeDto att1 = createAttribute(attrCode1, attrDefaultValue1, PersistentType.LONG,
  				formDefinition.getId());
  		roleFormAttributeService.addAttributeToSubdefintion(role, att1);
  
  		// prepare form attribute 2
  		String attrCode2 = getHelper().createName();
  		String attrDefaultValue2 = getHelper().createName() + getHelper().createName();
  		IdmFormAttributeDto att2 = createAttribute(attrCode2, attrDefaultValue2, PersistentType.SHORTTEXT,
  				formDefinition.getId());
  		roleFormAttributeService.addAttributeToSubdefintion(role, att2);
  
  		// prepare form attribute 3 without default value
  		String attrCode3 = getHelper().createName();
  		IdmFormAttributeDto att3 = createAttribute(attrCode3, null, PersistentType.SHORTTEXT, formDefinition.getId());
  		roleFormAttributeService.addAttributeToSubdefintion(role, att3);
  
  		IdmIdentityRoleDto identityRole = new IdmIdentityRoleDto();
  		identityRole.setIdentityContract(primeContract.getId());
  		identityRole.setRole(role.getId());
  		IdmFormInstanceDto formInstanceDto = new IdmFormInstanceDto();
  		formInstanceDto.setFormDefinition(formDefinition);
  		IdmFormValueDto formValueDto = new IdmFormValueDto();
  		formValueDto.setFormAttribute(att2.getId());
  		formValueDto.setShortTextValue(overrideValue);
  		formInstanceDto.setValues(Lists.newArrayList(formValueDto));
  		identityRole.getEavs().clear();
  		identityRole.getEavs().add(formInstanceDto);
  
  		// check eav before
  		List<IdmFormInstanceDto> eavs = identityRole.getEavs();
  		assertFalse(eavs.isEmpty());
  
  		createGenerator();
  
  		// generate and check values after
  		identityRole = this.valueGeneratorManager.generate(identityRole);
  		eavs = identityRole.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);
  		assertNotEquals(attrDefaultValue2, value.getValue().toString());
  		assertEquals(overrideValue, value.getValue().toString());
  
  		values = generatedEav.getValues().stream().filter(val -> val.getFormAttribute().equals(att3.getId()))
  				.collect(Collectors.toList());
  		assertEquals(0, values.size());
  	}
test_case.class_method_signature: IdentityRoleFormDefaultValueGeneratorTest.testGivenValue()
test_case.full_signature: @Test public void testGivenValue()
test_case.identifier: testGivenValue
test_case.invocations: currentTimeMillis createIdentity getHelper createRole getHelper getPrimeContract getHelper createFormDefinition setIdentityRoleAttributeDefinition getId save createName getHelper createAttribute getId addAttributeToSubdefintion createName getHelper createName getHelper createName getHelper createAttribute getId addAttributeToSubdefintion createName getHelper createAttribute getId addAttributeToSubdefintion setIdentityContract getId setRole getId setFormDefinition setFormAttribute getId setShortTextValue setValues newArrayList clear getEavs add getEavs getEavs assertFalse isEmpty createGenerator generate getEavs assertFalse isEmpty orElse findFirst filter stream equals getCode getFormDefinition getCode assertNotNull collect filter stream getValues equals getFormAttribute getId toList assertEquals size get assertEquals toString getValue collect filter stream getValues equals getFormAttribute getId toList assertEquals size get assertNotEquals toString getValue assertEquals toString getValue collect filter stream getValues equals getFormAttribute getId toList assertEquals size
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGivenValue()
focal_class.declarator: GENERATOR_NAME = "core-identity-role-form-default-value-generator"
focal_class.modifier: public static final
focal_class.original_string: public static final String GENERATOR_NAME = "core-identity-role-form-default-value-generator";
focal_class.type: String
focal_class.var_name: GENERATOR_NAME
focal_class.declarator: roleService
focal_class.modifier: @Autowired
  	private
focal_class.original_string: @Autowired
  	private IdmRoleService roleService;
focal_class.type: IdmRoleService
focal_class.var_name: roleService
focal_class.file: Realization/backend/core/core-impl/src/main/java/eu/bcvsolutions/idm/core/generator/role/IdentityRoleFormDefaultValueGenerator.java
focal_class.identifier: IdentityRoleFormDefaultValueGenerator
focal_class.class_method_signature: IdentityRoleFormDefaultValueGenerator.getName()
focal_class.full_signature: @Override public String getName()
focal_class.identifier: getName
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getName()
focal_class.class_method_signature: IdentityRoleFormDefaultValueGenerator.generate(IdmIdentityRoleDto dto, IdmGenerateValueDto valueGenerator)
focal_class.full_signature: @Override public IdmIdentityRoleDto generate(IdmIdentityRoleDto dto, IdmGenerateValueDto valueGenerator)
focal_class.identifier: generate
focal_class.modifiers: @Override public
focal_class.parameters: (IdmIdentityRoleDto dto, IdmGenerateValueDto valueGenerator)
focal_class.return: IdmIdentityRoleDto
focal_class.signature: IdmIdentityRoleDto generate(IdmIdentityRoleDto dto, IdmGenerateValueDto valueGenerator)
focal_class.superclass: extends AbstractRoleParametrizationFormDefaultValueGenerator<IdmIdentityRoleDto>
focal_method.body: @Override
  	public IdmIdentityRoleDto generate(IdmIdentityRoleDto dto, IdmGenerateValueDto valueGenerator) {
  		Assert.notNull(dto, "DTO is required.");
  		Assert.notNull(valueGenerator, "Value generator is required.");
  		UUID roleId = dto.getRole();
  
  		IdmRoleDto roleDto = null;
  		// Role id may not be set
  		if (roleId == null) {
  			return dto;
  		} else {
  			roleDto = roleService.get(roleId);
  		}
  
  		// Defensive behavior if role doesn't exist
  		if (roleDto == null) {
  			return dto;
  		}
  
  		// TODO: now exists only one form instance for identity roles and conpcets
  		List<IdmFormInstanceDto> existingEavs = dto.getEavs();
  		IdmFormInstanceDto eavs = getDefaultValuesByRoleDefinition(roleDto, valueGenerator,
  				existingEavs.isEmpty() ? null : existingEavs.get(0), dto);
  		if (eavs == null) {
  			return dto;
  		}
  		dto.getEavs().clear();
  		dto.getEavs().add(eavs);
  		return dto;
  	}
focal_method.class_method_signature: IdentityRoleFormDefaultValueGenerator.generate(IdmIdentityRoleDto dto, IdmGenerateValueDto valueGenerator)
focal_method.full_signature: @Override public IdmIdentityRoleDto generate(IdmIdentityRoleDto dto, IdmGenerateValueDto valueGenerator)
focal_method.identifier: generate
focal_method.invocations: notNull notNull getRole get getEavs getDefaultValuesByRoleDefinition isEmpty get clear getEavs add getEavs
focal_method.modifiers: @Override public
focal_method.parameters: (IdmIdentityRoleDto dto, IdmGenerateValueDto valueGenerator)
focal_method.return: IdmIdentityRoleDto
focal_method.signature: IdmIdentityRoleDto generate(IdmIdentityRoleDto dto, IdmGenerateValueDto valueGenerator)