From 844f2463963afeb3954a0847cf3afff0e37055f5 Mon Sep 17 00:00:00 2001 From: uklimaschewski Date: Sun, 19 May 2024 14:20:25 +0200 Subject: [PATCH] removes deprecated methods --- .../ezylang/evalex/data/EvaluationValue.java | 27 ------------- .../evalex/data/EvaluationValueTest.java | 38 +++++++++---------- 2 files changed, 18 insertions(+), 47 deletions(-) diff --git a/src/main/java/com/ezylang/evalex/data/EvaluationValue.java b/src/main/java/com/ezylang/evalex/data/EvaluationValue.java index 9770d16b..7f5c658c 100644 --- a/src/main/java/com/ezylang/evalex/data/EvaluationValue.java +++ b/src/main/java/com/ezylang/evalex/data/EvaluationValue.java @@ -16,7 +16,6 @@ package com.ezylang.evalex.data; import com.ezylang.evalex.config.ExpressionConfiguration; -import com.ezylang.evalex.data.conversion.DefaultEvaluationValueConverter; import com.ezylang.evalex.parser.ASTNode; import java.math.BigDecimal; import java.math.BigInteger; @@ -87,19 +86,6 @@ public enum DataType { DataType dataType; - /** - * Creates a new evaluation value by using the default converter and configuration. - * - * @param value Any object that the default converter can convert. - * @throws IllegalArgumentException if the data type can't be mapped. - * @see DefaultEvaluationValueConverter - * @deprecated Use {@link EvaluationValue(Object, ExpressionConfiguration)} instead. - */ - @Deprecated(since = "3.1.0", forRemoval = true) - public EvaluationValue(Object value) { - this(value, ExpressionConfiguration.defaultConfiguration()); - } - /** * Creates a new evaluation value by using the configured converter and configuration. * @@ -233,19 +219,6 @@ public static EvaluationValue structureValue(Map value) { return new EvaluationValue(value, DataType.STRUCTURE); } - /** - * Creates a new evaluation value from a double value using the specified {@link MathContext}. - * - * @param value The double value. - * @param mathContext The math context to use. - * @deprecated since 3.1.0 - Use {@link EvaluationValue(Object, ExpressionConfiguration)}. - */ - @Deprecated(since = "3.1.0", forRemoval = true) - public EvaluationValue(double value, MathContext mathContext) { - this.dataType = DataType.NUMBER; - this.value = new BigDecimal(Double.toString(value), mathContext); - } - /** * Checks if the value is of type {@link DataType#NUMBER}. * diff --git a/src/test/java/com/ezylang/evalex/data/EvaluationValueTest.java b/src/test/java/com/ezylang/evalex/data/EvaluationValueTest.java index 48594caa..9cfc8b36 100644 --- a/src/test/java/com/ezylang/evalex/data/EvaluationValueTest.java +++ b/src/test/java/com/ezylang/evalex/data/EvaluationValueTest.java @@ -540,6 +540,24 @@ void testNull() { assertDataIsCorrect(value, null, null, null); } + @Test + @SuppressWarnings("removal") + void testDeprecatedConstructor() { + ExpressionConfiguration expressionConfiguration = + ExpressionConfiguration.builder().mathContext(new MathContext(3)).build(); + EvaluationValue evaluationValue = + new EvaluationValue(3.9876, expressionConfiguration); // NOSONAR - deprecated + assertThat(evaluationValue.getNumberValue()).isEqualByComparingTo("3.99"); + } + + @Test + @SuppressWarnings("removal") + void testNullValueSameInstance() { + EvaluationValue nullValue1 = EvaluationValue.nullValue(); // NOSONAR - deprecated + EvaluationValue nullValue2 = EvaluationValue.nullValue(); // NOSONAR - deprecated + assertThat(nullValue1).isSameAs(nullValue2); + } + @Test void nestedEvaluationValue() throws EvaluationException, ParseException { EvaluationValue value1 = EvaluationValue.of("Hello", defaultConfiguration()); @@ -557,26 +575,6 @@ void nestedEvaluationValue() throws EvaluationException, ParseException { assertThat(result.getBooleanValue()).isTrue(); } - @Test - @SuppressWarnings("removal") - void testDeprecatedDoubleMathContext() { - EvaluationValue evaluationValue64 = - new EvaluationValue(3.9876, MathContext.DECIMAL64); // NOSONAR - deprecated - assertThat(evaluationValue64.getNumberValue()).isEqualByComparingTo("3.9876"); - - EvaluationValue evaluationValue3 = - new EvaluationValue(3.9876, new MathContext(3)); // NOSONAR - deprecated - assertThat(evaluationValue3.getNumberValue()).isEqualByComparingTo("3.99"); - } - - @Test - @SuppressWarnings("removal") - void testDeprecatedConstructor() { - EvaluationValue value = new EvaluationValue("124"); // NOSONAR - deprecated - assertThat(value.isStringValue()).isTrue(); - assertThat(value.getStringValue()).isEqualTo("124"); - } - private void assertDataIsCorrect( EvaluationValue value, String stringValue, BigDecimal numberValue, Boolean booleanValue) { assertThat(value.getStringValue()).isEqualTo(stringValue);