use of eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto in project CzechIdMng by bcvsolutions.
the class AbstractMonitoringIgnoredBulkAction method processDto.
@Override
protected OperationResult processDto(DTO dto) {
IdmEntityStateDto state = new IdmEntityStateDto();
state.setResult(new OperationResultDto.Builder(OperationState.BLOCKED).setModel(new DefaultResultModel(CoreResultCode.MONITORING_IGNORED)).build());
entityStateManager.saveState(dto, state);
//
return new OperationResult.Builder(OperationState.EXECUTED).build();
}
use of eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmEntityStateServiceIntegrationTest method testReferentialIntegrityOwnerIsDeleted.
@Test
@Ignore
public void testReferentialIntegrityOwnerIsDeleted() {
IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
IdmIdentityDto identityTwo = getHelper().createIdentity((GuardedString) null);
//
IdmEntityStateDto entityState = new IdmEntityStateDto();
entityState.setOwnerId(lookupService.getOwnerId(identity));
entityState.setOwnerType(lookupService.getOwnerType(identity));
entityState.setResult(new OperationResultDto(OperationState.BLOCKED));
entityState = entityStateService.save(entityState);
//
IdmEntityStateDto entityStateTwo = new IdmEntityStateDto();
entityStateTwo.setOwnerId(lookupService.getOwnerId(identityTwo));
entityStateTwo.setOwnerType(lookupService.getOwnerType(identityTwo));
entityStateTwo.setResult(new OperationResultDto(OperationState.BLOCKED));
entityStateTwo = entityStateService.save(entityStateTwo);
//
Assert.assertNotNull(entityState.getId());
Assert.assertNotNull(entityStateTwo.getId());
//
getHelper().getService(IdmIdentityService.class).delete(identityTwo);
//
Assert.assertNull(entityStateService.get(entityStateTwo));
Assert.assertNotNull(entityStateService.get(entityState));
}
use of eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmEntityEventServiceIntegrationTest method testReferentialIntegrityOwnerIsDeleted.
@Test
@Ignore
public void testReferentialIntegrityOwnerIsDeleted() {
IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
IdmIdentityDto identityTwo = getHelper().createIdentity((GuardedString) null);
//
IdmEntityEventDto entityEvent = new IdmEntityEventDto();
entityEvent.setOwnerType(entityEventManager.getOwnerType(identity.getClass()));
entityEvent.setEventType("empty");
entityEvent.setOwnerId(identity.getId());
entityEvent.setInstanceId("empty");
entityEvent.setResult(new OperationResultDto(OperationState.BLOCKED));
entityEvent.setPriority(PriorityType.NORMAL);
entityEvent = entityEventService.save(entityEvent);
//
Assert.assertNotNull(entityEvent.getId());
//
IdmEntityStateDto entityState = new IdmEntityStateDto(entityEvent);
entityState.setResult(new OperationResultDto(OperationState.BLOCKED));
entityState = entityStateService.save(entityState);
//
Assert.assertNotNull(entityState.getId());
//
identityService.delete(identityTwo);
//
Assert.assertNotNull(identityService.get(identity));
Assert.assertNotNull(entityEventService.get(entityEvent));
Assert.assertNotNull(entityStateService.get(entityState));
//
identityService.delete(identity);
//
Assert.assertNull(identityService.get(identity));
Assert.assertNull(entityEventService.get(entityEvent));
Assert.assertNull(entityStateService.get(entityState));
}
use of eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmEntityEventServiceIntegrationTest method testReferentialIntegrity.
@Test
@Transactional
public void testReferentialIntegrity() {
IdmEntityEventDto entityEvent = new IdmEntityEventDto();
entityEvent.setOwnerType("empty");
entityEvent.setEventType("empty");
entityEvent.setOwnerId(UUID.randomUUID());
entityEvent.setInstanceId("empty");
entityEvent.setResult(new OperationResultDto(OperationState.BLOCKED));
entityEvent.setPriority(PriorityType.NORMAL);
entityEvent = entityEventService.save(entityEvent);
//
Assert.assertNotNull(entityEvent.getId());
//
IdmEntityStateDto entityState = new IdmEntityStateDto(entityEvent);
entityState.setResult(new OperationResultDto(OperationState.BLOCKED));
entityState = entityStateService.save(entityState);
//
Assert.assertNotNull(entityState.getId());
//
entityEventService.delete(entityEvent);
//
Assert.assertNull(entityEventService.get(entityEvent));
Assert.assertNull(entityStateService.get(entityState));
}
use of eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityContractServiceIntegrationTest method testSkipAndRemoveAutomaticRoleOnInvalidContract.
@Test
public void testSkipAndRemoveAutomaticRoleOnInvalidContract() {
IdmTreeNodeDto node = getHelper().createTreeNode();
// define automatic role for parent
IdmRoleDto role = getHelper().createRole();
IdmRoleDto subRole = getHelper().createRole();
getHelper().createRoleComposition(role, subRole);
IdmRoleTreeNodeDto automaticRole = getHelper().createRoleTreeNode(role, node, RecursionType.NO, true);
// create identity with contract on node
IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
IdmIdentityContractDto contract = getHelper().createContract(identity, node);
// role should be assigned now
List<IdmIdentityRoleDto> assignedRoles = identityRoleService.findAllByIdentity(identity.getId());
Assert.assertEquals(2, assignedRoles.size());
Assert.assertTrue(assignedRoles.stream().anyMatch(ir -> automaticRole.getId().equals(ir.getAutomaticRole())));
Assert.assertTrue(assignedRoles.stream().anyMatch(ir -> ir.getDirectRole() != null));
//
contract.setValidTill(LocalDate.now().minusDays(2));
EntityEvent<IdmIdentityContractDto> event = new IdentityContractEvent(IdentityContractEventType.UPDATE, contract);
event.getProperties().put(AutomaticRoleManager.SKIP_RECALCULATION, Boolean.TRUE);
contract = service.publish(event).getContent();
UUID contractId = contract.getId();
IdmEntityStateFilter filter = new IdmEntityStateFilter();
filter.setStates(Lists.newArrayList(OperationState.BLOCKED));
filter.setResultCode(CoreResultCode.AUTOMATIC_ROLE_SKIPPED_INVALID_CONTRACT.getCode());
filter.setOwnerType(entityStateManager.getOwnerType(IdmIdentityContractDto.class));
List<IdmEntityStateDto> skippedStates = entityStateManager.findStates(filter, null).getContent();
Assert.assertTrue(skippedStates.stream().anyMatch(s -> s.getOwnerId().equals(contractId)));
//
assignedRoles = identityRoleService.findAllByIdentity(identity.getId());
Assert.assertEquals(2, assignedRoles.size());
Assert.assertTrue(assignedRoles.stream().anyMatch(ir -> automaticRole.getId().equals(ir.getAutomaticRole())));
Assert.assertTrue(assignedRoles.stream().anyMatch(ir -> ir.getDirectRole() != null));
//
// recount skipped automatic roles
longRunningTaskManager.execute(new ProcessSkippedAutomaticRoleByTreeForContractTaskExecutor());
skippedStates = entityStateManager.findStates(filter, null).getContent();
Assert.assertFalse(skippedStates.stream().anyMatch(s -> s.getOwnerId().equals(automaticRole.getId())));
//
assignedRoles = identityRoleService.findAllByIdentity(identity.getId());
Assert.assertTrue(assignedRoles.isEmpty());
}
Aggregations