java - test case for spring rest controller for post mapping -
i have spring boot application controller logic shown below
@restcontroller public class compare { @postmapping(path = "/soon") public boolean compare (@requestbody string json, @requestheader(value="c_code") string old ) { hash hashobj=new hash(); string new=hashobj.(json); if(old.equals(new)) return true; else return false; } }
through postman posting string requestbody , string requestheader. string requestbody been sent function called sha() , returned value function compared string of requestheader. tried writing test case thing got errors.
@autowired private webapplicationcontext webapplicationcontext; private mockmvc mockmvc; @before public void setup() { mockmvc = mockmvcbuilders.webappcontextsetup(webapplicationcontext).build(); } @test public void testemployee() throws exception { // me write test case here }
Comments
Post a Comment