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

OZG-4717 Refactored TestConstraintViolationException

parent 38068155
No related branches found
No related tags found
No related merge requests found
package de.ozgcloud.admin.common.errorhandling;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
......@@ -80,14 +79,14 @@ class ExceptionControllerITCase {
class TestConstraintViolationException {
@Test
@SneakyThrows
void shouldHaveInfoInBody() {
void shouldHaveValidationMessage() {
when(modelAssembler.toModel(any())).thenAnswer((a) -> {
throw new ConstraintViolationException(getConstraintViolations());
});
var result = performGet();
assertThat(result.andReturn().getResponse().getContentAsString()).contains("string: Empty field");
result.andExpect(jsonPath("$.detail").value("string: Empty field"));
}
private Set<ConstraintViolation<ValidatedClass>> getConstraintViolations() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment