Skip to content

Commit b088abf

Browse files
committed
Moved custom config cases to another method
1 parent fedbf4f commit b088abf

File tree

8 files changed

+28
-24
lines changed

8 files changed

+28
-24
lines changed

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/TestCaseSupplier.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,6 +1795,16 @@ public Object extra() {
17951795
return extra;
17961796
}
17971797

1798+
/**
1799+
* Build a new {@link TestCase} with the {@link #TEST_CONFIGURATION}.
1800+
*
1801+
* @deprecated Use a custom configuration instead, and test the results.
1802+
*/
1803+
@Deprecated
1804+
public TestCase withStaticConfiguration() {
1805+
return withConfiguration(TEST_CONFIGURATION);
1806+
}
1807+
17981808
/**
17991809
* Build a new {@link TestCase} with new {@link #configuration}.
18001810
*/

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateExtractTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public static Iterable<Object[]> parameters() {
5656
"DateExtractMillisEvaluator[value=Attribute[channel=1], chronoField=Attribute[channel=0], zone=Z]",
5757
DataType.LONG,
5858
equalTo(2023L)
59-
).withConfiguration(TestCaseSupplier.TEST_CONFIGURATION)
59+
).withStaticConfiguration()
6060
),
6161
new TestCaseSupplier(
6262
List.of(stringType, DataType.DATE_NANOS),
@@ -68,7 +68,7 @@ public static Iterable<Object[]> parameters() {
6868
"DateExtractNanosEvaluator[value=Attribute[channel=1], chronoField=Attribute[channel=0], zone=Z]",
6969
DataType.LONG,
7070
equalTo(2023L)
71-
).withConfiguration(TestCaseSupplier.TEST_CONFIGURATION)
71+
).withStaticConfiguration()
7272
),
7373
new TestCaseSupplier(
7474
List.of(stringType, DataType.DATE_NANOS),
@@ -80,7 +80,7 @@ public static Iterable<Object[]> parameters() {
8080
"DateExtractNanosEvaluator[value=Attribute[channel=1], chronoField=Attribute[channel=0], zone=Z]",
8181
DataType.LONG,
8282
equalTo(123456L)
83-
).withConfiguration(TestCaseSupplier.TEST_CONFIGURATION)
83+
).withStaticConfiguration()
8484
),
8585
new TestCaseSupplier(
8686
List.of(stringType, DataType.DATETIME),
@@ -93,7 +93,7 @@ public static Iterable<Object[]> parameters() {
9393
"DateExtractMillisEvaluator[value=Attribute[channel=1], chronoField=Attribute[channel=0], zone=Z]",
9494
DataType.LONG,
9595
is(nullValue())
96-
).withConfiguration(TestCaseSupplier.TEST_CONFIGURATION)
96+
).withStaticConfiguration()
9797
.withWarning(
9898
"Line 1:1: evaluation of [source] failed, treating result as null. Only first 20 failures recorded."
9999
)

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateFormatTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public static Iterable<Object[]> parameters() {
8484
(value) -> new BytesRef(EsqlDataTypeConverter.DEFAULT_DATE_TIME_FORMATTER.formatNanos(DateUtils.toLong((Instant) value))),
8585
List.of()
8686
);
87-
suppliers = TestCaseSupplier.mapTestCases(suppliers, testCase -> testCase.withConfiguration(TestCaseSupplier.TEST_CONFIGURATION));
87+
suppliers = TestCaseSupplier.mapTestCases(suppliers, testCase -> testCase.withStaticConfiguration());
8888
return parameterSuppliersFromTypedDataWithDefaultChecks(true, suppliers);
8989
}
9090

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DayNameTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static Iterable<Object[]> parameters() {
6262
Matchers.startsWith("DayNameMillisEvaluator[val=Attribute[channel=0], zoneId=Z, locale=en_US]"),
6363
DataType.KEYWORD,
6464
equalTo(null)
65-
).withConfiguration(TestCaseSupplier.TEST_CONFIGURATION)
65+
).withStaticConfiguration()
6666
)
6767
);
6868

@@ -78,7 +78,7 @@ private static List<TestCaseSupplier> generateTest(String dateTime, String expec
7878
Matchers.startsWith("DayNameMillisEvaluator[val=Attribute[channel=0], zoneId=Z, locale=en_US]"),
7979
DataType.KEYWORD,
8080
equalTo(new BytesRef(expectedWeekDay))
81-
).withConfiguration(TestCaseSupplier.TEST_CONFIGURATION)
81+
).withStaticConfiguration()
8282
),
8383
new TestCaseSupplier(
8484
List.of(DataType.DATE_NANOS),
@@ -87,7 +87,7 @@ private static List<TestCaseSupplier> generateTest(String dateTime, String expec
8787
Matchers.is("DayNameNanosEvaluator[val=Attribute[channel=0], zoneId=Z, locale=en_US]"),
8888
DataType.KEYWORD,
8989
equalTo(new BytesRef(expectedWeekDay))
90-
).withConfiguration(TestCaseSupplier.TEST_CONFIGURATION)
90+
).withStaticConfiguration()
9191
)
9292
);
9393
}

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/MonthNameTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public static Iterable<Object[]> parameters() {
7272
Matchers.startsWith("MonthNameMillisEvaluator[val=Attribute[channel=0], zoneId=Z, locale=en_US]"),
7373
DataType.KEYWORD,
7474
equalTo(null)
75-
).withConfiguration(TestCaseSupplier.TEST_CONFIGURATION)
75+
).withStaticConfiguration()
7676
)
7777
);
7878

