Clover Coverage Report - ken-test 2.0.0-SNAPSHOT
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
../../../../../img/srcFileCovDistChart0.png 0% of files have more coverage
50   159   9   8.33
0   87   0.18   6
6     1.5  
1    
 
  NotificationProducerDaoTest       Line # 33 50 0% 9 56 0% 0.0
 
No Tests
 
1    /*
2    * Copyright 2007 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10    * Unless required by applicable law or agreed to in writing, software
11    * distributed under the License is distributed on an "AS IS" BASIS,
12    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    * See the License for the specific language governing permissions and
14    * limitations under the License.
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    * This class tests basic persistence for the NotificationProducer business object.
30    *
31    * @author Kuali Rice Team (rice.collab@kuali.org)
32    */
 
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 org.kuali.rice.ken.dao.BusinessObjectPersistenceTestCaseBase#setup()
43    */
 
44  0 toggle @Override
45    protected void setup() {
46  0 super.setup();
47  0 businessObjectDao.save(mockChannel1);
48  0 businessObjectDao.save(mockChannel2);
49    }
50   
51    /**
52    * @see org.kuali.rice.ken.dao.BusinessObjectPersistenceTestCaseBase#delete()
53    */
 
54  0 toggle @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 org.kuali.rice.ken.dao.BusinessObjectPersistenceTestCaseBase#retrieve()
79    */
 
80  0 toggle @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 org.kuali.rice.ken.dao.BusinessObjectPersistenceTestCaseBase#insert()
100    */
 
101  0 toggle @Override
102    protected boolean insert() {
103  0 NotificationProducer producer1 = MockObjectsUtil.getTestProducer1();
104   
105    //set up the channels
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 org.kuali.rice.ken.dao.BusinessObjectPersistenceTestCaseBase#update()
119    */
 
120  0 toggle @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 org.kuali.rice.ken.dao.BusinessObjectPersistenceTestCaseBase#validateChanges()
142    */
 
143  0 toggle @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    }