IdentityRoleByIdentityDeduplicationBulkAction extends AbstractBulkAction<IdmIdentityDto, IdmIdentityFilter> { @Override public String getName() { return IdentityRoleByIdentityDeduplicationBulkAction.NAME; }  @Override ReadWriteDtoService<IdmIdentityDto, IdmIdentityFilter> getService(); @Override List<IdmFormAttributeDto> getFormAttributes(); @Override String getName(); List<IdmIdentityRoleDto> getDuplicatesIdentityRoleForContract(IdmIdentityContractDto contract); @Override int getOrder(); @Override NotificationLevel getLevel(); static final String NAME; static final String CHECK_SUBDEFINITION_CODE; static final String APPROVE_CODE; }
@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()); }
@Test public void testThreeAutomaticAndThreeManually() { String automaticRoleValue = "test" + System.currentTimeMillis(); IdmIdentityDto identity = getHelper().createIdentity(new GuardedString()); identity.setDescription(automaticRoleValue); identity.setTitleAfter(automaticRoleValue); identity.setTitleBefore(automaticRoleValue); identity = identityService.save(identity); IdmRoleDto role = getHelper().createRole(); IdmIdentityRoleDto identityRoleOne = getHelper().createIdentityRole(identity, role); IdmIdentityRoleDto identityRoleTwo = getHelper().createIdentityRole(identity, role); IdmIdentityRoleDto identityRoleThree = getHelper().createIdentityRole(identity, role); 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); IdmAutomaticRoleAttributeDto automaticRoleThree = getHelper().createAutomaticRole(role.getId()); getHelper().createAutomaticRoleRule( automaticRoleThree.getId(), AutomaticRoleAttributeRuleComparison.EQUALS, AutomaticRoleAttributeRuleType.IDENTITY, IdmIdentity_.titleBefore.getName(), null, automaticRoleValue); getHelper().recalculateAutomaticRoleByAttribute(automaticRoleOne.getId()); getHelper().recalculateAutomaticRoleByAttribute(automaticRoleTwo.getId()); getHelper().recalculateAutomaticRoleByAttribute(automaticRoleThree.getId()); List<IdmIdentityRoleDto> roles = identityRoleService.findAllByIdentity(identity.getId()); assertEquals(6, 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(3, roles.size()); for (IdmIdentityRoleDto identityRole : roles) { assertNotEquals(identityRoleOne.getId(), identityRole.getId()); assertNotEquals(identityRoleTwo.getId(), identityRole.getId()); assertNotEquals(identityRoleThree.getId(), identityRole.getId()); } }
@Test public void testAutomaticAndManuallyAndContractCombination() { String automaticRoleValue = "test" + System.currentTimeMillis(); IdmIdentityDto identity = getHelper().createIdentity(new GuardedString()); IdmIdentityContractDto primary = getHelper().getPrimeContract(identity); IdmIdentityContractDto identityContactOne = getHelper().createContract(identity); IdmIdentityContractDto identityContactTwo = getHelper().createContract(identity); identity.setDescription(automaticRoleValue); identity.setTitleAfter(automaticRoleValue); identity.setTitleBefore(automaticRoleValue); identity = identityService.save(identity); IdmRoleDto role = getHelper().createRole(); IdmIdentityRoleDto primaryOne = getHelper().createIdentityRole(primary, role); IdmIdentityRoleDto contractOneOne = getHelper().createIdentityRole(identityContactOne, role); IdmIdentityRoleDto contractOneTwo = getHelper().createIdentityRole(identityContactOne, role); IdmIdentityRoleDto contractOneThree = getHelper().createIdentityRole(identityContactOne, role); IdmIdentityRoleDto contractOneFour = getHelper().createIdentityRole(identityContactOne, role); IdmIdentityRoleDto contractTwoOne = getHelper().createIdentityRole(identityContactTwo, role); IdmIdentityRoleDto contractTwoTwo = getHelper().createIdentityRole(identityContactTwo, role); 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); IdmAutomaticRoleAttributeDto automaticRoleThree = getHelper().createAutomaticRole(role.getId()); getHelper().createAutomaticRoleRule( automaticRoleThree.getId(), AutomaticRoleAttributeRuleComparison.EQUALS, AutomaticRoleAttributeRuleType.IDENTITY, IdmIdentity_.titleBefore.getName(), null, automaticRoleValue); getHelper().recalculateAutomaticRoleByAttribute(automaticRoleOne.getId()); getHelper().recalculateAutomaticRoleByAttribute(automaticRoleTwo.getId()); getHelper().recalculateAutomaticRoleByAttribute(automaticRoleThree.getId()); List<IdmIdentityRoleDto> roles = identityRoleService.findAllByIdentity(identity.getId()); assertEquals(16, 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(9, roles.size()); roles = identityRoleService.findAllByContract(primary.getId()); assertEquals(3, roles.size()); for (IdmIdentityRoleDto identityRole : roles) { assertNotEquals(primaryOne.getId(), identityRole.getId()); } roles = identityRoleService.findAllByContract(primary.getId()); assertEquals(3, roles.size()); for (IdmIdentityRoleDto identityRole : roles) { assertNotEquals(primaryOne.getId(), identityRole.getId()); } roles = identityRoleService.findAllByContract(identityContactOne.getId()); assertEquals(3, roles.size()); for (IdmIdentityRoleDto identityRole : roles) { assertNotEquals(contractOneOne.getId(), identityRole.getId()); assertNotEquals(contractOneTwo.getId(), identityRole.getId()); assertNotEquals(contractOneThree.getId(), identityRole.getId()); assertNotEquals(contractOneFour.getId(), identityRole.getId()); } roles = identityRoleService.findAllByContract(identityContactTwo.getId()); assertEquals(3, roles.size()); for (IdmIdentityRoleDto identityRole : roles) { assertNotEquals(contractTwoOne.getId(), identityRole.getId()); assertNotEquals(contractTwoTwo.getId(), identityRole.getId()); } }