| 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 org.kuali.rice.ken.bo.NotificationChannel; |
| 19 |
|
import org.kuali.rice.ken.bo.NotificationProducer; |
| 20 |
|
import org.kuali.rice.ken.test.util.MockObjectsUtil; |
| 21 |
|
import org.kuali.rice.ken.util.NotificationConstants; |
| 22 |
|
|
| 23 |
|
import java.util.HashMap; |
| 24 |
|
|
| 25 |
|
import static org.junit.Assert.assertEquals; |
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
@author |
| 32 |
|
|
|
|
|
| 0% |
Uncovered Elements: 56 (56) |
Complexity: 9 |
Complexity Density: 0.18 |
|
| 33 |
|
public class NotificationProducerDaoTest extends BusinessObjectPersistenceTestCaseBase { |
| 34 |
|
NotificationChannel mockChannel1 = MockObjectsUtil.getTestChannel1(); |
| 35 |
|
NotificationChannel mockChannel2 = MockObjectsUtil.getTestChannel2(); |
| 36 |
|
|
| 37 |
|
NotificationProducer mockProducer1 = MockObjectsUtil.getTestProducer1(); |
| 38 |
|
|
| 39 |
|
private String[] updatedDescriptions = {"Test 1 - updated description", "Test 2 - updated description"}; |
| 40 |
|
|
| 41 |
|
|
| 42 |
|
@see |
| 43 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 44 |
0
|
@Override... |
| 45 |
|
protected void setup() { |
| 46 |
0
|
super.setup(); |
| 47 |
0
|
businessObjectDao.save(mockChannel1); |
| 48 |
0
|
businessObjectDao.save(mockChannel2); |
| 49 |
|
} |
| 50 |
|
|
| 51 |
|
|
| 52 |
|
@see |
| 53 |
|
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 2 |
Complexity Density: 0.15 |
|
| 54 |
0
|
@Override... |
| 55 |
|
protected boolean delete() { |
| 56 |
0
|
HashMap criteria = new HashMap(); |
| 57 |
|
|
| 58 |
0
|
NotificationProducer producer4 = new NotificationProducer(); |
| 59 |
0
|
criteria.put(NotificationConstants.BO_PROPERTY_NAMES.NAME, mockProducer1.getName()); |
| 60 |
0
|
producer4 = (NotificationProducer) businessObjectDao.findByUniqueKey(NotificationProducer.class, criteria); |
| 61 |
|
|
| 62 |
0
|
assertEquals(1, producer4.getChannels().size()); |
| 63 |
|
|
| 64 |
0
|
criteria.clear(); |
| 65 |
0
|
NotificationProducer producer5 = new NotificationProducer(); |
| 66 |
0
|
criteria.put(NotificationConstants.BO_PROPERTY_NAMES.NAME, mockProducer1.getName()); |
| 67 |
0
|
producer5 = (NotificationProducer) businessObjectDao.findByUniqueKey(NotificationProducer.class, criteria); |
| 68 |
|
|
| 69 |
0
|
try { |
| 70 |
0
|
businessObjectDao.delete(producer5); |
| 71 |
|
} catch(Exception e) { |
| 72 |
0
|
return false; |
| 73 |
|
} |
| 74 |
0
|
return true; |
| 75 |
|
} |
| 76 |
|
|
| 77 |
|
|
| 78 |
|
@see |
| 79 |
|
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
|
| 80 |
0
|
@Override... |
| 81 |
|
protected boolean retrieve() { |
| 82 |
0
|
NotificationProducer producer2 = new NotificationProducer(); |
| 83 |
|
|
| 84 |
0
|
HashMap criteria = new HashMap(); |
| 85 |
|
|
| 86 |
0
|
criteria.put(NotificationConstants.BO_PROPERTY_NAMES.NAME, mockProducer1.getName()); |
| 87 |
0
|
producer2 = (NotificationProducer) businessObjectDao.findByUniqueKey(NotificationProducer.class, criteria); |
| 88 |
|
|
| 89 |
0
|
boolean success = true; |
| 90 |
|
|
| 91 |
0
|
success &= producer2 != null; |
| 92 |
0
|
success &= producer2.getDescription().equals(mockProducer1.getDescription()); |
| 93 |
0
|
success &= producer2.getChannels().size()==2; |
| 94 |
|
|
| 95 |
0
|
return success; |
| 96 |
|
} |
| 97 |
|
|
| 98 |
|
|
| 99 |
|
@see |
| 100 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.29 |
|
| 101 |
0
|
@Override... |
| 102 |
|
protected boolean insert() { |
| 103 |
0
|
NotificationProducer producer1 = MockObjectsUtil.getTestProducer1(); |
| 104 |
|
|
| 105 |
|
|
| 106 |
0
|
producer1.getChannels().add(mockChannel1); |
| 107 |
0
|
producer1.getChannels().add(mockChannel2); |
| 108 |
|
|
| 109 |
0
|
try { |
| 110 |
0
|
businessObjectDao.save(producer1); |
| 111 |
|
} catch(Exception e) { |
| 112 |
0
|
return false; |
| 113 |
|
} |
| 114 |
0
|
return true; |
| 115 |
|
} |
| 116 |
|
|
| 117 |
|
|
| 118 |
|
@see |
| 119 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.2 |
|
| 120 |
0
|
@Override... |
| 121 |
|
protected boolean update() { |
| 122 |
0
|
NotificationProducer producer2 = new NotificationProducer(); |
| 123 |
|
|
| 124 |
0
|
HashMap criteria = new HashMap(); |
| 125 |
|
|
| 126 |
0
|
criteria.put(NotificationConstants.BO_PROPERTY_NAMES.NAME, mockProducer1.getName()); |
| 127 |
0
|
producer2 = (NotificationProducer) businessObjectDao.findByUniqueKey(NotificationProducer.class, criteria); |
| 128 |
|
|
| 129 |
0
|
producer2.setDescription(updatedDescriptions[0]); |
| 130 |
0
|
producer2.getChannels().remove(0); |
| 131 |
|
|
| 132 |
0
|
try { |
| 133 |
0
|
businessObjectDao.save(producer2); |
| 134 |
|
} catch(Exception e) { |
| 135 |
0
|
return false; |
| 136 |
|
} |
| 137 |
0
|
return true; |
| 138 |
|
} |
| 139 |
|
|
| 140 |
|
|
| 141 |
|
@see |
| 142 |
|
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
| 143 |
0
|
@Override... |
| 144 |
|
protected boolean validateChanges() { |
| 145 |
0
|
NotificationProducer producer2 = new NotificationProducer(); |
| 146 |
|
|
| 147 |
0
|
HashMap criteria = new HashMap(); |
| 148 |
|
|
| 149 |
0
|
criteria.put(NotificationConstants.BO_PROPERTY_NAMES.NAME, mockProducer1.getName()); |
| 150 |
0
|
producer2 = (NotificationProducer) businessObjectDao.findByUniqueKey(NotificationProducer.class, criteria); |
| 151 |
|
|
| 152 |
0
|
boolean success = true; |
| 153 |
|
|
| 154 |
0
|
success &= producer2.getDescription().equals(updatedDescriptions[0]); |
| 155 |
0
|
success &= producer2.getChannels().size()==1; |
| 156 |
|
|
| 157 |
0
|
return success; |
| 158 |
|
} |
| 159 |
|
} |