@Test
  public void hasPermissionWorksWithThisObject() throws Exception {
    Object targetObject =
        new Object() {
          public String getX() {
            return "x";
          }
        };
    root.setThis(targetObject);
    Integer i = 2;
    PermissionEvaluator pe = mock(PermissionEvaluator.class);
    root.setPermissionEvaluator(pe);
    when(pe.hasPermission(user, targetObject, i)).thenReturn(true).thenReturn(false);
    when(pe.hasPermission(user, "x", i)).thenReturn(true);

    Expression e = parser.parseExpression("hasPermission(this, 2)");
    assertThat(ExpressionUtils.evaluateAsBoolean(e, ctx)).isTrue();
    e = parser.parseExpression("hasPermission(this, 2)");
    assertThat(ExpressionUtils.evaluateAsBoolean(e, ctx)).isFalse();

    e = parser.parseExpression("hasPermission(this.x, 2)");
    assertThat(ExpressionUtils.evaluateAsBoolean(e, ctx)).isTrue();
  }