rymghosn commented on code in PR #6203:
URL: https://github.com/apache/fineract/pull/6203#discussion_r3736271649


##########
fineract-core/src/test/java/org/apache/fineract/infrastructure/core/exception/HttpMessageNotReadableErrorControllerTest.java:
##########
@@ -0,0 +1,98 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.infrastructure.core.exception;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.exc.InvalidFormatException;
+import jakarta.ws.rs.core.Response;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import org.apache.fineract.infrastructure.core.data.ApiParameterError;
+import org.junit.jupiter.api.Test;
+import org.springframework.http.converter.HttpMessageNotReadableException;
+
+/**
+ * Tests for {@link HttpMessageNotReadableErrorController}, in particular the 
FINERACT-2724 behaviour where a
+ * non-numeric value submitted for a numeric field is reported as a 
field-specific "not a valid number" validation error
+ * rather than the generic invalid-JSON error.
+ */
+public class HttpMessageNotReadableErrorControllerTest {
+
+    private final HttpMessageNotReadableErrorController controller = new 
HttpMessageNotReadableErrorController();
+
+    @Test
+    public void 
nonNumericValueForNumericFieldReturnsFieldSpecificValidationError() throws 
Exception {
+        final InvalidFormatException invalidFormatException = 
invalidFormatExceptionFor("not-a-number", BigDecimal.class);
+        
invalidFormatException.prependPath(HttpMessageNotReadableErrorControllerTest.class,
 "txnAmount");
+        final HttpMessageNotReadableException exception = new 
HttpMessageNotReadableException("JSON parse error", invalidFormatException);

Review Comment:
   No — `(String, Throwable)` is the one to use; the other overload just adds 
an unused `HttpInputMessage`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to