Search in sources :

Example 71 with IdmEntityStateDto

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

the class DefaultIdmIdentityContractServiceIntegrationTest method testRecountAutomaticRoleWithMissingContent.

@Test
@Transactional
public void testRecountAutomaticRoleWithMissingContent() {
    // create state with missing content
    IdmEntityStateDto state = new IdmEntityStateDto();
    UUID stateId = UUID.randomUUID();
    state.setOwnerId(stateId);
    state.setOwnerType(entityStateManager.getOwnerType(IdmIdentityContractDto.class));
    state.setResult(new OperationResultDto.Builder(OperationState.BLOCKED).setModel(new DefaultResultModel(CoreResultCode.AUTOMATIC_ROLE_SKIPPED)).build());
    entityStateManager.saveState(null, state);
    state = new IdmEntityStateDto();
    state.setOwnerId(stateId);
    state.setOwnerType(entityStateManager.getOwnerType(IdmIdentityContractDto.class));
    state.setResult(new OperationResultDto.Builder(OperationState.BLOCKED).setModel(new DefaultResultModel(CoreResultCode.AUTOMATIC_ROLE_SKIPPED)).build());
    entityStateManager.saveState(null, state);
    // 
    state = new IdmEntityStateDto();
    state.setOwnerId(UUID.randomUUID());
    state.setOwnerType(entityStateManager.getOwnerType(IdmContractPositionDto.class));
    state.setResult(new OperationResultDto.Builder(OperationState.BLOCKED).setModel(new DefaultResultModel(CoreResultCode.AUTOMATIC_ROLE_SKIPPED)).build());
    entityStateManager.saveState(null, state);
    // 
    // recount skipped automatic roles
    LongRunningFutureTask<Boolean> executor = longRunningTaskManager.execute(new ProcessSkippedAutomaticRoleByTreeForContractTaskExecutor());
    IdmLongRunningTaskDto longRunningTask = longRunningTaskManager.getLongRunningTask(executor);
    Assert.assertTrue(longRunningTask.getWarningItemCount() > 1);
}
Also used : IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) ProcessSkippedAutomaticRoleByTreeForContractTaskExecutor(eu.bcvsolutions.idm.core.scheduler.task.impl.ProcessSkippedAutomaticRoleByTreeForContractTaskExecutor) IdmContractPositionDto(eu.bcvsolutions.idm.core.api.dto.IdmContractPositionDto) OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) UUID(java.util.UUID) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 72 with IdmEntityStateDto

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

the class IdmEntityStateControllerRestTest method testFindBySuperOwnerId.

@Test
public void testFindBySuperOwnerId() {
    UUID owner = UUID.randomUUID();
    UUID superOwnerOne = UUID.randomUUID();
    UUID superOwnerTwo = UUID.randomUUID();
    String ownerType = getHelper().createName();
    // 
    IdmEntityStateDto state = prepareDto();
    state.setOwnerId(owner);
    state.setSuperOwnerId(superOwnerOne);
    state.setOwnerType(ownerType);
    IdmEntityStateDto stateOne = entityStateService.save(state);
    // 
    state = prepareDto();
    state.setOwnerId(owner);
    state.setSuperOwnerId(superOwnerTwo);
    state.setOwnerType(ownerType);
    // other
    entityStateService.save(state);
    // 
    MultiValueMap<String, String> parameters = new LinkedMultiValueMap<>();
    parameters.set("superOwnerId", superOwnerOne.toString());
    parameters.set("ownerType", ownerType);
    // 
    List<IdmEntityStateDto> results = find(parameters);
    Assert.assertEquals(1, results.size());
    Assert.assertTrue(results.stream().anyMatch(s -> s.getId().equals(stateOne.getId())));
}
Also used : IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) IdmEntityEventDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto) Autowired(org.springframework.beans.factory.annotation.Autowired) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest) Lists(com.google.common.collect.Lists) AbstractReadWriteDtoController(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoController) SecurityMockMvcRequestPostProcessors.authentication(org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.authentication) MockMvcResultMatchers.status(org.springframework.test.web.servlet.result.MockMvcResultMatchers.status) OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) TestHelper(eu.bcvsolutions.idm.test.api.TestHelper) IdmEntityStateService(eu.bcvsolutions.idm.core.api.service.IdmEntityStateService) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) MultiValueMap(org.springframework.util.MultiValueMap) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) Test(org.junit.Test) UUID(java.util.UUID) PriorityType(eu.bcvsolutions.idm.core.api.domain.PriorityType) IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) List(java.util.List) IdmEntityEventService(eu.bcvsolutions.idm.core.api.service.IdmEntityEventService) ChronoUnit(java.time.temporal.ChronoUnit) MockMvcRequestBuilders.get(org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) Assert(org.junit.Assert) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) EntityEventManager(eu.bcvsolutions.idm.core.api.service.EntityEventManager) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) UUID(java.util.UUID) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest) Test(org.junit.Test)

