1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.mobility.security.authz.expression;
17
18 import org.junit.Test;
19 import org.kuali.mobility.security.user.api.User;
20 import org.kuali.mobility.security.user.entity.UserImpl;
21
22 import static org.junit.Assert.assertFalse;
23 import static org.junit.Assert.assertTrue;
24
25 public class OrExpressionTest {
26
27 @Test
28 public void testNone() throws Exception {
29 OrExpression expression = new OrExpression();
30 User user = new UserImpl();
31
32 assertFalse(expression.evaluate(user));
33 }
34
35 @Test
36 public void testOne() throws Exception {
37 OrExpression expression = new OrExpression();
38 PersonAttributeExpression prsnAttExp = new PersonAttributeExpression("user.authenticated", "false");
39
40 expression.addChild(prsnAttExp);
41
42 User user = new UserImpl();
43
44 assertFalse(expression.evaluate(user));
45
46 user.addAttribute("user.authenticated", "false");
47 assertTrue(expression.evaluate(user));
48 }
49
50 @Test
51 public void testTwo() throws Exception {
52 OrExpression expression = new OrExpression();
53 PersonAttributeExpression prsnAttExp = new PersonAttributeExpression("user.authenticated", "false");
54 expression.addChild(prsnAttExp);
55
56 prsnAttExp = new PersonAttributeExpression("user.iu.ou", "BL");
57 expression.addChild(prsnAttExp);
58
59 User user = new UserImpl();
60
61 assertFalse(expression.evaluate(user));
62
63 user.addAttribute("user.authenticated", "false");
64 assertTrue(expression.evaluate(user));
65
66 user.removeAttribute("user.authenticated");
67 user.addAttribute("user.iu.ou", "BL");
68 assertTrue(expression.evaluate(user));
69
70 user.addAttribute("user.authenticated", "false");
71 assertTrue(expression.evaluate(user));
72 }
73
74 }