Skip to content
Snippets Groups Projects
Commit 38068155 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-4717 PR#23 Comments

parent d84fc6ae
Branches
Tags
No related merge requests found
...@@ -38,7 +38,7 @@ import lombok.SneakyThrows; ...@@ -38,7 +38,7 @@ import lombok.SneakyThrows;
@ITCase @ITCase
@AutoConfigureMockMvc @AutoConfigureMockMvc
@WithMockUser @WithMockUser
public class ExceptionControllerITCase { class ExceptionControllerITCase {
@Autowired @Autowired
private MockMvc mockMvc; private MockMvc mockMvc;
...@@ -82,8 +82,7 @@ public class ExceptionControllerITCase { ...@@ -82,8 +82,7 @@ public class ExceptionControllerITCase {
@SneakyThrows @SneakyThrows
void shouldHaveInfoInBody() { void shouldHaveInfoInBody() {
when(modelAssembler.toModel(any())).thenAnswer((a) -> { when(modelAssembler.toModel(any())).thenAnswer((a) -> {
var validationObject = ValidatedClass.builder().build(); throw new ConstraintViolationException(getConstraintViolations());
throw new ConstraintViolationException(getConstraintViolations(validationObject));
}); });
var result = performGet(); var result = performGet();
...@@ -91,9 +90,9 @@ public class ExceptionControllerITCase { ...@@ -91,9 +90,9 @@ public class ExceptionControllerITCase {
assertThat(result.andReturn().getResponse().getContentAsString()).contains("string: Empty field"); assertThat(result.andReturn().getResponse().getContentAsString()).contains("string: Empty field");
} }
private <T> Set<ConstraintViolation<T>> getConstraintViolations(T object) { private Set<ConstraintViolation<ValidatedClass>> getConstraintViolations() {
Validator validator = Validation.buildDefaultValidatorFactory().getValidator(); Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
return validator.validate(object); return validator.validate(ValidatedClass.builder().build());
} }
@Getter @Getter
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment