Skip to content

Commit

Permalink
Fix merge result
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller committed Sep 5, 2020
1 parent 9d7849c commit 3fd89c3
Showing 1 changed file with 0 additions and 55 deletions.
Expand Up @@ -83,61 +83,6 @@ public int getOrder() {
return 42;
}
}

@Test // gh-25706
void defaultMethodInvocation() {
SpelParserConfiguration config = new SpelParserConfiguration(SpelCompilerMode.IMMEDIATE, null);
SpelExpressionParser parser = new SpelExpressionParser(config);

StandardEvaluationContext context = new StandardEvaluationContext();
Item item = new Item();
context.setRootObject(item);

Expression expression = parser.parseExpression("#root.isEditable2()");
assertThat(SpelCompiler.compile(expression)).isFalse();
assertThat(expression.getValue(context)).isEqualTo(false);
assertThat(SpelCompiler.compile(expression)).isTrue();
SpelCompilationCoverageTests.assertIsCompiled(expression);
assertThat(expression.getValue(context)).isEqualTo(false);

context.setVariable("user", new User());
expression = parser.parseExpression("#root.isEditable(#user)");
assertThat(SpelCompiler.compile(expression)).isFalse();
assertThat(expression.getValue(context)).isEqualTo(true);
assertThat(SpelCompiler.compile(expression)).isTrue();
SpelCompilationCoverageTests.assertIsCompiled(expression);
assertThat(expression.getValue(context)).isEqualTo(true);
}

public static class User {
boolean isAdmin() {
return true;
}
}

public static class Item implements Editable {
// some fields
private String someField = "";

// some getters and setters

@Override
public boolean hasSomeProperty() {
return someField != null;
}
}

public interface Editable {
default boolean isEditable(User user) {
return user.isAdmin() && hasSomeProperty();
}

default boolean isEditable2() {
return false;
}

boolean hasSomeProperty();
}


public static class User {
Expand Down

0 comments on commit 3fd89c3

Please sign in to comment.