@@ -171,6 +171,52 @@ class UserErrorMapperTest {
171171 )
172172 }
173173
174+ @Test
175+ fun test_validationErrorMapping_withNullData_returnsAllErrors () {
176+ val result = errorMapper(buildHttpException(" validation-failed" , null ))
177+ assertEquals(UserError .ValidationFailed (UserValidationError .VALUES_SET ), result)
178+ }
179+
180+ @Test
181+ fun test_validationErrorMapping_withListOfErrors () {
182+ val data = listOf (" invalid-email-address" , " too-short-first-name" )
183+ val result = errorMapper(buildHttpException(" validation-failed" , data))
184+ assertEquals(
185+ UserError .ValidationFailed (
186+ nonEmptySetOf(
187+ UserValidationError .INVALID_EMAIL_ADDRESS ,
188+ UserValidationError .TOO_SHORT_FIRST_NAME ,
189+ ),
190+ ),
191+ result,
192+ )
193+ }
194+
195+ @Test
196+ fun test_validationErrorMapping_withMapContainingErrors () {
197+ val data = mapOf (" errors" to listOf (" TOO_SHORT_LAST_NAME" ))
198+ val result = errorMapper(buildHttpException(" validation-failed" , data))
199+ assertEquals(
200+ UserError .ValidationFailed (nonEmptySetOf(UserValidationError .TOO_SHORT_LAST_NAME )),
201+ result,
202+ )
203+ }
204+
205+ @Test
206+ fun test_validationErrorMapping_withInvalidData_returnsAllErrors () {
207+ val data = listOf (" unknown-error" , " another-unknown" )
208+ val result = errorMapper(buildHttpException(" validation-failed" , data))
209+ // Falls back to all errors when none can be parsed
210+ assertEquals(UserError .ValidationFailed (UserValidationError .VALUES_SET ), result)
211+ }
212+
213+ @Test
214+ fun test_validationErrorMapping_withMixedCaseErrors () {
215+ val data = listOf (" INVALID_EMAIL_ADDRESS" , " too-short-first-name" , " TOO-SHORT-LAST-NAME" )
216+ val result = errorMapper(buildHttpException(" validation-failed" , data))
217+ assertEquals(UserError .ValidationFailed (UserValidationError .VALUES_SET ), result)
218+ }
219+
174220 @Test
175221 fun test_withOtherwiseExceptions_returnsUnexpectedError () {
176222 assertEquals(
0 commit comments