完全な JUnit テスト・クラスについては、pureQuery のネストされた Bean サンプルのための JUnit テスト・クラスを参照してください。
public void test_joinTest1() throws Exception {
System.out.println("==Test1 nested beans with interface==");
SimpleQueryInterface data = null;
data = DataFactory.getData(SimpleQueryInterface.class, jdbcCon);
System.out.println("==Get Dept data ==");
List<Dept1> depts = data.joinTest();
System.out.println("Employees by Dept:");
for (Dept1 d : depts) {
System.out.println(d.getDeptCode() + " - " + d.getDeptNameEn());
List<Emp> employees = d.getDeptEmployees();
if (!employees.isEmpty()) {
for (Emp e : employees) {
System.out.println(" " + e.getLastName() + ", "
+ e.getFirstName() + ", " + e.toString());
}
} else {
System.out.println(" -- No Employees-- ");
}
}
}
7810 - Production and Distribution
Agostini, Massimo, ID: 10481
Boscolo, Gabriella, ID: 10480
Ferrari, Arabela, ID: 10304
Gallo, Feliti, ID: 10632
Lombardi, Isabella, ID: 10482
Marino, Gualtier, ID: 10793
Medina, Benicio, ID: 10483
Morales, Ada, ID: 10306
public void test_joinTest2() throws Exception {
System.out.println("==Test2 nested bean with Inline SQL==");
Data data = null;
String myDeptNo = "6820";
data = DataFactory.getData(jdbcCon);
List<Dept2> depts = data
queryList(
"SELECT E.EMPLOYEE_CODE, E.FIRST_NAME, E.LAST_NAME, E.DATE_HIRED, "
+ " ORG.ORGANIZATION_CODE, ORG.ORGANIZATION_NAME_EN"
+ " FROM EMPLOYEE AS E, EMPLOYEE_HISTORY AS EH, ORGANIZATION AS ORG"
+ " WHERE EH.EMPLOYEE_CODE = E.EMPLOYEE_CODE "
+ " AND EH.ORGANIZATION_CODE = ORG.ORGANIZATION_CODE"
+ " AND EH.RECORD_END_DATE IS NULL "
+ " ORDER BY EH.ORGANIZATION_CODE, E.LAST_NAME ",
Dept2.class);
System.out.println("Employees by Dept:");
for (Dept2 d : depts) {
System.out.println(d.deptCode + " - " + d.deptNameEn);
List<Emp> employees = d.deptEmployees;
if (!employees.isEmpty()) {
for (Emp e : employees) {
System.out.println(" " + e.getLastName() + ", "
+ e.getFirstName() + ", " + e.toString());
}
} else {
System.out.println(" -- No Employees-- ");
}
}
}
7810 - Production and Distribution
Agostini, Massimo, ID: 10481
Boscolo, Gabriella, ID: 10480
Ferrari, Arabela, ID: 10304
Gallo, Feliti, ID: 10632
Lombardi, Isabella, ID: 10482
Marino, Gualtier, ID: 10793
Medina, Benicio, ID: 10483
Morales, Ada, ID: 10306