Example 73 with IdmEntityStateDto

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

the class IdmEntityStateControllerRestTest method testFindByEventId.

@Test
public void testFindByEventId() {
    UUID owner = UUID.randomUUID();
    IdmEntityEventDto eventOne = createEvent();
    IdmEntityEventDto eventTwo = createEvent();
    String ownerType = getHelper().createName();
    // 
    IdmEntityStateDto state = prepareDto();
    state.setOwnerId(owner);
    state.setEvent(eventOne.getId());
    state.setOwnerType(ownerType);
    IdmEntityStateDto stateOne = entityStateService.save(state);
    // 
    state = prepareDto();
    state.setOwnerId(owner);
    state.setEvent(eventTwo.getId());
    state.setOwnerType(ownerType);
    // other
    entityStateService.save(state);
    // 
    MultiValueMap<String, String> parameters = new LinkedMultiValueMap<>();
    parameters.set("eventId", eventOne.getId().toString());
    parameters.set("ownerType", ownerType);
    // 
    List<IdmEntityStateDto> results = find(parameters);
    Assert.assertEquals(1, results.size());
    Assert.assertTrue(results.stream().anyMatch(s -> s.getId().equals(stateOne.getId())));
}
Also used : IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) IdmEntityEventDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto) Autowired(org.springframework.beans.factory.annotation.Autowired) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest) Lists(com.google.common.collect.Lists) AbstractReadWriteDtoController(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoController) SecurityMockMvcRequestPostProcessors.authentication(org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.authentication) MockMvcResultMatchers.status(org.springframework.test.web.servlet.result.MockMvcResultMatchers.status) OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) TestHelper(eu.bcvsolutions.idm.test.api.TestHelper) IdmEntityStateService(eu.bcvsolutions.idm.core.api.service.IdmEntityStateService) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) MultiValueMap(org.springframework.util.MultiValueMap) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) Test(org.junit.Test) UUID(java.util.UUID) PriorityType(eu.bcvsolutions.idm.core.api.domain.PriorityType) IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) List(java.util.List) IdmEntityEventService(eu.bcvsolutions.idm.core.api.service.IdmEntityEventService) ChronoUnit(java.time.temporal.ChronoUnit) MockMvcRequestBuilders.get(org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) Assert(org.junit.Assert) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) EntityEventManager(eu.bcvsolutions.idm.core.api.service.EntityEventManager) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) UUID(java.util.UUID) IdmEntityEventDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest) Test(org.junit.Test)

Example 74 with IdmEntityStateDto

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

the class IdmEntityStateControllerRestTest method testFindByResultCode.

