Expected Behavior
def resultJSON = ''
try {
resultJSON = readJSON text: scriptResult?.trim()
} catch (ex) {
echo 'The response is may not be in JSON format/No error received. \n Exception received trying to parse result as JSON : ' + ex
}
I am trying to mock the readJSON and get resultJSON populated with some value.
String resTxt = "testString"
String resTxt = "{'test':'value'}"
getPipelineMock("readJSON").call(["[text:'test value']"]) >> { return resTxt}
or
getPipelineMock("readJSON").call(["{'test':'value'}"]) >> { return resTxt}
or any other value even line below....
getPipelineMock("readJSON").call([[text:null]]) >> { return resTxt}
should be returning a value provided with return statement or should throw an exception.
Actual Behavior
Below block is seen anyways.
And nothing is returned.
17:01:32.221 [main] DEBUG com.homeaway.devtools.jenkins.testing.JenkinsPipelineSpecification - TEST FIXTURE intercepted & redirected a call:
Test : class com.homeaway.devtools.jenkins.testing.JenkinsPipelineSpecification
Note : pipeline step
Via : queryWebUrl@6917bb4.methodMissing
(types) : queryWebUrl.methodMissing
Invocation : queryWebUrl@6917bb4.readJSON([[text:null]])
(types) : queryWebUrl.readJSON(Object[])
Forwarded To : Mock for type 'Closure' named 'getPipelineMock("readJSON")'.call([text:null])
(types) : Closure$$EnhancerByCGLIB$$94f4fb1c.call(LinkedHashMap)
Expected Behavior
def resultJSON = ''
try {
resultJSON = readJSON text: scriptResult?.trim()
} catch (ex) {
echo 'The response is may not be in JSON format/No error received. \n Exception received trying to parse result as JSON : ' + ex
}
I am trying to mock the readJSON and get resultJSON populated with some value.
String resTxt = "testString"
String resTxt = "{'test':'value'}"
getPipelineMock("readJSON").call(["[text:'test value']"]) >> { return resTxt}
or
getPipelineMock("readJSON").call(["{'test':'value'}"]) >> { return resTxt}
or any other value even line below....
getPipelineMock("readJSON").call([[text:null]]) >> { return resTxt}
should be returning a value provided with return statement or should throw an exception.
Actual Behavior
Below block is seen anyways.
And nothing is returned.
17:01:32.221 [main] DEBUG com.homeaway.devtools.jenkins.testing.JenkinsPipelineSpecification - TEST FIXTURE intercepted & redirected a call:
Test : class com.homeaway.devtools.jenkins.testing.JenkinsPipelineSpecification
Note : pipeline step
Via : queryWebUrl@6917bb4.methodMissing
(types) : queryWebUrl.methodMissing
Invocation : queryWebUrl@6917bb4.readJSON([[text:null]])
(types) : queryWebUrl.readJSON(Object[])
Forwarded To : Mock for type 'Closure' named 'getPipelineMock("readJSON")'.call([text:null])
(types) : Closure$$EnhancerByCGLIB$$94f4fb1c.call(LinkedHashMap)