我是 Mockito 的新手。我正在使用 Mockito 为一个类编写测试。我有一个调用同一类的其他方法的方法。我将如何嘲笑这种方法?我已经发布了我试图为其编写测试的课程。我正在尝试模拟方法 process(PersonDTO person)
public class Processor {
@Autowired
private SomeService service;
@Autowired
private SomeServiceProperties properties;
private Util util = new Util();
public SPMOutboundVO process(PersonDTO person) throws Exception {
SPMOutboundVO outboundVO = null;
if(validatePersonForBenefitsProcessing(person)) {
PersonPayrollFromWorkdayVO personPayrollFromWorkdayVO = service.getPersonPayrollFromWorkday(util.getStartOrEndDate(DayOfWeek.SUNDAY),util.getStartOrEndDate(DayOfWeek.SATURDAY),person.getEmployeeID());
if(personPayrollFromWorkdayVO != null) {
person.setBillingStartDate(getPayrollPeriod(personPayrollFromWorkdayVO));
person.setAmount(util.getMonthlyDiscountPayRate(person.getPayPeriod(),getDiscountRate(personPayrollFromWorkdayVO)));
}
if(isNewLeave(person,getPayrollPeriod(personPayrollFromWorkdayVO))) {
person.setBillingStartDate(getPayrollPeriod(personPayrollFromWorkdayVO));
outboundVO = processOutboundSPMInsertRecords(person);
} else if (person.isReturnFromLeaveOrTermed()){
person.setBillingEndDate(person.getFirstDayBackAtWorkMinus1());
outboundVO = processOutboundSPMUpdateRecords(person);
}
}
return outboundVO;
}
public boolean validatePersonForBenefitsProcessing(PersonDTO person) {
// Some code
}
public SPMOutboundVO processOutboundSPMInsertRecords(PersonDTO person) {
// Some code
}
public SPMOutboundVO processOutboundSPMUpdateRecords(PersonDTO person) {
// Some code
}
public String getPayrollPeriod(PersonPayrollFromWorkdayVO personPayrollFromWorkdayVO) {
// Some code
}
public boolean isNewLeave(PersonDTO, String) {
// Some code
}
}
FFIVE
相关分类