@Test void testEvaluateDate() { when(expressionAttribute.getExpression()).thenReturn("{\"template\":\"my {{attr}}\"}"); Attribute attribute = when(mock(Attribute.class).getDataType()).thenReturn(DATE).getMock(); when(entityType.getAttribute("attr")).thenReturn(attribute); Entity entity = when(mock(Entity.class).getLocalDate("attr")) .thenReturn(LocalDate.parse("2000-12-31")) .getMock(); when(entity.getEntityType()).thenReturn(entityType); assertEquals("my 2000-12-31", templateExpressionEvaluator.evaluate(entity)); }
@Override public Object evaluate(Entity entity) { initTemplate(); Map<String, Object> tagValues = getTemplateTagValue(entity); try { return template.apply(Context.newContext(tagValues)); } catch (IOException e) { throw new TemplateExpressionException(attribute, e); } }
TemplateExpressionEvaluator implements ExpressionEvaluator { @Override public Object evaluate(Entity entity) { initTemplate(); Map<String, Object> tagValues = getTemplateTagValue(entity); try { return template.apply(Context.newContext(tagValues)); } catch (IOException e) { throw new TemplateExpressionException(attribute, e); } } }
TemplateExpressionEvaluator implements ExpressionEvaluator { @Override public Object evaluate(Entity entity) { initTemplate(); Map<String, Object> tagValues = getTemplateTagValue(entity); try { return template.apply(Context.newContext(tagValues)); } catch (IOException e) { throw new TemplateExpressionException(attribute, e); } } TemplateExpressionEvaluator(Attribute attribute, EntityType entityType); }
TemplateExpressionEvaluator implements ExpressionEvaluator { @Override public Object evaluate(Entity entity) { initTemplate(); Map<String, Object> tagValues = getTemplateTagValue(entity); try { return template.apply(Context.newContext(tagValues)); } catch (IOException e) { throw new TemplateExpressionException(attribute, e); } } TemplateExpressionEvaluator(Attribute attribute, EntityType entityType); @Override Object evaluate(Entity entity); static Template getTemplate(Attribute attribute); }
TemplateExpressionEvaluator implements ExpressionEvaluator { @Override public Object evaluate(Entity entity) { initTemplate(); Map<String, Object> tagValues = getTemplateTagValue(entity); try { return template.apply(Context.newContext(tagValues)); } catch (IOException e) { throw new TemplateExpressionException(attribute, e); } } TemplateExpressionEvaluator(Attribute attribute, EntityType entityType); @Override Object evaluate(Entity entity); static Template getTemplate(Attribute attribute);  }