use of com.nexblocks.authguard.api.dto.requests.CreateRoleRequestDTO in project AuthGuard by AuthGuard.
the class CreateRoleRequestValidatorTest method validateNoNameOrDomain.
@Test
void validateNoNameOrDomain() {
final CreateRoleRequestDTO request = CreateRoleRequestDTO.builder().domain("main").build();
final Validator<CreateRoleRequestDTO> validator = Validators.getForClass(CreateRoleRequestDTO.class);
final List<Violation> violations = validator.validate(request);
assertThat(violations).containsExactly(new Violation("name", ViolationType.MISSING_REQUIRED_VALUE));
}
use of com.nexblocks.authguard.api.dto.requests.CreateRoleRequestDTO in project AuthGuard by AuthGuard.
the class RolesRoute method create.
public void create(final Context context) {
final CreateRoleRequestDTO role = createRoleRequestBodyHandler.getValidated(context);
final RoleDTO created = Optional.of(role).map(restMapper::toBO).map(rolesService::create).map(restMapper::toDTO).orElseThrow();
context.status(201).json(created);
}
use of com.nexblocks.authguard.api.dto.requests.CreateRoleRequestDTO in project AuthGuard by AuthGuard.
the class CreateRoleRequestValidatorTest method validateValidRequest.
@Test
void validateValidRequest() {
final CreateRoleRequestDTO request = CreateRoleRequestDTO.builder().name("test-role").domain("main").build();
final Validator<CreateRoleRequestDTO> validator = Validators.getForClass(CreateRoleRequestDTO.class);
final List<Violation> violations = validator.validate(request);
assertThat(violations).isEmpty();
}
Aggregations