Search in sources :

Example 1 with IdmEntityEventFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityEventFilter 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);
    }
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmEntityEventFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityEventFilter) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) IdmEntityEventDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 2 with IdmEntityEventFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityEventFilter 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());
}
Also used : OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) UUID(java.util.UUID) IdmEntityEventFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityEventFilter) IdmEntityEventDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with IdmEntityEventFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityEventFilter 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());
}
Also used : OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) UUID(java.util.UUID) IdmEntityEventFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityEventFilter) IdmEntityEventDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with IdmEntityEventFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityEventFilter in project CzechIdMng by bcvsolutions.

the class IdmEntityEventFilterIntegrationTest method testFindByPriority.

@Test
@Transactional
public void testFindByPriority() {
    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.HIGH);
    entityEventTwo = service.save(entityEventTwo);
    // 
    IdmEntityEventFilter filter = new IdmEntityEventFilter();
    filter.setOwnerType("mockType");
    filter.setPriority(PriorityType.NORMAL);
    // 
    List<IdmEntityEventDto> events = service.find(filter, null).getContent();
    Assert.assertEquals(1, events.size());
    Assert.assertEquals(entityEventOne.getId(), events.get(0).getId());
    // 
    filter.setPriority(PriorityType.HIGH);
    events = service.find(filter, null).getContent();
    Assert.assertEquals(1, events.size());
    Assert.assertEquals(entityEventTwo.getId(), events.get(0).getId());
}
Also used : OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) UUID(java.util.UUID) IdmEntityEventFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityEventFilter) IdmEntityEventDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with IdmEntityEventFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityEventFilter in project CzechIdMng by bcvsolutions.

the class IdmEntityEventFilterIntegrationTest method testFindByStates.

@Test
@Transactional
public void testFindByStates() {
    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 = 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 = service.save(entityEventTwo);
    // 
    IdmEntityEventFilter filter = new IdmEntityEventFilter();
    filter.setOwnerType("mockType");
    filter.setStates(Lists.newArrayList(OperationState.BLOCKED));
    // 
    List<IdmEntityEventDto> events = service.find(filter, null).getContent();
    Assert.assertEquals(1, events.size());
    Assert.assertEquals(entityEventOne.getId(), events.get(0).getId());
    // 
    filter.setStates(Lists.newArrayList(OperationState.EXCEPTION));
    // 
    events = service.find(filter, null).getContent();
    Assert.assertEquals(1, events.size());
    Assert.assertEquals(entityEventTwo.getId(), events.get(0).getId());
    // 
    filter.setStates(Lists.newArrayList(OperationState.EXCEPTION, OperationState.BLOCKED));
    // 
    events = service.find(filter, null).getContent();
    Assert.assertEquals(2, events.size());
    Assert.assertTrue(events.stream().anyMatch(e -> e.getOwnerId().equals(ownerOneId)));
    Assert.assertTrue(events.stream().anyMatch(e -> e.getOwnerId().equals(ownerTwoId)));
}
Also used : IdmEntityEventDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto) IdmEntityEventFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityEventFilter) Autowired(org.springframework.beans.factory.annotation.Autowired) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) Test(org.junit.Test) UUID(java.util.UUID) PriorityType(eu.bcvsolutions.idm.core.api.domain.PriorityType) List(java.util.List) IdmEntityEventService(eu.bcvsolutions.idm.core.api.service.IdmEntityEventService) Lists(com.google.common.collect.Lists) OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) TestHelper(eu.bcvsolutions.idm.test.api.TestHelper) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Assert(org.junit.Assert) Transactional(org.springframework.transaction.annotation.Transactional) OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) UUID(java.util.UUID) IdmEntityEventFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityEventFilter) IdmEntityEventDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

IdmEntityEventFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityEventFilter)10 IdmEntityEventDto (eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto)9 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)9 Test (org.junit.Test)9 OperationResultDto (eu.bcvsolutions.idm.core.api.dto.OperationResultDto)8 UUID (java.util.UUID)6 Transactional (org.springframework.transaction.annotation.Transactional)6 OperationState (eu.bcvsolutions.idm.core.api.domain.OperationState)2 MockOwner (eu.bcvsolutions.idm.core.event.domain.MockOwner)2 ArrayList (java.util.ArrayList)2 PageRequest (org.springframework.data.domain.PageRequest)2 Lists (com.google.common.collect.Lists)1 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)1 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)1 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)1 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)1 PriorityType (eu.bcvsolutions.idm.core.api.domain.PriorityType)1 AbstractDto (eu.bcvsolutions.idm.core.api.dto.AbstractDto)1 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)1 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)1