Skip to content

Commit

Permalink
Remove warnings from JUnit classes (#472)
Browse files Browse the repository at this point in the history
  • Loading branch information
oswaldobapvicjr authored May 11, 2024
1 parent 3a5a957 commit 902648e
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,9 @@ void testDefaultConstants(String expression, String expectedResult)
@Test
void testCustomConstantsMixedCase() throws EvaluationException, ParseException {
Map<String, EvaluationValue> constants =
new HashMap<>() {
{
put("A", EvaluationValue.numberValue(new BigDecimal("2.5")));
put("B", EvaluationValue.numberValue(new BigDecimal("3.9")));
}
};
Map.of(
"A", EvaluationValue.numberValue(new BigDecimal("2.5")),
"B", EvaluationValue.numberValue(new BigDecimal("3.9")));

ExpressionConfiguration configuration =
ExpressionConfiguration.builder().defaultConstants(constants).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.ezylang.evalex.data.EvaluationValue;
import com.ezylang.evalex.parser.ParseException;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -65,12 +64,7 @@ void testDefaultNoRoundingArray() throws ParseException, EvaluationException {

@Test
void testDefaultNoRoundingStructure() throws ParseException, EvaluationException {
Map<String, BigDecimal> structure =
new HashMap<>() {
{
put("b", new BigDecimal("1.12345"));
}
};
Map<String, BigDecimal> structure = Map.of("b", new BigDecimal("1.12345"));

Expression expression = createExpression("a.b").with("a", structure);

Expand Down Expand Up @@ -138,12 +132,7 @@ void testCustomRoundingDecimalsArray() throws ParseException, EvaluationExceptio
void testCustomRoundingStructure() throws ParseException, EvaluationException {
ExpressionConfiguration config =
ExpressionConfiguration.builder().decimalPlacesRounding(3).build();
Map<String, BigDecimal> structure =
new HashMap<>() {
{
put("b", new BigDecimal("1.12345"));
}
};
Map<String, BigDecimal> structure = Map.of("b", new BigDecimal("1.12345"));

Expression expression = new Expression("a.b", config).with("a", structure);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@ class ExpressionEvaluatorStructureTest extends BaseExpressionEvaluatorTest {

@Test
void testStructureScientificNumberDistinction() throws EvaluationException, ParseException {
Map<String, BigDecimal> structure =
new HashMap<>() {
{
put("environment_id", new BigDecimal(12345));
}
};
Map<String, BigDecimal> structure = Map.of("environment_id", new BigDecimal(12345));
Expression expression = new Expression("order.environment_id").with("order", structure);

assertThat(expression.evaluate().getStringValue()).isEqualTo("12345");
Expand All @@ -59,12 +54,7 @@ void testStructureScientificNumberDistinctionMultiple()

@Test
void testSimpleStructure() throws ParseException, EvaluationException {
Map<String, BigDecimal> structure =
new HashMap<>() {
{
put("b", new BigDecimal(99));
}
};
Map<String, BigDecimal> structure = Map.of("b", new BigDecimal(99));

Expression expression = createExpression("a.b").with("a", structure);

Expand All @@ -75,12 +65,7 @@ void testSimpleStructure() throws ParseException, EvaluationException {
void testTripleStructure() throws ParseException, EvaluationException {
Map<String, Map<String, BigDecimal>> structure = new HashMap<>();

Map<String, BigDecimal> subStructure =
new HashMap<>() {
{
put("c", new BigDecimal(95));
}
};
Map<String, BigDecimal> subStructure = Map.of("c", new BigDecimal(95));

structure.put("b", subStructure);

Expand Down Expand Up @@ -133,12 +118,7 @@ void testTripleStructureWithSpaces() throws ParseException, EvaluationException

@Test
void testStructureWithSpaceInNameAndArrayAccess() throws EvaluationException, ParseException {
Map<String, List<Integer>> structure =
new HashMap<>() {
{
put("b prop", Arrays.asList(1, 2, 3));
}
};
Map<String, List<Integer>> structure = Map.of("b prop", Arrays.asList(1, 2, 3));

Expression expression = createExpression("a.\"b prop\"[1]").with("a", structure);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.ezylang.evalex.operators.arithmetic.InfixPlusOperator;
import java.math.MathContext;
import java.time.ZoneId;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -135,12 +134,9 @@ void testDataAccessorSupplierReturnsNewInstance() {
@Test
void testCustomConstants() {
Map<String, EvaluationValue> constants =
new HashMap<>() {
{
put("A", EvaluationValue.stringValue("a"));
put("B", EvaluationValue.stringValue("b"));
}
};
Map.of(
"A", EvaluationValue.stringValue("a"),
"B", EvaluationValue.stringValue("b"));
ExpressionConfiguration configuration =
ExpressionConfiguration.builder().defaultConstants(constants).build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.ezylang.evalex.parser.ParseException;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down Expand Up @@ -123,28 +122,19 @@ void testInfixEqualsStructures() throws EvaluationException, ParseException {
Expression expression = new Expression("a=b");

Map<String, BigDecimal> structure1 =
new HashMap<>() {
{
put("a", new BigDecimal(35));
put("b", new BigDecimal(99));
}
};
Map.of(
"a", new BigDecimal(35),
"b", new BigDecimal(99));

Map<String, BigDecimal> structure2 =
new HashMap<>() {
{
put("a", new BigDecimal(35));
put("b", new BigDecimal(99));
}
};
Map.of(
"a", new BigDecimal(35),
"b", new BigDecimal(99));

Map<String, BigDecimal> structure3 =
new HashMap<>() {
{
put("a", new BigDecimal(45));
put("b", new BigDecimal(99));
}
};
Map.of(
"a", new BigDecimal(45),
"b", new BigDecimal(99));

assertThat(expression.with("a", structure1).and("b", structure2).evaluate().getBooleanValue())
.isTrue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.ezylang.evalex.parser.ParseException;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down Expand Up @@ -123,28 +122,19 @@ void testInfixNotEqualsStructures() throws EvaluationException, ParseException {
Expression expression = new Expression("a!=b");

Map<String, BigDecimal> structure1 =
new HashMap<>() {
{
put("a", new BigDecimal(35));
put("b", new BigDecimal(99));
}
};
Map.of(
"a", new BigDecimal(35),
"b", new BigDecimal(99));

Map<String, BigDecimal> structure2 =
new HashMap<>() {
{
put("a", new BigDecimal(35));
put("b", new BigDecimal(99));
}
};
Map.of(
"a", new BigDecimal(35),
"b", new BigDecimal(99));

Map<String, BigDecimal> structure3 =
new HashMap<>() {
{
put("a", new BigDecimal(45));
put("b", new BigDecimal(99));
}
};
Map.of(
"a", new BigDecimal(45),
"b", new BigDecimal(99));

assertThat(expression.with("a", structure1).and("b", structure2).evaluate().getBooleanValue())
.isFalse();
Expand Down

0 comments on commit 902648e

Please sign in to comment.