1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kcb.service.impl;
17
18 import org.junit.Test;
19 import org.kuali.rice.kcb.bo.MessageDelivery;
20 import org.kuali.rice.kcb.deliverer.MessageDeliverer;
21 import org.kuali.rice.kcb.test.KCBTestCase;
22 import org.kuali.rice.kcb.test.TestConstants;
23 import org.kuali.rice.test.BaselineTestCase.BaselineMode;
24 import org.kuali.rice.test.BaselineTestCase.Mode;
25
26 import java.util.Collection;
27
28 import static org.junit.Assert.*;
29
30
31
32
33
34 @BaselineMode(Mode.ROLLBACK_CLEAR_DB)
35 public class MessageDelivererRegistryServiceTest extends KCBTestCase {
36
37
38
39 @Test
40 public void testGetAllDeliverTypes() {
41 Collection<MessageDeliverer> deliverers = services.getMessageDelivererRegistryService().getAllDeliverers();
42
43 assertEquals(4, deliverers.size());
44
45 for(MessageDeliverer deliverer: deliverers) {
46 assertTrue(deliverer.getName() != null);
47 assertTrue(deliverer.getName().length() > 0);
48 }
49 }
50
51
52
53
54 @Test
55 public void testGetDeliverer_valid() {
56 MessageDelivery mockValid = new MessageDelivery();
57 mockValid.setDelivererTypeName(TestConstants.VALID_DELIVERER_NAME);
58
59
60 MessageDeliverer deliverer = services.getMessageDelivererRegistryService().getDeliverer(mockValid);
61 if (deliverer == null) {
62 throw new RuntimeException("Message deliverer could not be obtained");
63 }
64
65 assertEquals(TestConstants.VALID_DELIVERER_NAME, deliverer.getName());
66 }
67
68
69
70
71 @Test
72 public void testGetDeliverer_nonExistent() {
73 MessageDelivery mockInvalid = new MessageDelivery();
74 mockInvalid.setDelivererTypeName(TestConstants.NON_EXISTENT_DELIVERER_NAME);
75
76 boolean caughtException = false;
77
78 MessageDeliverer deliverer = services.getMessageDelivererRegistryService().getDeliverer(mockInvalid);
79
80 assertNull(deliverer);
81 }
82
83
84
85
86 @Test
87 public void testGetDelivererByName_valid() {
88 MessageDeliverer deliverer = services.getMessageDelivererRegistryService().getDelivererByName(TestConstants.VALID_DELIVERER_NAME);
89
90 assertEquals(TestConstants.VALID_DELIVERER_NAME, deliverer.getName());
91 }
92
93 @Test
94 public void testGetDelivererByName_nonExistent() {
95 boolean caughtException = false;
96
97 MessageDeliverer deliverer = services.getMessageDelivererRegistryService().getDelivererByName(TestConstants.NON_EXISTENT_DELIVERER_NAME);
98
99 assertNull(deliverer);
100 }
101 }