1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
package info.magnolia.module.groovy.terminal; |
35 |
|
|
36 |
|
import static org.junit.Assert.assertTrue; |
37 |
|
import static org.mockito.Mockito.mock; |
38 |
|
|
39 |
|
import info.magnolia.context.MgnlContext; |
40 |
|
import info.magnolia.i18nsystem.LocaleProvider; |
41 |
|
import info.magnolia.i18nsystem.SimpleTranslator; |
42 |
|
import info.magnolia.i18nsystem.TranslationService; |
43 |
|
import info.magnolia.module.groovy.GroovyBaseTestCase; |
44 |
|
import info.magnolia.test.ComponentsTestUtil; |
45 |
|
import info.magnolia.test.mock.MockContext; |
46 |
|
import info.magnolia.test.mock.MockUtil; |
47 |
|
import info.magnolia.test.mock.MockWebContext; |
48 |
|
import info.magnolia.ui.framework.message.MessagesManager; |
49 |
|
|
50 |
|
import org.junit.Test; |
51 |
|
|
52 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 3 |
Complexity Density: 0.33 |
|
53 |
|
public class GroovyTerminalTest extends GroovyBaseTestCase { |
54 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
55 |
1 |
@Override... |
56 |
|
public void setUp() throws Exception { |
57 |
1 |
super.setUp(); |
58 |
1 |
ComponentsTestUtil.setInstance(TranslationService.class, mock(TranslationService.class)); |
59 |
1 |
ComponentsTestUtil.setInstance(LocaleProvider.class, mock(LocaleProvider.class)); |
60 |
1 |
MockContext ctx = MockUtil.initMockContext(); |
61 |
1 |
((MockWebContext) ctx).setUser(new GroovyUser()); |
62 |
|
} |
63 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
64 |
1 |
@Override... |
65 |
|
public void tearDown() throws Exception { |
66 |
1 |
super.tearDown(); |
67 |
1 |
ComponentsTestUtil.clear(); |
68 |
|
} |
69 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
70 |
1 |
@Test... |
71 |
|
public void onlyAuthorizedUsersCanExecuteGroovyCode() throws Exception { |
72 |
1 |
Terminal terminal = new Terminal(mock(SimpleTranslator.class), false, false, mock(MessagesManager.class)); |
73 |
1 |
assertTrue(terminal.isAuthorized(MgnlContext.getUser())); |
74 |
|
} |
75 |
|
|
76 |
|
} |