Created
May 22, 2019 07:34
-
-
Save d3ep4k/fd23ebcdcaaca485dcce99442e8822b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GroovyScriptEngine engine = new GroovyScriptEngine("."); | |
Map<String, String> request = new HashMap(); | |
request.put("param1", "Hello"); | |
Map<String, String> response = new HashMap(); | |
response.put("param1", "World"); | |
Binding binding = new Binding(); | |
binding.setVariable("request", request); | |
binding.setVariable("response", response); | |
engine.run("src/main/java/"+className, binding); | |
import com.jayway.jsonpath.JsonPath; | |
import com.jayway.jsonpath.Configuration; | |
String json = "{\"user\":\"deepak\"}"; | |
Object document = Configuration.defaultConfiguration().jsonProvider().parse(json); | |
println JsonPath.read(document, "\$.user"); | |
def makethiswork(request, response){ | |
return request.param1 + ' ' + response.param1; | |
} | |
response.param1 = makethiswork(request, response) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment