integration testing - how to write RestTemplate.put() in groovy using Spock -


i writing integration test cases using spock in groovy. using resttemplate call operation example

when: string url="http://localhost:$port/user/password" responseentity<responsewrapper<user>> entity=resttemplate.postforentity(url,changepassworddto,responsewrapper.class)  then:     entity.statuscode == httpstatus.ok     entity!=null 

i have written integration test post , get, when writing put, getting null pointer exception on entity object

i have written put, know put operation null, not getting other way this, can please me

string url="http://localhost:$port/applicant/{id}/status?blacklistingflag&reason"     map.put("id", "23")     map.put("blacklistingflag","0")     map.put("reason","no reason")     resttemplate.exchange(url, httpmethod.put, null, null, map)     responseentity<responsewrapper<user>> entity=resttemplate.put(url,responsewrapper.class , map)      then:     entity.statuscode == httpstatus.ok     entity!=null 

i see old post couldn't leave without answer. resttemplate.put void method won't able callback it.

you should use resttemplate.exchange responseentity object in return.

check this post.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

dns - Dokku server hosts two sites with TLD's, both domains are landing on only one app -

Delphi 7 and decode UTF-8 base64 -