I want to execute a request based on condition. I’m trying the Functional Interface approach in Java ,
How do I get this running ?
Compile Error:
Bad return type in lambda expression: ChainBuilder cannot be converted to Session
Also in the below code I want to skip the request if, filteredCount==0. How do I do that ?
static Function<Session, ChainBuilder> conditionalFunc =
session -> session.getInt("filteredCount")>0
? approveJobReqs() : null;
//>>> How can I skip the request , or use Optional.empty() instead of null ?
public static ChainBuilder checkForApprovals =
exec(session -> conditionalFunc.apply(session));
private static ChainBuilder approveJobReqs() {
return exec(
http("#{transactionName_2}")
.post("/xi/someajax/")
.exec(session -> {
.........
log.info("Executing"));
return session;
} );
}