ChlineSaurus commented on code in PR #2746:
URL: https://github.com/apache/jackrabbit-oak/pull/2746#discussion_r2852399001


##########
oak-core/src/test/java/org/apache/jackrabbit/oak/query/UnionQueryTest.java:
##########
@@ -512,12 +552,19 @@ public MockQueryBuilder(boolean hasScore) {
         }
 
         public MockQueryBuilder addResult(String path, double score) {
+            if (!hasScore) {
+                throw new IllegalStateException("Cannot provide score");
+            }
+            return addResult(path, Double.valueOf(score));
+        }
+
+        public MockQueryBuilder addResult(String path, Double score) {
             if (!hasScore) {
                 throw new IllegalStateException("Cannot provide score");
             }
             PropertyValue[] values = new PropertyValue[] {
                     PropertyValues.newString(path),
-                    PropertyValues.newDouble(score)
+                    score == null ? null : PropertyValues.newDouble(score)

Review Comment:
   This is only for mocking behavior in tests. The goal is that it returns 
null, so the change would defeat the purpose in my opinion. The mock should be 
able to return null to test if the actual code can handle a null return.
   
   What this (somewhat weird) line does is to ensure, that we only try to turn 
the value to be returned by the mock into a Double if it isn't null, with the 
goal that the same mocking code can be used for tests with null and actual 
scores.



-- 
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