use of cn.taketoday.expression.spel.testresources.RecordPerson in project today-infrastructure by TAKETODAY.
the class PropertyAccessTests method propertyReadOnlyWithRecordStyle.
@Test
void propertyReadOnlyWithRecordStyle() {
EvaluationContext context = SimpleEvaluationContext.forReadOnlyDataBinding().build();
Expression expr = parser.parseExpression("name");
RecordPerson target1 = new RecordPerson("p1");
assertThat(expr.getValue(context, target1)).isEqualTo("p1");
RecordPerson target2 = new RecordPerson("p2");
assertThat(expr.getValue(context, target2)).isEqualTo("p2");
assertThatExceptionOfType(SpelEvaluationException.class).isThrownBy(() -> parser.parseExpression("name='p3'").getValue(context, target2));
}
use of cn.taketoday.expression.spel.testresources.RecordPerson in project today-framework by TAKETODAY.
the class PropertyAccessTests method propertyReadOnlyWithRecordStyle.
@Test
void propertyReadOnlyWithRecordStyle() {
EvaluationContext context = SimpleEvaluationContext.forReadOnlyDataBinding().build();
Expression expr = parser.parseExpression("name");
RecordPerson target1 = new RecordPerson("p1");
assertThat(expr.getValue(context, target1)).isEqualTo("p1");
RecordPerson target2 = new RecordPerson("p2");
assertThat(expr.getValue(context, target2)).isEqualTo("p2");
assertThatExceptionOfType(SpelEvaluationException.class).isThrownBy(() -> parser.parseExpression("name='p3'").getValue(context, target2));
}
Aggregations