use of com.nexblocks.authguard.api.dto.requests.RolesRequestDTO in project AuthGuard by AuthGuard.
the class RolesRequestValidatorTest method validateValid.
@Test
void validateValid() {
final RolesRequestDTO request = RolesRequestDTO.builder().action(RolesRequest.Action.GRANT).addRoles("test").build();
final Validator<RolesRequestDTO> validator = Validators.getForClass(RolesRequestDTO.class);
final List<Violation> violations = validator.validate(request);
assertThat(violations).isEmpty();
}
use of com.nexblocks.authguard.api.dto.requests.RolesRequestDTO in project AuthGuard by AuthGuard.
the class RolesRequestDTOTest method parse.
@Test
void parse() {
final ArrayNode roles = new ArrayNode(JsonNodeFactory.instance).add("test");
final ObjectNode requestJson = new ObjectNode(JsonNodeFactory.instance).put("action", "GRANT").set("roles", roles);
final ObjectMapper objectMapper = new ObjectMapper();
final RolesRequestDTO expected = RolesRequestDTO.builder().action(RolesRequest.Action.GRANT).addRoles("test").build();
final RolesRequestDTO actual = objectMapper.convertValue(requestJson, RolesRequestDTO.class);
assertThat(actual).isEqualTo(expected);
}
use of com.nexblocks.authguard.api.dto.requests.RolesRequestDTO in project AuthGuard by AuthGuard.
the class RolesRequestValidatorTest method validateNoFields.
@Test
void validateNoFields() {
final RolesRequestDTO request = RolesRequestDTO.builder().build();
final Validator<RolesRequestDTO> validator = Validators.getForClass(RolesRequestDTO.class);
final List<Violation> violations = validator.validate(request);
assertThat(violations).containsExactly(new Violation("roles", ViolationType.EMPTY_LIST), new Violation("action", ViolationType.MISSING_REQUIRED_VALUE));
}
Aggregations