1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.kuali.mobility.admin.util;
16
17 import java.util.Properties;
18
19 import org.junit.Assert;
20 import org.junit.Test;
21 import org.kuali.mobility.admin.entity.HomeScreen;
22
23
24
25
26
27
28 public class LayoutUtilTest {
29
30
31
32
33
34 @Test
35 public void testValidLayoutPredefined(){
36 for(String layout : HomeScreen.LAYOUTS){
37 Assert.assertTrue("Layout " + layout + " is expected to be valid", LayoutUtil.isValidLayout(layout));
38 }
39 }
40
41
42
43
44 @Test
45 public void testNullInvalidLayoutPredefined(){
46 Assert.assertFalse("null layout is not expected to be valid", LayoutUtil.isValidLayout(null));
47 }
48
49
50
51
52
53 @Test
54 public void testCorrectedLayout(){
55 Properties kmeProperties = new Properties();
56 kmeProperties.put(LayoutUtil.PROP_LAYOUT_EDITABLE, "false");
57 kmeProperties.put(LayoutUtil.PROP_LAYOUT_DEFAULT, HomeScreen.LAYOUT_LIST);
58
59 String layout = "myFakeLayout";
60 String newLayout = LayoutUtil.getValidLayout(layout, kmeProperties);
61
62 Assert.assertEquals(HomeScreen.LAYOUT_LIST, newLayout);
63 }
64
65
66
67
68
69 @Test
70 public void testCorrectedLayout2(){
71 Properties kmeProperties = new Properties();
72 kmeProperties.put(LayoutUtil.PROP_LAYOUT_EDITABLE, "false");
73 kmeProperties.put(LayoutUtil.PROP_LAYOUT_DEFAULT, HomeScreen.LAYOUT_LIST);
74
75 String newLayout = LayoutUtil.getValidLayout(HomeScreen.LAYOUT_TILES, kmeProperties);
76
77 Assert.assertEquals(HomeScreen.LAYOUT_LIST, newLayout);
78 }
79
80
81
82
83
84 @Test
85 public void testCorrectedLayout3(){
86 Properties kmeProperties = new Properties();
87 kmeProperties.put(LayoutUtil.PROP_LAYOUT_EDITABLE, "true");
88 kmeProperties.put(LayoutUtil.PROP_LAYOUT_DEFAULT, HomeScreen.LAYOUT_LIST);
89
90 String layout = "myFakeLayout";
91 String newLayout = LayoutUtil.getValidLayout(layout, kmeProperties);
92
93 Assert.assertEquals(HomeScreen.LAYOUT_LIST, newLayout);
94 }
95
96
97
98
99 @Test
100 public void testIsValidLayout(){
101 Properties kmeProperties = new Properties();
102 kmeProperties.put(LayoutUtil.PROP_LAYOUT_EDITABLE, "true");
103 kmeProperties.put(LayoutUtil.PROP_LAYOUT_DEFAULT, HomeScreen.LAYOUT_LIST);
104
105 String layout = "myFakeLayout";
106 Assert.assertFalse("Layout " + layout + " is not expected to be valid", LayoutUtil.isValidLayout(layout));
107 }
108
109
110
111
112
113 @Test
114 public void testIsLayoutAllowed(){
115 Properties kmeProperties = new Properties();
116 kmeProperties.put(LayoutUtil.PROP_LAYOUT_EDITABLE, "true");
117 kmeProperties.put(LayoutUtil.PROP_LAYOUT_DEFAULT, HomeScreen.LAYOUT_LIST);
118
119 String layout = "myFakeLayout";
120 Assert.assertFalse("Layout " + layout + " is not expected to be valid", LayoutUtil.isLayoutAllowed(layout, kmeProperties));
121 }
122
123
124
125
126 @Test
127 public void testIsLayoutAllowed2(){
128 Properties kmeProperties = new Properties();
129 kmeProperties.put(LayoutUtil.PROP_LAYOUT_EDITABLE, "false");
130 kmeProperties.put(LayoutUtil.PROP_LAYOUT_DEFAULT, HomeScreen.LAYOUT_LIST);
131
132 Assert.assertFalse("Layout " + HomeScreen.LAYOUT_TILES + " is not expected to be valid", LayoutUtil.isLayoutAllowed(HomeScreen.LAYOUT_TILES, kmeProperties));
133 }
134
135
136
137
138 @Test
139 public void testIsLayoutAllowed3(){
140 Properties kmeProperties = new Properties();
141 kmeProperties.put(LayoutUtil.PROP_LAYOUT_EDITABLE, "true");
142 kmeProperties.put(LayoutUtil.PROP_LAYOUT_DEFAULT, HomeScreen.LAYOUT_LIST);
143
144 Assert.assertTrue("Layout " + HomeScreen.LAYOUT_TILES + " is expected to be valid", LayoutUtil.isLayoutAllowed(HomeScreen.LAYOUT_TILES, kmeProperties));
145 }
146
147
148
149
150 @Test
151 public void testIsLayoutChangeAllowed(){
152 Properties kmeProperties = new Properties();
153 kmeProperties.put(LayoutUtil.PROP_LAYOUT_EDITABLE, "false");
154 Assert.assertFalse(LayoutUtil.isLayoutChangeAllowed(kmeProperties));
155 }
156
157
158
159
160 @Test
161 public void testIsLayoutChangeAllowed2(){
162 Properties kmeProperties = new Properties();
163 kmeProperties.put(LayoutUtil.PROP_LAYOUT_EDITABLE, "true");
164 Assert.assertTrue(LayoutUtil.isLayoutChangeAllowed(kmeProperties));
165 }
166 }