我是单元测试的新手,我正在寻找一种使用流测试方法的方法,但到目前为止我在互联网上找不到示例。
我在一个服务类中有两个带有流的方法:
public List<Appointment> getAppointmentsForToday() {
return getAppointmentsForSpecificDoctor().stream()
.filter(appointment -> appointment.getDate().equals(LocalDate.now()))
.collect(Collectors.toList());
}
public ObservableList<String> getScheduledTime(User pickedDoctor, LocalDate pickedDate) {
List<Appointment> appointmentsOfDoctor = getAllAppointments()
.stream()
.filter(appointment -> appointment.getDoctor().getFirstName().equals(pickedDoctor.getFirstName()))
.collect(Collectors.toList());
List<Appointment> appointmentsInSpecificDay = appointmentsOfDoctor
.stream()
.filter(appointment -> appointment.getDate().equals(pickedDate))
.collect(Collectors.toList());
Iterator<Appointment> it = appointmentsInSpecificDay.iterator();
ObservableList<String> scheduledHours = FXCollections.observableArrayList();
while(it.hasNext()) {
scheduledHours.add(it.next().getTime());
}
return scheduledHours;
}
我应该如何处理这些问题?