use of eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto in project CzechIdMng by bcvsolutions.
the class DefaultEntityEventManagerUnitTest method testResurrectEventWithLoadedContent.
@Test
public void testResurrectEventWithLoadedContent() {
IdmIdentityDto mockOwner = new IdmIdentityDto(UUID.randomUUID());
IdmEntityEventDto entityEvent = new IdmEntityEventDto(UUID.randomUUID());
entityEvent.setOwnerType(IdmIdentity.class.getCanonicalName());
entityEvent.setOwnerId((UUID) mockOwner.getId());
entityEvent.setEventType(CoreEventType.NOTIFY.name());
//
when(lookupService.lookupDto(IdmIdentity.class, mockOwner.getId())).thenReturn(mockOwner);
//
EntityEvent<Identifiable> event = eventManager.toEvent(entityEvent);
//
Assert.assertEquals(mockOwner, event.getContent());
Assert.assertEquals(CoreEventType.NOTIFY.name(), event.getType().name());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto in project CzechIdMng by bcvsolutions.
the class DefaultEntityEventManagerUnitTest method testCreatedEventsHigherPriorityByDuplicate.
@Test
public void testCreatedEventsHigherPriorityByDuplicate() {
List<IdmEntityEventDto> highEvents = new ArrayList<>();
DateTime created = new DateTime();
UUID ownerId = UUID.randomUUID();
IdmEntityEventDto highEventOne = new IdmEntityEventDto(UUID.randomUUID());
highEventOne.setCreated(created.minusMillis(11));
highEventOne.setPriority(PriorityType.HIGH);
highEventOne.setOwnerId(UUID.randomUUID());
highEvents.add(highEventOne);
IdmEntityEventDto highEventTwo = new IdmEntityEventDto(UUID.randomUUID());
highEventTwo.setCreated(created.minusMillis(21));
highEventTwo.setPriority(PriorityType.HIGH);
highEventTwo.setOwnerId(ownerId);
highEvents.add(highEventTwo);
when(entityEventService.findToExecute(any(), any(DateTime.class), eq(PriorityType.HIGH), any())).thenReturn(new PageImpl<>(highEvents));
//
List<IdmEntityEventDto> normalEvents = new ArrayList<>();
IdmEntityEventDto normalEventOne = new IdmEntityEventDto(UUID.randomUUID());
normalEventOne.setCreated(created.minusMillis(18));
normalEventOne.setPriority(PriorityType.NORMAL);
normalEventOne.setOwnerId(UUID.randomUUID());
normalEvents.add(normalEventOne);
IdmEntityEventDto normalEventTwo = new IdmEntityEventDto(UUID.randomUUID());
normalEventTwo.setCreated(created.minusMillis(4));
normalEventTwo.setPriority(PriorityType.NORMAL);
normalEventTwo.setOwnerId(ownerId);
normalEvents.add(normalEventTwo);
when(entityEventService.findToExecute(any(), any(DateTime.class), eq(PriorityType.NORMAL), any())).thenReturn(new PageImpl<>(normalEvents));
//
List<IdmEntityEventDto> events = eventManager.getCreatedEvents("instance");
//
// normalEventTwo (high now) - highEventOne - normalEventOne
Assert.assertEquals(3, events.size());
Assert.assertEquals(PriorityType.HIGH, events.get(0).getPriority());
Assert.assertEquals(normalEventTwo.getId(), events.get(0).getId());
Assert.assertEquals(highEventOne.getId(), events.get(1).getId());
Assert.assertEquals(normalEventOne.getId(), events.get(2).getId());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto in project CzechIdMng by bcvsolutions.
the class DefaultEntityEventManagerUnitTest method createEvents.
private Page<IdmEntityEventDto> createEvents(PriorityType priority, int count) {
List<IdmEntityEventDto> events = new ArrayList<>();
DateTime created = new DateTime().minusMillis(count);
for (int i = 0; i < count; i++) {
IdmEntityEventDto event = new IdmEntityEventDto();
event.setCreated(created.plusMillis(count));
event.setPriority(priority);
event.setOwnerId(UUID.randomUUID());
event.setEventType("custom");
events.add(event);
}
//
return new PageImpl<>(events);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto in project CzechIdMng by bcvsolutions.
the class IdmEntityEventFilterIntegrationTest method testFindByOwnerId.
@Test
@Transactional
public void testFindByOwnerId() {
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);
//
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.setOwnerId(ownerOneId);
//
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 testFindByParentId.
@Test
@Transactional
public void testFindByParentId() {
UUID ownerId = UUID.randomUUID();
IdmEntityEventDto entityEvent = new IdmEntityEventDto();
entityEvent.setOwnerType("mockType");
entityEvent.setEventType("mockEvent");
entityEvent.setOwnerId(ownerId);
entityEvent.setInstanceId("mockInstance");
entityEvent.setResult(new OperationResultDto(OperationState.CANCELED));
entityEvent.setPriority(PriorityType.NORMAL);
entityEvent = service.save(entityEvent);
//
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.setParent(entityEvent.getId());
entityEventOne = service.save(entityEventOne);
//
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.EXCEPTION));
entityEventTwo.setPriority(PriorityType.NORMAL);
entityEventTwo.setParent(entityEventOne.getId());
entityEventTwo = service.save(entityEventTwo);
//
IdmEntityEventFilter filter = new IdmEntityEventFilter();
filter.setOwnerType("mockType");
filter.setParentId(entityEventTwo.getId());
//
List<IdmEntityEventDto> events = service.find(filter, null).getContent();
Assert.assertEquals(0, events.size());
//
filter.setParentId(entityEvent.getId());
events = service.find(filter, null).getContent();
Assert.assertEquals(1, events.size());
Assert.assertEquals(entityEventOne.getId(), events.get(0).getId());
//
filter.setParentId(entityEventOne.getId());
events = service.find(filter, null).getContent();
Assert.assertEquals(1, events.size());
Assert.assertEquals(entityEventTwo.getId(), events.get(0).getId());
}
Aggregations