Search in sources :

Example 1 with AcceptedContent

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());
}
Also used : AcceptedContent(eu.bcvsolutions.idm.core.event.AcceptedContent) IdmEntityEventDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 2 with AcceptedContent

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);
}
Also used : AcceptedContent(eu.bcvsolutions.idm.core.event.AcceptedContent) IdmEntityEventDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 3 with AcceptedContent

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);
}
Also used : AcceptedContent(eu.bcvsolutions.idm.core.event.AcceptedContent) IdmEntityEventDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 4 with AcceptedContent

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());
}
Also used : AcceptedContent(eu.bcvsolutions.idm.core.event.AcceptedContent) IdmEntityEventDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 5 with AcceptedContent

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();
    }
}
Also used : IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) DefaultEventContext(eu.bcvsolutions.idm.core.api.event.DefaultEventContext) IdmEntityEventDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto) AcceptedContent(eu.bcvsolutions.idm.core.event.AcceptedContent) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) EntityGenerateValuesProcessor(eu.bcvsolutions.idm.core.model.event.processor.EntityGenerateValuesProcessor) Autowired(org.springframework.beans.factory.annotation.Autowired) SecurityService(eu.bcvsolutions.idm.core.security.api.service.SecurityService) CoreEvent(eu.bcvsolutions.idm.core.api.event.CoreEvent) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) MockDto(eu.bcvsolutions.idm.core.event.domain.MockDto) TransactionContextHolder(eu.bcvsolutions.idm.core.api.domain.TransactionContextHolder) IdentityEventType(eu.bcvsolutions.idm.core.model.event.IdentityEvent.IdentityEventType) ObserveDtoProcessor(eu.bcvsolutions.idm.core.model.event.processor.ObserveDtoProcessor) TestEntityEventProcessorConfiguration(eu.bcvsolutions.idm.core.event.TestEntityEventProcessorConfiguration) EntityEventProcessorFilter(eu.bcvsolutions.idm.core.api.dto.filter.EntityEventProcessorFilter) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) IdentityContractEventType(eu.bcvsolutions.idm.core.model.event.IdentityContractEvent.IdentityContractEventType) PageRequest(org.springframework.data.domain.PageRequest) IdmEntityStateFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityStateFilter) UUID(java.util.UUID) PriorityType(eu.bcvsolutions.idm.core.api.domain.PriorityType) Serializable(java.io.Serializable) IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) List(java.util.List) EventConfiguration(eu.bcvsolutions.idm.core.api.config.domain.EventConfiguration) NeverEndingProcessor(eu.bcvsolutions.idm.core.model.event.processor.NeverEndingProcessor) EventType(eu.bcvsolutions.idm.core.api.event.EventType) IdentityContractEvent(eu.bcvsolutions.idm.core.model.event.IdentityContractEvent) IdentityEvent(eu.bcvsolutions.idm.core.model.event.IdentityEvent) EntityEventProcessorDto(eu.bcvsolutions.idm.core.api.dto.EntityEventProcessorDto) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) RoleRequestEventType(eu.bcvsolutions.idm.core.model.event.RoleRequestEvent.RoleRequestEventType) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) TestContentTwo(eu.bcvsolutions.idm.core.event.TestContentTwo) EntityEventProcessor(eu.bcvsolutions.idm.core.api.event.EntityEventProcessor) MockOwner(eu.bcvsolutions.idm.core.event.domain.MockOwner) ArrayList(java.util.ArrayList) AbstractDto(eu.bcvsolutions.idm.core.api.dto.AbstractDto) EntityStateManager(eu.bcvsolutions.idm.core.api.service.EntityStateManager) Lists(com.google.common.collect.Lists) OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) Qualifier(org.springframework.beans.factory.annotation.Qualifier) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) EventResult(eu.bcvsolutions.idm.core.api.event.EventResult) IdentityRoleEventType(eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent.IdentityRoleEventType) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) EntityEvent(eu.bcvsolutions.idm.core.api.event.EntityEvent) Before(org.junit.Before) IdmIdentityRoleService(eu.bcvsolutions.idm.core.api.service.IdmIdentityRoleService) ConditionalContent(eu.bcvsolutions.idm.core.event.ConditionalContent) CoreException(eu.bcvsolutions.idm.core.api.exception.CoreException) TestIdentityNotifyProcessor(eu.bcvsolutions.idm.core.model.event.processor.TestIdentityNotifyProcessor) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmEntityEventFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityEventFilter) Assert.assertTrue(org.junit.Assert.assertTrue) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) Test(org.junit.Test) ApplicationContext(org.springframework.context.ApplicationContext) EventContext(eu.bcvsolutions.idm.core.api.event.EventContext) EmptyEntityEventProcessor(eu.bcvsolutions.idm.core.api.event.EmptyEntityEventProcessor) IdmEntityEventService(eu.bcvsolutions.idm.core.api.service.IdmEntityEventService) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) CoreResultCode(eu.bcvsolutions.idm.core.api.domain.CoreResultCode) CoreEventType(eu.bcvsolutions.idm.core.api.event.CoreEvent.CoreEventType) TestContent(eu.bcvsolutions.idm.core.event.TestContent) BaseDto(eu.bcvsolutions.idm.core.api.dto.BaseDto) Assert(org.junit.Assert) Assert.assertEquals(org.junit.Assert.assertEquals) Transactional(org.springframework.transaction.annotation.Transactional) AcceptedContent(eu.bcvsolutions.idm.core.event.AcceptedContent) IdmEntityEventFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityEventFilter) IdmEntityStateFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityStateFilter) IdmEntityEventDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IdmEntityEventDto (eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto)5 AcceptedContent (eu.bcvsolutions.idm.core.event.AcceptedContent)5 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)4 Test (org.junit.Test)4 Lists (com.google.common.collect.Lists)1 EventConfiguration (eu.bcvsolutions.idm.core.api.config.domain.EventConfiguration)1 CoreResultCode (eu.bcvsolutions.idm.core.api.domain.CoreResultCode)1 OperationState (eu.bcvsolutions.idm.core.api.domain.OperationState)1 PriorityType (eu.bcvsolutions.idm.core.api.domain.PriorityType)1 TransactionContextHolder (eu.bcvsolutions.idm.core.api.domain.TransactionContextHolder)1 AbstractDto (eu.bcvsolutions.idm.core.api.dto.AbstractDto)1 BaseDto (eu.bcvsolutions.idm.core.api.dto.BaseDto)1 EntityEventProcessorDto (eu.bcvsolutions.idm.core.api.dto.EntityEventProcessorDto)1 IdmEntityStateDto (eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto)1 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)1 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)1 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)1 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)1 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)1 OperationResultDto (eu.bcvsolutions.idm.core.api.dto.OperationResultDto)1