|
34 | 34 | */ |
35 | 35 | class ValidatingEntityCallbackUnitTests { |
36 | 36 |
|
37 | | - private ValidatingEntityCallback callback; |
| 37 | + private ValidatingEntityCallback callback; |
38 | 38 |
|
39 | | - @BeforeEach |
40 | | - public void setUp() { |
41 | | - try (ValidatorFactory factory = Validation.buildDefaultValidatorFactory()) { |
42 | | - callback = new ValidatingEntityCallback(factory.getValidator()); |
43 | | - } |
44 | | - } |
| 39 | + @BeforeEach |
| 40 | + public void setUp() { |
| 41 | + try (ValidatorFactory factory = Validation.buildDefaultValidatorFactory()) { |
| 42 | + callback = new ValidatingEntityCallback(factory.getValidator()); |
| 43 | + } |
| 44 | + } |
45 | 45 |
|
46 | | - @Test // GH-4910 |
47 | | - void invalidModel_throwsException() { |
48 | | - Coordinates coordinates = new Coordinates(-1, -1); |
| 46 | + @Test |
| 47 | + // GH-4910 |
| 48 | + void invalidModel_throwsException() { |
| 49 | + Coordinates coordinates = new Coordinates(-1, -1); |
49 | 50 |
|
50 | | - assertThatExceptionOfType(ConstraintViolationException.class) |
51 | | - .isThrownBy(() -> callback.onBeforeSave(coordinates, coordinates.toDocument(), "coordinates")) |
52 | | - .satisfies(e -> assertThat(e.getConstraintViolations()).hasSize(2)); |
53 | | - } |
| 51 | + assertThatExceptionOfType(ConstraintViolationException.class).isThrownBy( |
| 52 | + () -> callback.onBeforeSave(coordinates, coordinates.toDocument(), "coordinates")) |
| 53 | + .satisfies(e -> assertThat(e.getConstraintViolations()).hasSize(2)); |
| 54 | + } |
54 | 55 |
|
55 | | - @Test // GH-4910 |
56 | | - void validModel_noExceptionThrown() { |
57 | | - Coordinates coordinates = new Coordinates(0, 0); |
58 | | - Object entity = callback.onBeforeSave(coordinates, coordinates.toDocument(), "coordinates"); |
59 | | - assertThat(entity).isEqualTo(coordinates); |
60 | | - } |
| 56 | + @Test |
| 57 | + // GH-4910 |
| 58 | + void validModel_noExceptionThrown() { |
| 59 | + Coordinates coordinates = new Coordinates(0, 0); |
| 60 | + Object entity = callback.onBeforeSave(coordinates, coordinates.toDocument(), "coordinates"); |
| 61 | + assertThat(entity).isEqualTo(coordinates); |
| 62 | + } |
61 | 63 |
|
62 | | - record Coordinates(@NotNull @Min(0) Integer x, @NotNull @Min(0) Integer y) { |
| 64 | + record Coordinates(@NotNull @Min(0) Integer x, @NotNull @Min(0) Integer y) { |
63 | 65 |
|
64 | | - Document toDocument() { |
65 | | - return Document.parse(""" |
66 | | - { |
67 | | - "x": %d, |
68 | | - "y": %d |
69 | | - } |
70 | | - """.formatted(x, y)); |
71 | | - } |
72 | | - } |
| 66 | + Document toDocument() { |
| 67 | + return Document.parse(""" |
| 68 | + { |
| 69 | + "x": %d, |
| 70 | + "y": %d |
| 71 | + } |
| 72 | + """.formatted(x, y)); |
| 73 | + } |
| 74 | + } |
73 | 75 | } |
0 commit comments