I am using RestTemplate in a Spring project.Due to some reason i have created a RestTemplate Object inside a method. Example :
public class Post {
public Post(){
}
public T postRequest(Object request){
// Creating a Header Part
// Creating a Restemplate instance
RestTemplate rest = new RestTemplate();
ResponseEntity<T> response = rest.exchange(......)
}
}
My Question : How can we write Junit Test case for postRequest method even with mock. Because i can not autowired RestTemplate in PostTest class. Any Idea can help. Thanks in Advance.