1 package org.kuali.ole.deliver.service;
2
3 import org.junit.Test;
4
5 import java.util.ArrayList;
6 import java.util.List;
7 import java.util.Map;
8
9 import static org.junit.Assert.*;
10
11
12
13
14 public class LoanWithNoticesDAOTest {
15
16 @Test
17 public void getLoanIdsForOverudeNoticesForMySQL() throws Exception {
18 LoanWithNoticesDAO loanWithNoticesDAO = new MockLoanWithNoticesDAOForMySQL();
19 List<String> overdueNotice = loanWithNoticesDAO.getLoanIdsForOverudeNotices("3/3/2015", "OverdueNotice");
20 assertNotNull(overdueNotice);
21 assertTrue(overdueNotice.isEmpty());
22 }
23
24 @Test
25 public void getLoanIdsForOverudeNoticesForMySQLWithNullDate() throws Exception {
26 LoanWithNoticesDAO loanWithNoticesDAO = new MockLoanWithNoticesDAOForMySQL();
27 List<String> overdueNotice = loanWithNoticesDAO.getLoanIdsForOverudeNotices(null, "OverdueNotice");
28 assertNotNull(overdueNotice);
29 assertTrue(overdueNotice.isEmpty());
30 }
31
32 @Test
33 public void MockLoanWithNoticesDAOForOracle() throws Exception {
34 LoanWithNoticesDAO loanWithNoticesDAO = new MockLoanWithNoticesDAOForOracle();
35 List<String> overdueNotice = loanWithNoticesDAO.getLoanIdsForOverudeNotices("3/3/2015", "OverdueNotice");
36 assertNotNull(overdueNotice);
37 assertTrue(overdueNotice.isEmpty());
38 }
39
40 @Test
41 public void MockLoanWithNoticesDAOForOracleWithNullDate() throws Exception {
42 LoanWithNoticesDAO loanWithNoticesDAO = new MockLoanWithNoticesDAOForOracle();
43 List<String> overdueNotice = loanWithNoticesDAO.getLoanIdsForOverudeNotices(null, "OverdueNotice");
44 assertNotNull(overdueNotice);
45 assertTrue(overdueNotice.isEmpty());
46 }
47
48
49
50 class MockLoanWithNoticesDAOForMySQL extends LoanWithNoticesDAO {
51 @Override
52 protected String getProperty(String property) {
53 if (property.equals("db.vendor")){
54 return "mysql";
55 }
56 return null;
57 }
58
59 @Override
60 protected List<Map<String, Object>> executeQuery(String query) {
61 System.out.println(query);
62 return new ArrayList<>();
63 }
64 }
65
66 class MockLoanWithNoticesDAOForOracle extends LoanWithNoticesDAO {
67 @Override
68 protected String getProperty(String property) {
69 if (property.equals("db.vendor")){
70 return "oracle";
71 }
72 return null;
73 }
74
75 @Override
76 protected List<Map<String, Object>> executeQuery(String query) {
77 System.out.println(query);
78 return new ArrayList<>();
79 }
80 }
81 }