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