//working out what patients have not been seen in 1 year.
import java.util.ArrayList;
import java.util.Calendar;
public class PatientTest {
public static void main(String[] args){
Calendar cal1 =Calendar.getInstance();
PatientExtended Patient1 = new PatientExtended("Ian", "04/12/1970", "M", cal1);
Calendar cal2 =Calendar.getInstance();
cal2.set(2012, 11, 8);
PatientExtended Patient2 = new PatientExtended("Bob", "13/08/1989", "M", cal2);
ArrayList<PatientExtended>mylist = new ArrayList <PatientExtended>();
mylist.add(Patient1);
mylist.add(Patient2);
System.out.println(PatientExtended(mylist));
}
public static ArrayList<PatientExtended> PatientExtended(ArrayList<PatientExtended> PatientArrayList){
Calendar lastYear = Calendar.getInstance();
int year = lastYear.get(Calendar.YEAR);
year = year -1;
lastYear.set(Calendar.YEAR, year);
ArrayList<PatientExtended>notSeenAllYear = new ArrayList <PatientExtended>();
for(int i =1; i<=1; i++){
System.out.println(i);
int check = PatientArrayList.get(i).getlastSeen().compareTo(lastYear);
if (check <= 1){
notSeenAllYear.add(PatientArrayList.get(i));
}
}
return notSeenAllYear;
//return new array
}
}
答案 0 :(得分:0)
我将从更多关于如何使用junit api视角来回答这个问题,而不是试图计算出你的测试用例,因为我相信你的问题是什么。对于某些基本覆盖,您可以执行以下操作:请注意Kent Beck测试命名约定。我还应该补充我已经将PatientExtended上的病例更正为PatientExtended并使其采用List接口而不是ArrayList实现。
@Test
public void has_single_patient_been_seen_within_a_year() {
List<PatientExtended> list = new ArrayList<>();
list.add(new PatientExtended(<your constructor args here>));
assertEquals(list, patientExtended(list));
};