|
39 | 39 | import org.xwiki.rendering.transformation.MacroTransformationContext; |
40 | 40 | import org.xwiki.rendering.transformation.RenderingContext; |
41 | 41 | import org.xwiki.rendering.transformation.Transformation; |
| 42 | +import org.xwiki.rendering.transformation.TransformationContext; |
42 | 43 | import org.xwiki.test.annotation.ComponentList; |
43 | 44 | import org.xwiki.test.junit5.mockito.ComponentTest; |
44 | 45 | import org.xwiki.test.junit5.mockito.InjectMockComponents; |
45 | 46 | import org.xwiki.test.junit5.mockito.MockComponent; |
46 | 47 |
|
47 | 48 | import static org.junit.jupiter.api.Assertions.assertEquals; |
48 | 49 | import static org.mockito.ArgumentMatchers.any; |
| 50 | +import static org.mockito.ArgumentMatchers.argThat; |
49 | 51 | import static org.mockito.ArgumentMatchers.eq; |
50 | 52 | import static org.mockito.Mockito.mock; |
51 | 53 | import static org.mockito.Mockito.verify; |
@@ -108,7 +110,26 @@ void parseInlineWithStandaloneMacroWithTransformations() throws Exception |
108 | 110 |
|
109 | 111 | this.macroContentParser.parse("content", this.macroContext, true, true); |
110 | 112 |
|
111 | | - verify((MutableRenderingContext) this.renderingContext).transformInContext(any(), any(), |
| 113 | + verify((MutableRenderingContext) this.renderingContext).transformInContext(any(), |
| 114 | + argThat(context -> !context.isRestricted()), |
112 | 115 | eq(new XDOM(Arrays.<Block>asList(new MacroBlock("macro", Collections.emptyMap(), null, true))))); |
113 | 116 | } |
| 117 | + |
| 118 | + @Test |
| 119 | + void parseInlineWithStandaloneMacroWithRestrictedTransformations() throws Exception |
| 120 | + { |
| 121 | + when(this.mockParser.parse(any(Reader.class))) |
| 122 | + .thenReturn( |
| 123 | + new XDOM(Collections.singletonList(new MacroBlock("macro", Collections.emptyMap(), null, false)))); |
| 124 | + |
| 125 | + this.macroContext.setTransformation(mock(Transformation.class)); |
| 126 | + this.macroContext.getTransformationContext().setRestricted(true); |
| 127 | + |
| 128 | + this.macroContentParser.parse("content", this.macroContext, true, true); |
| 129 | + |
| 130 | + verify((MutableRenderingContext) this.renderingContext).transformInContext( |
| 131 | + any(), argThat(TransformationContext::isRestricted), |
| 132 | + eq(new XDOM(Collections.singletonList(new MacroBlock("macro", Collections.emptyMap(), null, true)))) |
| 133 | + ); |
| 134 | + } |
114 | 135 | } |
0 commit comments