@Test void testStringEvaluatorLookupAttributeAndConvertFromNonNumericStringToLongFails() { Attribute amd = when(mock(Attribute.class).getName()).thenReturn("#POS").getMock(); when(amd.getName()).thenReturn("id"); when(amd.getDataType()).thenReturn(LONG); when(amd.getExpression()).thenReturn("NonNumericString"); when(amd.getEntity()).thenReturn(entityType); Exception exception = assertThrows( AttributeValueConversionException.class, () -> new StringExpressionEvaluator(amd, entityType).evaluate(entity)); assertThat(exception.getMessage()) .containsPattern( "Conversion failure in entity type \\[test\\] attribute \\[id\\]; Failed to convert from type \\[java.lang.String\\] to type \\[java.lang.Long\\] for value 'Hello World!'; nested exception is java.lang.NumberFormatException: For input string: \"HelloWorld!\""); }
@Override public Object evaluate(Entity entity) { Object o = entity.get(sourceAttribute.getName()); return DataConverter.convert(o, targetAttribute); }
StringExpressionEvaluator implements ExpressionEvaluator { @Override public Object evaluate(Entity entity) { Object o = entity.get(sourceAttribute.getName()); return DataConverter.convert(o, targetAttribute); } }
StringExpressionEvaluator implements ExpressionEvaluator { @Override public Object evaluate(Entity entity) { Object o = entity.get(sourceAttribute.getName()); return DataConverter.convert(o, targetAttribute); } StringExpressionEvaluator(Attribute attribute, EntityType entityType); }
StringExpressionEvaluator implements ExpressionEvaluator { @Override public Object evaluate(Entity entity) { Object o = entity.get(sourceAttribute.getName()); return DataConverter.convert(o, targetAttribute); } StringExpressionEvaluator(Attribute attribute, EntityType entityType); @Override Object evaluate(Entity entity); }
StringExpressionEvaluator implements ExpressionEvaluator { @Override public Object evaluate(Entity entity) { Object o = entity.get(sourceAttribute.getName()); return DataConverter.convert(o, targetAttribute); } StringExpressionEvaluator(Attribute attribute, EntityType entityType); @Override Object evaluate(Entity entity);  }