I am trying to write a test case in groovy for a class that is written in java. The Java class(name:Helper) has a static method in it where a HttpClient object is obtained a
You can use
HttpClient.metaClass.executeMethod = {Type name -> doSomething}
You need to declare the closure signature with the correct Type
i.e. String, Map, etc.
void testSendMessage(){
def serviceUrl = properties.getProperty("ITEM").toString()
// mocking to return null
HttpClient.metaClass.executeMethod = {HttpMethod str -> null}
def responseXml = helper.message(serviceUrl)
}