@Test(expected = MacroExecutionException.class)
  public void testRestrictedByContext() throws Exception {
    VelocityMacroParameters params = new VelocityMacroParameters();
    MacroTransformationContext context = new MacroTransformationContext();
    context.setSyntax(Syntax.XWIKI_2_0);
    context.setCurrentMacroBlock(
        new MacroBlock("velocity", Collections.<String, String>emptyMap(), false));
    context.setId("page1");

    // Restrict the transformation context.
    context.getTransformationContext().setRestricted(true);

    when(authorizationManager.hasAccess(Right.SCRIPT)).thenReturn(true);

    mocker
        .getComponentUnderTest()
        .execute(params, "#macro(testMacrosAreLocal)mymacro#end", context);
  }