@Test
public void testFindByResultCode() {
    UUID ownerId = UUID.randomUUID();
    // 
    IdmEntityStateDto other = prepareDto();
    other.setOwnerId(ownerId);
    other.getResult().setCode(getHelper().createName());
    other = entityStateService.save(other);
    IdmEntityStateDto idmEntityStateDto = prepareDto();
    idmEntityStateDto.setOwnerId(ownerId);
    idmEntityStateDto.getResult().setCode(getHelper().createName());
    idmEntityStateDto = entityStateService.save(idmEntityStateDto);
    // 
    MultiValueMap<String, String> parameters = new LinkedMultiValueMap<>();
    parameters.set("ownerId", ownerId.toString());
    parameters.set("resultCode", idmEntityStateDto.getResult().getCode());
    // 
    List<IdmEntityStateDto> results = find(parameters);
    Assert.assertEquals(1, results.size());
    Assert.assertEquals(idmEntityStateDto.getId(), results.get(0).getId());
}
Also used : IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) UUID(java.util.UUID) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest) Test(org.junit.Test)

Example 75 with IdmEntityStateDto

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

the class IdmEntityStateControllerRestTest method testFindByOwner.

/**
 * Find by owner and type
 */
@Test
public void testFindByOwner() {
    UUID ownerOne = UUID.randomUUID();
    UUID ownerTwo = UUID.randomUUID();
    String ownerType = getHelper().createName();
    // 
    IdmEntityStateDto state = prepareDto();
    state.setOwnerId(ownerOne);
    state.setOwnerType(ownerType);
    IdmEntityStateDto stateOne = entityStateService.save(state);
    // 
    state = prepareDto();
    state.setOwnerId(ownerTwo);
    state.setOwnerType(ownerType);
    // other
    entityStateService.save(state);
    // 
    MultiValueMap<String, String> parameters = new LinkedMultiValueMap<>();
    parameters.set("ownerId", ownerOne.toString());
    parameters.set("ownerType", ownerType);
    // 
    List<IdmEntityStateDto> results = find(parameters);
    Assert.assertEquals(1, results.size());
    Assert.assertTrue(results.stream().anyMatch(s -> s.getId().equals(stateOne.getId())));
}
Also used : IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) IdmEntityEventDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto) Autowired(org.springframework.beans.factory.annotation.Autowired) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest) Lists(com.google.common.collect.Lists) AbstractReadWriteDtoController(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoController) SecurityMockMvcRequestPostProcessors.authentication(org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.authentication) MockMvcResultMatchers.status(org.springframework.test.web.servlet.result.MockMvcResultMatchers.status) OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) TestHelper(eu.bcvsolutions.idm.test.api.TestHelper) IdmEntityStateService(eu.bcvsolutions.idm.core.api.service.IdmEntityStateService) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) MultiValueMap(org.springframework.util.MultiValueMap) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) Test(org.junit.Test) UUID(java.util.UUID) PriorityType(eu.bcvsolutions.idm.core.api.domain.PriorityType) IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) List(java.util.List) IdmEntityEventService(eu.bcvsolutions.idm.core.api.service.IdmEntityEventService) ChronoUnit(java.time.temporal.ChronoUnit) MockMvcRequestBuilders.get(org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) Assert(org.junit.Assert) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) EntityEventManager(eu.bcvsolutions.idm.core.api.service.EntityEventManager) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) UUID(java.util.UUID) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest) Test(org.junit.Test)

Aggregations

IdmEntityStateDto (eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto)77 OperationResultDto (eu.bcvsolutions.idm.core.api.dto.OperationResultDto)43 Test (org.junit.Test)41 UUID (java.util.UUID)40 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)33 DefaultResultModel (eu.bcvsolutions.idm.core.api.dto.DefaultResultModel)30 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)30 OperationState (eu.bcvsolutions.idm.core.api.domain.OperationState)24 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)23 List (java.util.List)21 Autowired (org.springframework.beans.factory.annotation.Autowired)21 IdmEntityEventDto (eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto)20 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)19 Transactional (org.springframework.transaction.annotation.Transactional)19 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)18 Lists (com.google.common.collect.Lists)15 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)15 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)15 Assert (org.junit.Assert)14 CoreResultCode (eu.bcvsolutions.idm.core.api.domain.CoreResultCode)13