1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rendering.macro.script; |
21 |
|
|
22 |
|
import java.util.Collections; |
23 |
|
|
24 |
|
import org.jmock.Expectations; |
25 |
|
import org.jmock.Mockery; |
26 |
|
import org.jmock.integration.junit4.JUnit4Mockery; |
27 |
|
import org.junit.runner.RunWith; |
28 |
|
import org.xwiki.observation.EventListener; |
29 |
|
import org.xwiki.observation.event.Event; |
30 |
|
import org.xwiki.rendering.test.integration.RenderingTestSuite; |
31 |
|
import org.xwiki.rendering.transformation.MacroTransformationContext; |
32 |
|
import org.xwiki.script.event.ScriptEvaluatingEvent; |
33 |
|
import org.xwiki.test.jmock.MockingComponentManager; |
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
@link |
38 |
|
|
39 |
|
@version |
40 |
|
@since |
41 |
|
|
42 |
|
@RunWith(RenderingTestSuite.class) |
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 2 |
Complexity Density: 0.22 |
|
43 |
|
public class IntegrationTests |
44 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
45 |
8 |
@RenderingTestSuite.Initialized... |
46 |
|
public void initialize(MockingComponentManager cm) throws Exception |
47 |
|
{ |
48 |
8 |
Mockery mockery = new JUnit4Mockery(); |
49 |
8 |
new ScriptMockSetup(mockery, cm); |
50 |
|
|
51 |
|
|
52 |
8 |
final EventListener nestedValidator = |
53 |
|
cm.registerMockComponent(mockery, EventListener.class, "nestedscriptmacrovalidator"); |
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
54 |
8 |
mockery.checking(new Expectations() {{... |
55 |
8 |
atLeast(1).of(nestedValidator).onEvent(with(any(Event.class)), with(any(MacroTransformationContext.class)), |
56 |
|
with(any(ScriptMacroParameters.class))); |
57 |
8 |
allowing(nestedValidator).getName(); |
58 |
8 |
will(returnValue("nestedscriptmacrovalidator")); |
59 |
8 |
allowing(nestedValidator).getEvents(); |
60 |
8 |
will(returnValue(Collections.singletonList((Event) new ScriptEvaluatingEvent()))); |
61 |
|
}}); |
62 |
|
} |
63 |
|
} |