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