use of eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto in project CzechIdMng by bcvsolutions.
the class EntityEventDeleteProcessor method process.
@Override
public EventResult<IdmEntityEventDto> process(EntityEvent<IdmEntityEventDto> event) {
IdmEntityEventDto role = event.getContent();
//
service.deleteInternal(role);
//
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto in project CzechIdMng by bcvsolutions.
the class EntityEventExecuteProcessor method process.
@Override
public EventResult<IdmEntityEventDto> process(EntityEvent<IdmEntityEventDto> event) {
IdmEntityEventDto entityEvent = event.getContent();
//
EntityEvent<Identifiable> resurectedEvent;
try {
resurectedEvent = entityEventManager.toEvent(entityEvent);
// execute
EventContext<Identifiable> context = entityEventManager.process(resurectedEvent);
entityEvent.setProcessedOrder(context.getProcessedOrder());
entityEvent.setResult(new OperationResultDto.Builder(OperationState.EXECUTED).build());
} catch (EventContentDeletedException ex) {
// content was deleted - log state
LOG.warn("Event content was deleted, event cannot be executed.", ex);
entityEvent.setResult(new OperationResultDto.Builder(// it's expected ex, lower level
OperationState.NOT_EXECUTED).setException(ex).build());
}
//
event.setContent(entityEvent);
//
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto in project CzechIdMng by bcvsolutions.
the class AsynchronousAccountManagementIntegrationTest method testAsynchronousAccountManagementError.
@Test
public void testAsynchronousAccountManagementError() {
// add error to some script
SysSystemDto system = helper.createTestResourceSystem(true);
SysSystemMappingDto mapping = helper.getDefaultMapping(system);
SysSystemAttributeMappingDto attributeHandlingUserName = schemaAttributeHandlingService.findBySystemMappingAndName(mapping.getId(), TestHelper.ATTRIBUTE_MAPPING_NAME);
// username is transformed with error
attributeHandlingUserName.setTransformToResourceScript("returan \"" + "error" + "\";");
attributeHandlingUserName = schemaAttributeHandlingService.save(attributeHandlingUserName);
IdmIdentityDto identity = helper.createIdentity();
IdmRoleDto role = helper.createRole();
helper.createRoleSystem(role, system);
IdmIdentityRoleDto identityRole = helper.createIdentityRole(identity, role);
try {
helper.waitForResult(res -> {
return !(entityEventService.findByState(configurationService.getInstanceId(), OperationState.CREATED).isEmpty() && entityEventService.findByState(configurationService.getInstanceId(), OperationState.RUNNING).isEmpty());
});
AccAccountDto account = accountService.getAccount(identity.getUsername(), system.getId());
Assert.assertNull(account);
//
// find event result with exception
IdmEntityEventFilter eventFilter = new IdmEntityEventFilter();
eventFilter.setOwnerId(identityRole.getId());
eventFilter.setStates(Lists.newArrayList(OperationState.EXCEPTION));
List<IdmEntityEventDto> failedEvents = entityEventService.find(eventFilter, null).getContent();
//
Assert.assertEquals(1, failedEvents.size());
Assert.assertEquals(CoreResultCode.GROOVY_SCRIPT_EXCEPTION.getCode(), failedEvents.get(0).getResult().getCode());
} finally {
identityService.delete(identity);
systemService.delete(system);
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto in project CzechIdMng by bcvsolutions.
the class IdmEntityEventFilterIntegrationTest method testFindByOwnerType.
@Test
@Transactional
public void testFindByOwnerType() {
UUID ownerOneId = UUID.randomUUID();
IdmEntityEventDto entityEventOne = new IdmEntityEventDto();
entityEventOne.setOwnerType("mockTypeOne");
entityEventOne.setEventType("mockEvent");
entityEventOne.setOwnerId(ownerOneId);
entityEventOne.setInstanceId("mockInstance");
entityEventOne.setResult(new OperationResultDto(OperationState.BLOCKED));
entityEventOne.setPriority(PriorityType.NORMAL);
entityEventOne = service.save(entityEventOne);
//
UUID ownerTwoId = UUID.randomUUID();
IdmEntityEventDto entityEventTwo = new IdmEntityEventDto();
entityEventTwo.setOwnerType("mockTypeTwo");
entityEventTwo.setEventType("mockEvent");
entityEventTwo.setOwnerId(ownerTwoId);
entityEventTwo.setInstanceId("mockInstance");
entityEventTwo.setResult(new OperationResultDto(OperationState.BLOCKED));
entityEventTwo.setPriority(PriorityType.NORMAL);
entityEventTwo = service.save(entityEventTwo);
//
IdmEntityEventFilter filter = new IdmEntityEventFilter();
filter.setOwnerType("mockTypeOne");
//
List<IdmEntityEventDto> events = service.find(filter, null).getContent();
Assert.assertEquals(1, events.size());
Assert.assertEquals(entityEventOne.getId(), events.get(0).getId());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto in project CzechIdMng by bcvsolutions.
the class IdmEntityEventFilterIntegrationTest method testFindByCreated.
@Test
@Transactional
public void testFindByCreated() {
UUID ownerOneId = UUID.randomUUID();
IdmEntityEventDto entityEventOne = new IdmEntityEventDto();
entityEventOne.setOwnerType("mockType");
entityEventOne.setEventType("mockEvent");
entityEventOne.setOwnerId(ownerOneId);
entityEventOne.setInstanceId("mockInstance");
entityEventOne.setResult(new OperationResultDto(OperationState.BLOCKED));
entityEventOne.setPriority(PriorityType.NORMAL);
entityEventOne = service.save(entityEventOne);
//
helper.waitForResult(null, null, 1);
//
UUID ownerTwoId = UUID.randomUUID();
IdmEntityEventDto entityEventTwo = new IdmEntityEventDto();
entityEventTwo.setOwnerType("mockType");
entityEventTwo.setEventType("mockEvent");
entityEventTwo.setOwnerId(ownerTwoId);
entityEventTwo.setInstanceId("mockInstance");
entityEventTwo.setResult(new OperationResultDto(OperationState.BLOCKED));
entityEventTwo.setPriority(PriorityType.NORMAL);
entityEventTwo = service.save(entityEventTwo);
//
IdmEntityEventFilter filter = new IdmEntityEventFilter();
filter.setCreatedFrom(entityEventTwo.getCreated());
filter.setOwnerType("mockType");
List<IdmEntityEventDto> events = service.find(filter, null).getContent();
Assert.assertEquals(1, events.size());
Assert.assertEquals(entityEventTwo.getId(), events.get(0).getId());
//
filter.setCreatedFrom(null);
filter.setCreatedTill(entityEventTwo.getCreated());
events = service.find(filter, null).getContent();
Assert.assertEquals(2, events.size());
//
filter.setCreatedTill(entityEventOne.getCreated());
events = service.find(filter, null).getContent();
Assert.assertEquals(1, events.size());
Assert.assertEquals(entityEventOne.getId(), events.get(0).getId());
}
Aggregations