Unable to use Java Streams in Custom Keyword


I am trying to use Java Streams and lambda expressions while writing custom keywords.

It is throwing error and i am not able to see suggestions as well. Someone please help me how to use java 8 features

Hi @sudheer.dj,
Please use Groovy closure in place of lambda.

I am new to this. Could you please correct the code.
public static void main(String[] args) {
ArrayList names = new ArrayList();


@huynguyen please help

Try to follow this:

Thanks, @Russ_Thomas. Could you please correct my code and send it.

I am a little confused with Groovy script.

A sample Groovy class implementation with the Java Stream:

package my

import java.util.stream.Collectors

public class Dummy {
	public void forTest() {
		List<String> names = ["Sam", "ple", "Ap", "ple"]
		println names
		List<String> filtered = 
				.filter({ String name -> 
		println filtered

A Test Case script using the class:

import my.Dummy

Dummy instance = new Dummy()

The output from the Test Case:

2020-09-24 09:52:40.718 INFO  c.k.katalon.core.main.TestCaseExecutor   - --------------------
2020-09-24 09:52:40.722 INFO  c.k.katalon.core.main.TestCaseExecutor   - START Test Cases/TC3
2020-09-24 09:52:41.393 DEBUG testcase.TC3                             - 1: instance = new my.Dummy()
2020-09-24 09:52:41.410 DEBUG testcase.TC3                             - 2: instance.forTest()
[Sam, ple, Ap, ple]
2020-09-24 09:52:41.570 INFO  c.k.katalon.core.main.TestCaseExecutor   - END Test Cases/TC3

Thank you so much @kazurayam . Your response helped a lot