1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.ken.dao;
17
18 import java.util.HashMap;
19
20 import org.kuali.rice.ken.bo.NotificationPriorityBo;
21 import org.kuali.rice.ken.test.util.MockObjectsUtil;
22 import org.kuali.rice.ken.util.NotificationConstants;
23
24
25
26
27
28
29
30 public class NotificationPriorityDaoTest extends BusinessObjectPersistenceTestCaseBase {
31 NotificationPriorityBo mockPriority1 = MockObjectsUtil.getTestPriority1();
32 NotificationPriorityBo priority1 = MockObjectsUtil.getTestPriority1();
33
34 private String[] updatedDescriptions = {"Test 1 - updated description", "Test 2 - updated description"};
35
36
37
38
39 @Override
40 protected boolean delete() {
41 try {
42 businessObjectDao.delete(priority1);
43 } catch(Exception e) {
44 return false;
45 }
46 return true;
47 }
48
49
50
51
52 @Override
53 protected boolean retrieve() {
54 priority1 = new NotificationPriorityBo();
55
56 HashMap criteria = new HashMap();
57
58 criteria.put(NotificationConstants.BO_PROPERTY_NAMES.NAME, mockPriority1.getName());
59 priority1 = (NotificationPriorityBo) (businessObjectDao.findMatching(NotificationPriorityBo.class, criteria)).iterator().next();
60
61 boolean success = true;
62
63 success &= priority1 != null;
64 success &= priority1.getDescription().equals(mockPriority1.getDescription());
65
66 return success;
67 }
68
69
70
71
72 @Override
73 protected boolean insert() {
74 try {
75 businessObjectDao.save(priority1);
76 } catch(Exception e) {
77 return false;
78 }
79 return true;
80 }
81
82
83
84
85 @Override
86 protected boolean update() {
87 priority1.setDescription(updatedDescriptions[0]);
88
89 try {
90 businessObjectDao.save(priority1);
91 } catch(Exception e) {
92 return false;
93 }
94 return true;
95 }
96
97
98
99
100 @Override
101 protected boolean validateChanges() {
102 retrieve();
103
104 boolean success = true;
105
106 success &= priority1.getDescription().equals(updatedDescriptions[0]);
107
108 return success;
109 }
110 }