Привет, мой класс выглядит так.
public class Class1 {
public void method1(Object obj) {
// Class 2 makes the restApiCall and result as "SUCCESS" if the HTTP response is 202
Class2 class2 = new Class2();
String result = class2.callRestService();
System.out.println(result);
}
}
public class Class2 {
public String callRestService() {
String url = fetchUrl(System.getProperty(COnstants.URL);
String result = callRestServiceAPi(url); // Calling the RestApimethod.
return result;
}
}
Я хочу написать модульный тест для class1, и я хочу сделать это, фактически не вызывая RestAPi, что означает, что я хочу имитировать class2.callRestService () для возврата как «успех» или «сбой». Как это сделать.