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);
}
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())));
}
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())));
}
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());
}
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())));
}
Aggregations