1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.ken.services.impl;
17
18 import org.junit.Test;
19 import org.kuali.rice.ken.bo.NotificationChannelBo;
20 import org.kuali.rice.ken.bo.NotificationProducerBo;
21 import org.kuali.rice.ken.test.KENTestCase;
22 import org.kuali.rice.ken.test.TestConstants;
23 import org.kuali.rice.krad.service.KRADServiceLocator;
24 import org.kuali.rice.test.BaselineTestCase.BaselineMode;
25 import org.kuali.rice.test.BaselineTestCase.Mode;
26
27 import static org.junit.Assert.assertFalse;
28 import static org.junit.Assert.assertTrue;
29
30
31
32
33
34 @BaselineMode(Mode.CLEAR_DB)
35 public class NotificationAuthorizationServiceImplTest extends KENTestCase {
36
37 public NotificationAuthorizationServiceImplTest() {
38 }
39
40 @Test
41 public void testIsProducerAuthorizedForNotificationChannel_validInput() {
42
43 NotificationChannelBo channel = KRADServiceLocator.getDataObjectService().find(NotificationChannelBo.class,
44 TestConstants.CHANNEL_ID_1);
45 NotificationProducerBo producer = KRADServiceLocator.getDataObjectService().find(NotificationProducerBo.class,
46 TestConstants.PRODUCER_3.getId());
47
48 assertTrue(services.getNotificationAuthorizationService().isProducerAuthorizedToSendNotificationForChannel(producer, channel));
49 }
50
51 @Test
52 public void testIsProducerAuthorizedForNotificationChannel_invalidInput() {
53
54 NotificationChannelBo channel = KRADServiceLocator.getDataObjectService().find(NotificationChannelBo.class, TestConstants.CHANNEL_ID_1);
55 NotificationProducerBo producer = KRADServiceLocator.getDataObjectService().find(NotificationProducerBo.class, TestConstants.PRODUCER_4.getId());
56
57 assertFalse(services.getNotificationAuthorizationService().isProducerAuthorizedToSendNotificationForChannel(producer, channel));
58 }
59
60 @Test
61 public void testIsUserAdministrator_validAdmin() {
62 assertTrue(services.getNotificationAuthorizationService().isUserAdministrator(TestConstants.ADMIN_USER_1));
63 }
64
65 @Test
66 public void testIsUserAdministrator_nonAdmin() {
67 assertFalse(services.getNotificationAuthorizationService().isUserAdministrator(TestConstants.NON_ADMIN_USER_1));
68 }
69
70 @Test
71 public void testIsUserAdministrator_invalidUser() {
72 assertFalse(services.getNotificationAuthorizationService().isUserAdministrator(TestConstants.INVALID_USER_1));
73 }
74 }