1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.kuali.mobility.push.dao;
16
17 import static org.junit.Assert.assertFalse;
18 import static org.junit.Assert.assertTrue;
19
20 import java.util.List;
21
22 import javax.persistence.EntityManager;
23 import javax.persistence.PersistenceContext;
24
25 import org.apache.log4j.Logger;
26 import org.junit.AfterClass;
27 import org.junit.Before;
28 import org.junit.BeforeClass;
29 import org.junit.Test;
30 import org.junit.runner.RunWith;
31 import org.kuali.mobility.push.entity.Sender;
32 import org.springframework.beans.factory.annotation.Autowired;
33 import org.springframework.beans.factory.annotation.Qualifier;
34 import org.springframework.test.context.ContextConfiguration;
35 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
36
37
38
39
40 @RunWith(SpringJUnit4ClassRunner.class)
41 @ContextConfiguration(value = "classpath:TestSpringBeans.xml")
42 public class SenderDaoImplTest {
43
44 private static final Logger LOG = Logger.getLogger(SenderDaoImplTest.class);
45
46 @PersistenceContext
47 private EntityManager entityManager;
48
49
50
51
52
53 @Autowired
54 @Qualifier("senderDaoImpl")
55 private SenderDao dao;
56
57 @BeforeClass
58 public static void setUpClass() throws Exception {
59 }
60
61 @AfterClass
62 public static void tearDownClass() throws Exception {
63 }
64
65 @Before
66 public void preTest() {
67 }
68
69 @Test
70 public void testNothing() {
71
72 }
73
74 @Test
75 public void testFindAllSenders() {
76 List<Sender> senders = getDao().findAllSenders();
77 assertFalse("FindAllSenders returned null and should not have.",null==senders);
78 assertTrue("FindAllSenders returned no devices.", senders.size() > 0);
79 assertTrue("FindAllSenders failed to find the pre-loaded data.",senders.size()==3);
80 }
81
82 @Test
83 public void testFindAllUnhiddenSenders() {
84 List<Sender> senders = getDao().findAllUnhiddenSenders();
85 assertFalse("FindAllUnhiddenSenders returned null and should not have.",null==senders);
86 assertTrue("FindAllUnhiddenSenders returned no devices.", senders.size() > 0);
87 assertTrue("FindAllUnhiddenSenders failed to find the pre-loaded data.",senders.size()==1);
88 }
89
90 @Test
91 public void testFindSenderById() {
92 Sender senders = getDao().findSenderById(1L);
93 assertFalse("FindSenderById returned null and should not have.",null==senders);
94 }
95
96 @Test
97 public void testFindSenderByWrongId() {
98 Sender senders = getDao().findSenderById(123L);
99 assertTrue("FindSenderById shouldn't return Sender, but did.",null==senders);
100 }
101
102 @Test
103 public void testFindSenderByName(){
104
105
106 }
107
108 @Test
109 public void testFindSenderByWrongName(){
110 Sender senders = getDao().findSenderByName("FALSE_KME_PUSH");
111 assertTrue("FindSenderByWrongName should have returned null, but didn't.",null==senders);
112 }
113
114 @Test
115 public void testFindSenderBySenderKey(){
116 Sender senders = getDao().findSenderBySenderKey("3AbHRDjirFn2hvii4Pq3");
117 assertFalse("FindSenderById returned null and should not have.",null==senders);
118 }
119
120 @Test
121 public void testFindSenderByWrongSenderKey(){
122 Sender senders = getDao().findSenderBySenderKey("FALSE_SENDER_KEY");
123 assertTrue("FindSenderById should have returned null, but didn't.",null==senders);
124 }
125
126
127
128
129 public EntityManager getEntityManager() {
130 return entityManager;
131 }
132
133
134
135
136 public void setEntityManager(EntityManager entityManager) {
137 this.entityManager = entityManager;
138 }
139
140
141
142
143 public SenderDao getDao() {
144 return dao;
145 }
146
147
148
149
150 public void setDao(SenderDao dao) {
151 this.dao = dao;
152 }
153
154
155 }