@Test
public void testTwoAutomatic() {

	String automaticRoleValue = "test" + System.currentTimeMillis();
	IdmIdentityDto identity = getHelper().createIdentity(new GuardedString());
	identity.setDescription(automaticRoleValue);
	identity.setTitleAfter(automaticRoleValue);
	identity = identityService.save(identity);
	IdmRoleDto role = getHelper().createRole();
	IdmAutomaticRoleAttributeDto automaticRoleOne = getHelper().createAutomaticRole(role.getId());
	getHelper().createAutomaticRoleRule(
			automaticRoleOne.getId(),
			AutomaticRoleAttributeRuleComparison.EQUALS,
			AutomaticRoleAttributeRuleType.IDENTITY,
			IdmIdentity_.description.getName(), null, automaticRoleValue);
	
	IdmAutomaticRoleAttributeDto automaticRoleTwo = getHelper().createAutomaticRole(role.getId());
	getHelper().createAutomaticRoleRule(
			automaticRoleTwo.getId(),
			AutomaticRoleAttributeRuleComparison.EQUALS,
			AutomaticRoleAttributeRuleType.IDENTITY,
			IdmIdentity_.titleAfter.getName(), null, automaticRoleValue);
	getHelper().recalculateAutomaticRoleByAttribute(automaticRoleOne.getId());
	getHelper().recalculateAutomaticRoleByAttribute(automaticRoleTwo.getId());
	List<IdmIdentityRoleDto> roles = identityRoleService.findAllByIdentity(identity.getId());
	assertEquals(2, roles.size());
	IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityRoleByIdentityDeduplicationBulkAction.NAME);
	bulkAction.setIdentifiers(Sets.newHashSet(identity.getId()));
	
	IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
	checkResultLrt(processAction, 1l, null, null);
	roles = identityRoleService.findAllByIdentity(identity.getId());
	assertEquals(2, roles.size());
}