Favourite Quote

Every artist was first an amateur. - Ralph Waldo Emerson The more difficulties one has to encounter, within and without, the more significant and the higher in inspiration his life will be. - Horace Bushnell

Friday, May 29, 2015

Building a Nested JSON using HTTPBuilder in Groovy

Here is an example of how to pass a JSON that is nested with a HTTPBuilder
 
private def getWorkingLatitude(String additionalInfo)
{
              def json = new JsonBuilder()
  json {
   "jobId" additionalInfo
    "phoneList"{
                         "mobilePhone" "0123469521"
                         "homePhone" "01235698470"
                         }
   
  }
  return json;
 }

 
Here is how you wrap it with HTTPBuilder
HTTP_BUILDER.request(Method.PUT, ContentType.JSON){
   headers.'Authorization' = "Bearer "+ ACCESS_TOKEN_TM
   uri.path =  JOB_URI_PREFIX +USER_ID_TM+"/reject"
   println "uri job is : "+uri.path
   body = json.toString()
}

How to disable and enable behaviour driven tests in Spock

I wanted to disable Spock Tests Adding @Ignore Annotation above the Test will not execute the test you may also add at Class Level Tests