jlprat commented on a change in pull request #11241:
URL: https://github.com/apache/kafka/pull/11241#discussion_r694629688



##########
File path: 
streams/src/test/java/org/apache/kafka/streams/kstream/internals/KStreamMapTest.java
##########
@@ -68,6 +70,12 @@ public void testMap() {
         }
     }
 
+    @Test
+    public void testKeyValueMapperResultNotNull() {
+        final KStreamMap<String, Integer, String, Integer> supplier = new 
KStreamMap<>((key, value) -> null);
+        assertThrows(NullPointerException.class, () -> 
supplier.get().process(new Record<>("K", 0, 0L)));

Review comment:
       Same as previous comment

##########
File path: 
streams/src/test/java/org/apache/kafka/streams/kstream/internals/KStreamFlatMapTest.java
##########
@@ -86,4 +88,10 @@ public void testFlatMap() {
             assertEquals(expected[i], 
supplier.theCapturedProcessor().processed().get(i));
         }
     }
+
+    @Test
+    public void testKeyValueMapperResultNotNull() {
+        final KStreamFlatMap<String, Integer, String, Integer> supplier = new 
KStreamFlatMap<>((key, value) -> null);
+        assertThrows(NullPointerException.class, () -> 
supplier.get().process(new Record<>("K", 0, 0L)));

Review comment:
       As the whole point of this PR is to provide better messages, I would 
also check in the test that the exception has the new enhanced message. 
Something like 
   ```suggestion
           final Record<String, Integer> record = new Record<>("K", 0, 0L);
           assertThrows(NullPointerException.class, () -> 
supplier.get().process(record), String.format("KeyValueMapper can't return null 
from mapping the record: %s", record));
   ```




-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to