From 67eb9d62ac166bfd09b6a21846b9a26912b9b88e Mon Sep 17 00:00:00 2001
From: OZGCloud <ozgcloud@mgm-tp.com>
Date: Fri, 9 Aug 2024 16:37:42 +0200
Subject: [PATCH] OZG-6381 Fix ExceptionControllerITCase

---
 .../ExceptionControllerITCase.java             | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/test/java/de/ozgcloud/admin/common/errorhandling/ExceptionControllerITCase.java b/src/test/java/de/ozgcloud/admin/common/errorhandling/ExceptionControllerITCase.java
index e965505f..5c246fff 100644
--- a/src/test/java/de/ozgcloud/admin/common/errorhandling/ExceptionControllerITCase.java
+++ b/src/test/java/de/ozgcloud/admin/common/errorhandling/ExceptionControllerITCase.java
@@ -54,7 +54,7 @@ class ExceptionControllerITCase {
 
 			var result = performGet();
 
-			result.andExpect(jsonPath("$.invalid-params[*].name").value("string2"));
+			result.andExpect(jsonPath("$.invalidParams[*].name").value("string2"));
 		}
 
 		@Test
@@ -66,7 +66,7 @@ class ExceptionControllerITCase {
 
 			var result = performGet();
 
-			result.andExpect(jsonPath("$.invalid-params[*].length()").value(Arrays.asList(new Integer[] { 2, 2 })));
+			result.andExpect(jsonPath("$.invalidParams[*].length()").value(Arrays.asList(new Integer[] { 4, 4 })));
 		}
 
 		@Test
@@ -78,7 +78,19 @@ class ExceptionControllerITCase {
 
 			var result = performGet();
 
-			result.andExpect(jsonPath("$.invalid-params[0].reason").value("Empty field"));
+			result.andExpect(jsonPath("$.invalidParams[0].reason").value("Empty field"));
+		}
+
+		@Test
+		@SneakyThrows
+		void shouldHaveValueInResponse() {
+			when(modelAssembler.toModel(any())).thenAnswer((a) -> {
+				throw new ConstraintViolationException(getConstraintViolations(StringUtils.EMPTY));
+			});
+
+			var result = performGet();
+
+			result.andExpect(jsonPath("$.invalidParams[0].value").value(""));
 		}
 
 		private Set<ConstraintViolation<ValidatedClass>> getConstraintViolations(String string) {
-- 
GitLab