Итак, я хочу протестировать процесс():
Код: Выделить всё
public class ServiceImpl {
SomeSM someSM;
@Autowired
public void setSomeSM(SomeSM someSM) {
this.someSM = someSM;
}
@Override
public Map process(Map requestBody) throws Exception {
Map params01 = new HashMap();
Map params02 = new HashMap();
// Compile body to params in some lines here
Map rawResultProcess01 = someSM.callThirdPartyProcess01(params01);
Map rawResultProcess02 = someSM.callThirdPartyProcess02(params02);
Map finalResult = new HashMap();
// Compile rawResult to finalResult in some lines here
return finalResult;
}
}
Код: Выделить всё
@Service
public class SomeSMImpl implements SomeSM {
@Override
public Map callThirdPartyProcess01(Map payload) throws Exception {
Map rawResult = new HashMap();
HttpRequestHelper httpHelper = new HttpRequestHelper();
Map parsedJson = httpHelper.postHTTPS(payload.get("headers"), payload.get("body"), payload.get("params"), Map.class);
if(parsedJson.get("api_code") != null)
// ........ some processes here
return rawResult;
}
@Override
public Map callThirdPartyProcess02(Map payload) throws Exception {
Map rawResult = new HashMap();
HttpRequestHelper httpHelper = new HttpRequestHelper();
Map parsedJson = httpHelper.postHTTPS(payload.get("headers"), payload.get("body"), payload.get("params"), Map.class);
if(parsedJson.get("api_code") != null)
// ........ some processes here
return rawResult;
}
}
Как я могу имитировать значения parsedJson на двух методах SomeSM при тестировании из класса ServiceImpl?
Подробнее здесь: https://stackoverflow.com/questions/792 ... ion-return