Search in sources :

Example 26 with IdmRoleRequestFilter

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

the class IdmRoleRequestController method toFilter.

@Override
protected IdmRoleRequestFilter toFilter(MultiValueMap<String, Object> parameters) {
    IdmRoleRequestFilter filter = new IdmRoleRequestFilter(parameters, getParameterConverter());
    // 
    filter.setApplicant(getParameterConverter().toString(parameters, "applicant"));
    filter.setApplicantId(getParameterConverter().toUuid(parameters, "applicantId"));
    // 
    if (filter.getApplicant() != null) {
        try {
            // Applicant can be UUID (Username vs UUID identification schizma)
            // TODO: replace with parameterConverter#toEntityUuid ...
            filter.setApplicantId(UUID.fromString(filter.getApplicant()));
            filter.setApplicant(null);
        } catch (IllegalArgumentException ex) {
        // Ok applicant is not UUID
        }
    }
    // TODO: remove redundant state field
    filter.setState(getParameterConverter().toEnum(parameters, "state", RoleRequestState.class));
    filter.setStates(getParameterConverter().toEnums(parameters, "states", RoleRequestState.class));
    filter.setSystemStates(getParameterConverter().toEnums(parameters, "systemStates", OperationState.class));
    filter.setApplicants(getParameterConverter().toUuids(parameters, "applicants"));
    filter.setCreatorId(getParameterConverter().toEntityUuid(parameters, IdmRoleRequestFilter.PARAMETER_CREATOR_ID, IdmIdentityDto.class));
    filter.setExecuted(getParameterConverter().toBoolean(parameters, "executed"));
    filter.setIncludeApprovers(getParameterConverter().toBoolean(parameters, "includeApprovers", false));
    return filter;
}
Also used : RoleRequestState(eu.bcvsolutions.idm.core.api.domain.RoleRequestState) IdmRoleRequestFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleRequestFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState)

Example 27 with IdmRoleRequestFilter

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

the class DefaultIdmRoleServiceIntegrationTest method testCreateConceptRoleWithoutRequiredValue.

@Test(expected = ResultCodeException.class)
public void testCreateConceptRoleWithoutRequiredValue() throws Exception {
    IdmIdentityDto identity = getHelper().createIdentity();
    IdmRoleDto role = createRoleWithAttributes();
    IdmIdentityContractDto identityContact = getHelper().createContract(identity);
    IdmRoleRequestDto roleRequest = getHelper().createRoleRequest(identityContact, role);
    // Get request by id
    String response = getMockMvc().perform(get(getDetailRoleRequestUrl(roleRequest.getId())).with(authentication(getAdminAuthentication())).contentType(TestHelper.HAL_CONTENT_TYPE)).andExpect(status().isOk()).andReturn().getResponse().getContentAsString();
    IdmRoleRequestDto createdDto = (IdmRoleRequestDto) getMapper().readValue(response, roleRequest.getClass());
    // Request from REST doesn't contains concept (from version 9.7.0!)
    assertTrue(createdDto.getConceptRoles().isEmpty());
    roleRequestService.validate(createdDto);
    roleRequestService.validate(roleRequestService.get(createdDto.getId(), new IdmRoleRequestFilter(true)));
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmRoleRequestFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleRequestFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) AbstractRestTest(eu.bcvsolutions.idm.test.api.AbstractRestTest) Test(org.junit.Test)

Aggregations

IdmRoleRequestFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleRequestFilter)27 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)21 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)19 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)16 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)16 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)15 Test (org.junit.Test)15 Transactional (org.springframework.transaction.annotation.Transactional)15 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)13 IdmRequestIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRequestIdentityRoleDto)11 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)10 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)10 Serializable (java.io.Serializable)8 UUID (java.util.UUID)8 RoleRequestState (eu.bcvsolutions.idm.core.api.domain.RoleRequestState)6 IdmIdentityRoleFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter)6 IdmIdentityRoleService (eu.bcvsolutions.idm.core.api.service.IdmIdentityRoleService)5 IdmRoleRequestService (eu.bcvsolutions.idm.core.api.service.IdmRoleRequestService)5 PersistentType (eu.bcvsolutions.idm.core.eav.api.domain.PersistentType)5 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)5