@@ -88,7 +88,7 @@ private static List<TestCaseSupplier> generateTest(String dateTime, String expec
8888
Matchers.startsWith("MonthNameMillisEvaluator[val=Attribute[channel=0], zoneId=Z, locale=en_US]"),
8989
DataType.KEYWORD,
9090
equalTo(new BytesRef(expectedMonthName))
91-
).withConfiguration(TestCaseSupplier.TEST_CONFIGURATION)
91+
).withStaticConfiguration()
9292
),
9393
new TestCaseSupplier(
9494
List.of(DataType.DATE_NANOS),
@@ -97,7 +97,7 @@ private static List<TestCaseSupplier> generateTest(String dateTime, String expec
9797
Matchers.is("MonthNameNanosEvaluator[val=Attribute[channel=0], zoneId=Z, locale=en_US]"),
9898
DataType.KEYWORD,
9999
equalTo(new BytesRef(expectedMonthName))
100-
).withConfiguration(TestCaseSupplier.TEST_CONFIGURATION)
100+
).withStaticConfiguration()
101101
)
102102
);
103103
}

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/NowTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static Iterable<Object[]> parameters() {
4242
matchesPattern("LiteralsEvaluator\\[lit=.*]"),
4343
DataType.DATETIME,
4444
equalTo(TestCaseSupplier.TEST_CONFIGURATION.now().toInstant().toEpochMilli())
45-
).withConfiguration(TestCaseSupplier.TEST_CONFIGURATION)
45+
).withStaticConfiguration()
4646
)
4747
)
4848
);

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToLowerTests.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,8 @@ private static void suppliers(List<TestCaseSupplier> suppliers, String name, Dat
9191
values.add(new TestCaseSupplier.TypedData(new BytesRef(value), type, "0"));
9292

9393
String expectedValue = value.toLowerCase(EsqlTestUtils.TEST_CFG.locale());
94-
return new TestCaseSupplier.TestCase(values, expectedToString, type, equalTo(new BytesRef(expectedValue))).withConfiguration(
95-
TestCaseSupplier.TEST_CONFIGURATION
96-
);
94+
return new TestCaseSupplier.TestCase(values, expectedToString, type, equalTo(new BytesRef(expectedValue)))
95+
.withStaticConfiguration();
9796
}));
9897
suppliers.add(new TestCaseSupplier(name + " mv", List.of(type), () -> {
9998
List<TestCaseSupplier.TypedData> values = new ArrayList<>();
@@ -103,9 +102,7 @@ private static void suppliers(List<TestCaseSupplier> suppliers, String name, Dat
103102
values.add(new TestCaseSupplier.TypedData(strings.stream().map(BytesRef::new).toList(), type, "0"));
104103

105104
List<BytesRef> expectedValue = strings.stream().map(s -> new BytesRef(s.toLowerCase(EsqlTestUtils.TEST_CFG.locale()))).toList();
106-
return new TestCaseSupplier.TestCase(values, expectedToString, type, equalTo(expectedValue)).withConfiguration(
107-
TestCaseSupplier.TEST_CONFIGURATION
108-
);
105+
return new TestCaseSupplier.TestCase(values, expectedToString, type, equalTo(expectedValue)).withStaticConfiguration();
109106
}));
110107
}
111108

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToUpperTests.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,8 @@ private static void supplier(List<TestCaseSupplier> suppliers, String name, Data
9191
values.add(new TestCaseSupplier.TypedData(new BytesRef(value), type, "0"));
9292

9393
String expectedValue = value.toUpperCase(EsqlTestUtils.TEST_CFG.locale());
94-
return new TestCaseSupplier.TestCase(values, expectedToString, type, equalTo(new BytesRef(expectedValue))).withConfiguration(
95-
TestCaseSupplier.TEST_CONFIGURATION
96-
);
94+
return new TestCaseSupplier.TestCase(values, expectedToString, type, equalTo(new BytesRef(expectedValue)))
95+
.withStaticConfiguration();
9796
}));
9897
suppliers.add(new TestCaseSupplier(name + " mv", List.of(type), () -> {
9998
List<TestCaseSupplier.TypedData> values = new ArrayList<>();
@@ -103,9 +102,7 @@ private static void supplier(List<TestCaseSupplier> suppliers, String name, Data
103102
values.add(new TestCaseSupplier.TypedData(strings.stream().map(BytesRef::new).toList(), type, "0"));
104103

105104
List<BytesRef> expectedValue = strings.stream().map(s -> new BytesRef(s.toUpperCase(EsqlTestUtils.TEST_CFG.locale()))).toList();
106-
return new TestCaseSupplier.TestCase(values, expectedToString, type, equalTo(expectedValue)).withConfiguration(
107-
TestCaseSupplier.TEST_CONFIGURATION
108-
);
105+
return new TestCaseSupplier.TestCase(values, expectedToString, type, equalTo(expectedValue)).withStaticConfiguration();
109106
}));
110107
}
111108

0 commit comments

Comments
 (0)