1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kcb.dao;
17
18 import org.junit.Ignore;
19 import org.junit.Test;
20 import org.kuali.rice.kcb.bo.RecipientPreference;
21 import org.kuali.rice.kcb.test.BusinessObjectTestCase;
22
23 import java.util.HashMap;
24
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertNotNull;
27
28
29
30
31
32
33 public class RecipientPreferenceDaoTest extends BusinessObjectTestCase {
34 RecipientPreference pref1 = new RecipientPreference();
35 RecipientPreference pref2 = new RecipientPreference();
36
37 private String[] recipientTypes = {"Type 1", "Type 2"};
38 private String[] recipientIds = {"unit_test_recip1", "unit_test_recip2"};
39 private String[] propertys = {"Property A", "Property B"};
40 private String[] values = {"Value A", "Value B"};
41 private String[] updatedValues = {"Value C", "Value D"};
42
43
44
45
46 @Test
47 @Override
48 public void testDelete() {
49 testCreate();
50 businessObjectDao.delete(pref1);
51 businessObjectDao.delete(pref2);
52 }
53
54
55
56
57 @Test
58 @Override
59 public void testReadByQuery() {
60 testCreate();
61
62 HashMap criteria = new HashMap();
63
64 criteria.put(RecipientPreference.RECIPIENT_FIELD, recipientIds[0]);
65 criteria.put(RecipientPreference.PROPERTY_FIELD, propertys[0]);
66 pref1 = (RecipientPreference) businessObjectDao.findByUniqueKey(RecipientPreference.class, criteria);
67
68 criteria.clear();
69
70 criteria.put(RecipientPreference.RECIPIENT_FIELD, recipientIds[1]);
71 criteria.put(RecipientPreference.PROPERTY_FIELD, propertys[1]);
72 pref2 = (RecipientPreference) businessObjectDao.findByUniqueKey(RecipientPreference.class, criteria);
73
74 assertNotNull(pref1);
75 assertEquals(recipientIds[0], pref1.getRecipientId());
76
77 assertNotNull(pref2);
78 assertEquals(recipientIds[1], pref2.getRecipientId());
79
80 }
81
82
83
84
85 @Test
86 @Override
87 public void testCreate() {
88 pref1.setRecipientId(recipientIds[0]);
89 pref1.setProperty(propertys[0]);
90 pref1.setValue(values[0]);
91
92 pref2.setRecipientId(recipientIds[1]);
93 pref2.setProperty(propertys[1]);
94 pref2.setValue(values[1]);
95
96 businessObjectDao.save(pref1);
97 businessObjectDao.save(pref2);
98 }
99
100
101
102
103 @Test
104 @Ignore
105 @Override
106 public void testUpdate() {
107 testCreate();
108 pref1.setValue(updatedValues[0]);
109
110 pref2.setValue(updatedValues[1]);
111
112 businessObjectDao.save(pref1);
113 businessObjectDao.save(pref2);
114
115 testReadByQuery();
116
117 assertEquals(updatedValues[0], pref1.getValue());
118 assertEquals(updatedValues[1], pref2.getValue());
119 }
120 }