Skip to content

Commit 1c96be2

Browse files
committed
Simplify
1 parent d533408 commit 1c96be2

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

java/src/test/java/io/cucumber/cucumberexpressions/CucumberExpressionGeneratorTest.java

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.cucumber.cucumberexpressions;
22

3+
import org.jspecify.annotations.Nullable;
34
import org.junit.jupiter.api.Test;
4-
import org.junit.jupiter.params.shadow.de.siegmar.fastcsv.util.Nullable;
55

66
import java.text.DateFormat;
77
import java.text.ParseException;
@@ -14,7 +14,9 @@
1414
import java.util.Optional;
1515

1616
import static java.util.Arrays.asList;
17+
import static java.util.Collections.emptyList;
1718
import static java.util.Collections.singletonList;
19+
import static java.util.Objects.requireNonNull;
1820
import static org.junit.jupiter.api.Assertions.assertEquals;
1921
import static org.junit.jupiter.api.Assertions.fail;
2022

@@ -76,7 +78,7 @@ public void generates_expression_for_numbers_with_symbols_and_currency() {
7678
@Test
7779
public void generates_expression_for_numbers_with_text_on_both_sides() {
7880
assertExpression(
79-
"i18n", asList(),
81+
"i18n", emptyList(),
8082
"i18n");
8183
}
8284

@@ -114,7 +116,7 @@ public void numbers_only_second_argument_when_type_is_not_reserved_keyword() {
114116
"currency",
115117
"[A-Z]{3}",
116118
Currency.class,
117-
(Transformer<Currency>) Currency::getInstance
119+
(@Nullable String s) -> Currency.getInstance(requireNonNull(s))
118120
));
119121
assertExpression(
120122
"I have a {currency} account and a {currency} account", asList("currency", "currency2"),
@@ -127,7 +129,7 @@ public void does_not_suggest_parameter_type_when_surrounded_by_alphanum() {
127129
"direction",
128130
"(up|down)",
129131
String.class,
130-
(Transformer<String>) arg -> arg,
132+
(@Nullable String arg) -> arg,
131133
true,
132134
false
133135
));
@@ -142,7 +144,7 @@ public void does_suggest_parameter_type_when_surrounded_by_space() {
142144
"direction",
143145
"(up|down)",
144146
String.class,
145-
(Transformer<String>) arg -> arg,
147+
(@Nullable String arg) -> arg,
146148
true,
147149
false
148150
));
@@ -157,13 +159,13 @@ public void prefers_leftmost_match_when_there_is_overlap() {
157159
"right",
158160
"c d",
159161
String.class,
160-
(Transformer<String>) s -> s
162+
(@Nullable String arg) -> arg
161163
));
162164
parameterTypeRegistry.defineParameterType(new ParameterType<>(
163165
"left",
164166
"b c",
165167
String.class,
166-
(Transformer<String>) arg -> arg
168+
(@Nullable String arg) -> arg
167169
));
168170
assertExpression(
169171
"a {left} d e f g", singletonList("left"),
@@ -176,13 +178,13 @@ public void prefers_widest_match_when_pos_is_same() {
176178
"airport",
177179
"[A-Z]{3}",
178180
String.class,
179-
(Transformer<String>) s -> s
181+
(@Nullable String arg) -> arg
180182
));
181183
parameterTypeRegistry.defineParameterType(new ParameterType<>(
182184
"leg",
183185
"[A-Z]{3}-[A-Z]{3}",
184186
String.class,
185-
(Transformer<String>) s -> s
187+
(@Nullable String arg) -> arg
186188
));
187189
assertExpression(
188190
"leg {leg}", singletonList("leg"),
@@ -195,7 +197,7 @@ public void generates_all_combinations_of_expressions_when_several_parameter_typ
195197
"currency",
196198
"x",
197199
Currency.class,
198-
(Transformer<Currency>) Currency::getInstance,
200+
(@Nullable String s) -> Currency.getInstance(requireNonNull(s)),
199201
true,
200202
true
201203
));
@@ -248,15 +250,15 @@ public void matches_parameter_types_with_optional_capture_groups() {
248250
"optional-flight",
249251
"(1st flight)?",
250252
String.class,
251-
(Transformer<String>) arg -> arg,
253+
(@Nullable String arg) -> arg,
252254
true,
253255
false
254256
);
255257
ParameterType<String> optionalHotel = new ParameterType<>(
256258
"optional-hotel",
257259
"(1 hotel)?",
258260
String.class,
259-
(Transformer<String>) arg -> arg,
261+
(@Nullable String arg) -> arg,
260262
true,
261263
false
262264
);
@@ -274,7 +276,7 @@ public void generates_at_most_256_expressions() {
274276
"my-type-" + i,
275277
"[a-z]",
276278
String.class,
277-
(Transformer<String>) arg -> arg,
279+
(@Nullable String arg) -> arg,
278280
true,
279281
false
280282
);
@@ -291,7 +293,7 @@ public void prefers_expression_with_longest_non_empty_match() {
291293
"zero-or-more",
292294
"[a-z]*",
293295
String.class,
294-
(Transformer<String>) arg -> arg,
296+
(@Nullable String arg) -> arg,
295297
true,
296298
false
297299
);
@@ -300,7 +302,7 @@ public void prefers_expression_with_longest_non_empty_match() {
300302
"exactly-one",
301303
"[a-z]",
302304
String.class,
303-
(Transformer<String>) arg -> arg,
305+
(@Nullable String arg) -> arg,
304306
true,
305307
false
306308
);

0 commit comments

Comments
 (0)