spring - How to write mockito junit for Resttemplate exchange method -
how write mockito junit method below:
@autowired resttemplate resttemplate; responseentity<?> execute(final string url, httpmethod httpmethod, httpentity<?> entityrequest, string.class, map<string, string> urlvariables){ resttemplate.exchange(url, httpmethod, entityrequest, responsetype, urlvariables); }
please me how write.
@runwith(mockitojunitrunner.class) public class totesttest { @injectmocks private yourclass totest; @mock private resttemplate template; @test public void test() { totest.execute(mockito.anystring(), mockito.any(), mockito.any(), mockito.any(), mockito.any()); mockito.verify(template, mockito.times(1)) .exchange(mockito.anystring(), mockito.<httpmethod> any(), mockito.<httpentity<?>> any(), mockito.<class<?>> any(), mockito.<string, string> anymap()); } }
Comments
Post a Comment