| 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 org.jmock.Expectations; |
| 23 |
|
import org.jmock.Mockery; |
| 24 |
|
import org.jmock.integration.junit4.JUnit4Mockery; |
| 25 |
|
import org.xwiki.bridge.DocumentAccessBridge; |
| 26 |
|
import org.xwiki.model.reference.AttachmentReferenceResolver; |
| 27 |
|
import org.xwiki.model.reference.DocumentReferenceResolver; |
| 28 |
|
import org.xwiki.model.reference.SpaceReferenceResolver; |
| 29 |
|
import org.xwiki.rendering.wiki.WikiModel; |
| 30 |
|
import org.xwiki.security.authorization.ContextualAuthorizationManager; |
| 31 |
|
import org.xwiki.security.authorization.Right; |
| 32 |
|
import org.xwiki.test.jmock.MockingComponentManager; |
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
@version |
| 38 |
|
@since |
| 39 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (19) |
Complexity: 4 |
Complexity Density: 0.27 |
|
| 40 |
|
public class ScriptMockSetup |
| 41 |
|
{ |
| 42 |
|
public DocumentAccessBridge bridge; |
| 43 |
|
|
| 44 |
|
public ContextualAuthorizationManager authorizationManager; |
| 45 |
|
|
| 46 |
|
public AttachmentReferenceResolver<String> attachmentReferenceResolver; |
| 47 |
|
|
| 48 |
|
public DocumentReferenceResolver<String> documentReferenceResolver; |
| 49 |
|
|
| 50 |
|
public SpaceReferenceResolver<String> spaceReferenceResolver; |
| 51 |
|
|
| 52 |
|
public WikiModel wikiModel; |
| 53 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 54 |
18 |
public ScriptMockSetup(MockingComponentManager componentManager) throws Exception... |
| 55 |
|
{ |
| 56 |
18 |
this(new JUnit4Mockery(), componentManager); |
| 57 |
|
} |
| 58 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
| 59 |
66 |
public ScriptMockSetup(Mockery mockery, MockingComponentManager cm) throws Exception... |
| 60 |
|
{ |
| 61 |
|
|
| 62 |
66 |
this.bridge = cm.registerMockComponent(mockery, DocumentAccessBridge.class); |
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 63 |
66 |
mockery.checking(new Expectations() {{... |
| 64 |
66 |
allowing(bridge).hasProgrammingRights(); will(returnValue(true)); |
| 65 |
|
}}); |
| 66 |
|
|
| 67 |
|
|
| 68 |
66 |
this.authorizationManager = cm.registerMockComponent(mockery, ContextualAuthorizationManager.class); |
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 69 |
66 |
mockery.checking(new Expectations() {{... |
| 70 |
66 |
allowing(authorizationManager).hasAccess(Right.SCRIPT); will(returnValue(true)); |
| 71 |
66 |
allowing(authorizationManager).hasAccess(Right.PROGRAM); will(returnValue(true)); |
| 72 |
|
}}); |
| 73 |
|
|
| 74 |
|
|
| 75 |
66 |
this.wikiModel = cm.registerMockComponent(mockery, WikiModel.class); |
| 76 |
|
|
| 77 |
|
|
| 78 |
66 |
this.attachmentReferenceResolver = |
| 79 |
|
cm.registerMockComponent(mockery, AttachmentReferenceResolver.TYPE_STRING, "current"); |
| 80 |
|
|
| 81 |
|
|
| 82 |
66 |
this.documentReferenceResolver = |
| 83 |
|
cm.registerMockComponent(mockery, DocumentReferenceResolver.TYPE_STRING, "current"); |
| 84 |
|
|
| 85 |
|
|
| 86 |
66 |
this.spaceReferenceResolver = cm.registerMockComponent(mockery, SpaceReferenceResolver.TYPE_STRING, "current"); |
| 87 |
|
} |
| 88 |
|
} |