Search in sources :

Example 1 with CreatePermissionRequestDTO

use of com.nexblocks.authguard.api.dto.requests.CreatePermissionRequestDTO in project AuthGuard by AuthGuard.

the class PermissionsRoute method create.

public void create(final Context context) {
    final CreatePermissionRequestDTO permission = createPermissionRequestBodyHandler.getValidated(context);
    final PermissionBO created = permissionsService.create(restMapper.toBO(permission));
    context.status(201).json(restMapper.toDTO(created));
}
Also used : CreatePermissionRequestDTO(com.nexblocks.authguard.api.dto.requests.CreatePermissionRequestDTO) PermissionBO(com.nexblocks.authguard.service.model.PermissionBO)

Example 2 with CreatePermissionRequestDTO

use of com.nexblocks.authguard.api.dto.requests.CreatePermissionRequestDTO in project AuthGuard by AuthGuard.

the class CreatePermissionRequestValidatorTest method validateValidRequest.

@Test
void validateValidRequest() {
    final CreatePermissionRequestDTO request = CreatePermissionRequestDTO.builder().group("group").name("test-Permission").domain("main").build();
    final Validator<CreatePermissionRequestDTO> validator = Validators.getForClass(CreatePermissionRequestDTO.class);
    final List<Violation> violations = validator.validate(request);
    assertThat(violations).isEmpty();
}
Also used : Violation(com.nexblocks.authguard.api.dto.validation.violations.Violation) CreatePermissionRequestDTO(com.nexblocks.authguard.api.dto.requests.CreatePermissionRequestDTO) Test(org.junit.jupiter.api.Test)

Example 3 with CreatePermissionRequestDTO

use of com.nexblocks.authguard.api.dto.requests.CreatePermissionRequestDTO in project AuthGuard by AuthGuard.

the class CreatePermissionRequestValidatorTest method validateNoFields.

@Test
void validateNoFields() {
    final CreatePermissionRequestDTO request = CreatePermissionRequestDTO.builder().build();
    final Validator<CreatePermissionRequestDTO> validator = Validators.getForClass(CreatePermissionRequestDTO.class);
    final List<Violation> violations = validator.validate(request);
    assertThat(violations).containsExactlyInAnyOrder(new Violation("name", ViolationType.MISSING_REQUIRED_VALUE), new Violation("group", ViolationType.MISSING_REQUIRED_VALUE), new Violation("domain", ViolationType.MISSING_REQUIRED_VALUE));
}
Also used : Violation(com.nexblocks.authguard.api.dto.validation.violations.Violation) CreatePermissionRequestDTO(com.nexblocks.authguard.api.dto.requests.CreatePermissionRequestDTO) Test(org.junit.jupiter.api.Test)

Aggregations

CreatePermissionRequestDTO (com.nexblocks.authguard.api.dto.requests.CreatePermissionRequestDTO)3 Violation (com.nexblocks.authguard.api.dto.validation.violations.Violation)2 Test (org.junit.jupiter.api.Test)2 PermissionBO (com.nexblocks.authguard.service.model.PermissionBO)1