use of eu.bcvsolutions.idm.core.event.AcceptedContent in project CzechIdMng by bcvsolutions.
the class DefaultEntityEventManagerIntergationTest method testCancelRunningEvent.
@Test
public void testCancelRunningEvent() {
IdmEntityEventDto event = new IdmEntityEventDto();
AcceptedContent content = new AcceptedContent();
content.setId(UUID.randomUUID());
event.setContent(content);
event.setOwnerId(content.getId());
event.setOwnerType(manager.getOwnerType(content));
event.setResult(new OperationResultDto.Builder(OperationState.RUNNING).build());
event = manager.saveEvent(event);
//
manager.cancelEvent(event);
//
event = manager.getEvent(event.getId());
Assert.assertEquals(OperationState.CANCELED, event.getResult().getState());
}
use of eu.bcvsolutions.idm.core.event.AcceptedContent in project CzechIdMng by bcvsolutions.
the class DefaultEntityEventManagerIntergationTest method testCancelNotRunningEventWitnResult.
@Test(expected = ResultCodeException.class)
public void testCancelNotRunningEventWitnResult() {
IdmEntityEventDto event = new IdmEntityEventDto();
AcceptedContent content = new AcceptedContent();
content.setId(UUID.randomUUID());
event.setContent(content);
event.setOwnerId(content.getId());
event.setOwnerType(manager.getOwnerType(content));
event.setResult(new OperationResultDto.Builder(OperationState.BLOCKED).build());
event = manager.saveEvent(event);
//
manager.cancelEvent(event);
}
use of eu.bcvsolutions.idm.core.event.AcceptedContent in project CzechIdMng by bcvsolutions.
the class DefaultEntityEventManagerIntergationTest method testCancelNotRunningEvent.
@Test(expected = ResultCodeException.class)
public void testCancelNotRunningEvent() {
IdmEntityEventDto event = new IdmEntityEventDto();
AcceptedContent content = new AcceptedContent();
content.setId(UUID.randomUUID());
event.setContent(content);
event.setOwnerId(content.getId());
event.setOwnerType(manager.getOwnerType(content));
event = manager.saveEvent(event);
//
manager.cancelEvent(event);
}
use of eu.bcvsolutions.idm.core.event.AcceptedContent in project CzechIdMng by bcvsolutions.
the class DefaultEntityEventManagerIntergationTest method testCancelCreatedEvent.
@Test
public void testCancelCreatedEvent() {
IdmEntityEventDto event = new IdmEntityEventDto();
AcceptedContent content = new AcceptedContent();
content.setId(UUID.randomUUID());
event.setContent(content);
event.setOwnerId(content.getId());
event.setOwnerType(manager.getOwnerType(content));
event.setResult(new OperationResultDto.Builder(OperationState.CREATED).build());
event = manager.saveEvent(event);
//
manager.cancelEvent(event);
//
event = manager.getEvent(event.getId());
Assert.assertEquals(OperationState.CANCELED, event.getResult().getState());
}
use of eu.bcvsolutions.idm.core.event.AcceptedContent in project CzechIdMng by bcvsolutions.
the class DefaultEntityEventManagerIntergationTest method testAcceptedException.
@Test
public void testAcceptedException() {
try {
getHelper().enableAsynchronousProcessing();
//
IdmEntityEventDto event = new IdmEntityEventDto();
AcceptedContent content = new AcceptedContent();
content.setId(UUID.randomUUID());
event.setContent(content);
event.setOwnerId(content.getId());
event.setOwnerType(manager.getOwnerType(content));
event = manager.saveEvent(event);
manager.executeEvent(event);
IdmEntityEventFilter filter = new IdmEntityEventFilter();
filter.setOwnerId(content.getId());
filter.setStates(Lists.newArrayList(OperationState.EXECUTED));
//
// wait for execute event
getHelper().waitForResult(res -> {
return entityEventService.find(filter, PageRequest.of(0, 1)).getContent().isEmpty();
}, 500, 20);
//
event = manager.getEvent(event.getId());
Assert.assertEquals(OperationState.EXECUTED, event.getResult().getState());
Assert.assertEquals(CoreResultCode.ACCEPTED.name(), event.getResult().getCode());
//
// check state is executed too
IdmEntityStateFilter stateFilter = new IdmEntityStateFilter();
stateFilter.setEventId(event.getId());
List<IdmEntityStateDto> states = entityStateManager.findStates(content, null).getContent();
Assert.assertFalse(states.isEmpty());
Assert.assertTrue(states.stream().allMatch(s -> s.getResult().getState() == OperationState.EXECUTED && s.getResult().getCode().equals(CoreResultCode.ACCEPTED.name())));
} finally {
getHelper().disableAsynchronousProcessing();
}
}
Aggregations