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

OZG-4717 Refactored TestConstraintViolationException

parent 38068155
Branches
Tags
No related merge requests found
package de.ozgcloud.admin.common.errorhandling; package de.ozgcloud.admin.common.errorhandling;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.ArgumentMatchers.*; import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
...@@ -80,14 +79,14 @@ class ExceptionControllerITCase { ...@@ -80,14 +79,14 @@ class ExceptionControllerITCase {
class TestConstraintViolationException { class TestConstraintViolationException {
@Test @Test
@SneakyThrows @SneakyThrows
void shouldHaveInfoInBody() { void shouldHaveValidationMessage() {
when(modelAssembler.toModel(any())).thenAnswer((a) -> { when(modelAssembler.toModel(any())).thenAnswer((a) -> {
throw new ConstraintViolationException(getConstraintViolations()); throw new ConstraintViolationException(getConstraintViolations());
}); });
var result = performGet(); 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() { 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