I am looking for example to JUnit test KStream related scenarios with spring-cloud-stream kafka streams binder. Any example available with KStream, KTable? For example i want to test following function
@Bean
public Function<KStream<String, String>, KTable<String, String>> func() {
return stringKStream -> {
stringKStream .print(Printed.<String, String>toSysOut().withLabel("String-Stream-
Print"));
return stringKStream.toTable();
};
}
I tried above example by referring https://docs.spring.io/spring-cloud-stream/reference/spring-cloud-stream/spring_integration_test_binder.html#test-binder-configuration but am getting following error
java.lang.NullPointerException: Cannot invoke
"org.springframework.messaging.SubscribableChannel.send(org.springframework.messaging.Message)"
because the return value of "org.springframework.cloud.stream.binder.test.InputDestination.getChannelByName(String)" is null
at org.springframework.cloud.stream.binder.test.InputDestination.send(InputDestination.java:89)
at net.apmoller.crb.apmt.microservices.tiaim.state.handler.integration.AnotherConfigTest.lambda$test2107$0(AnotherConfigTest.java:87)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at net.apmoller.crb.apmt.microservices.tiaim.state.handler.integration.AnotherConfigTest.test2107(AnotherConfigTest.java:86)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)