16
16
import io .cucumber .core .gherkin .Feature ;
17
17
import io .cucumber .core .gherkin .Step ;
18
18
import io .cucumber .core .runtime .TimeServiceEventBus ;
19
- import io .cucumber .core .stepexpression .StepTypeRegistry ;
20
19
import io .cucumber .cucumberexpressions .ParameterByTypeTransformer ;
21
20
import io .cucumber .cucumberexpressions .ParameterType ;
22
21
import io .cucumber .datatable .DataTable ;
33
32
import java .time .Clock ;
34
33
import java .util .ArrayList ;
35
34
import java .util .List ;
35
+ import java .util .Locale ;
36
36
import java .util .Optional ;
37
37
import java .util .UUID ;
38
38
import java .util .stream .Collectors ;
53
53
54
54
class CachingGlueTest {
55
55
56
- private final StepTypeRegistry stepTypeRegistry = new StepTypeRegistry ( ENGLISH ) ;
56
+ public static final Locale LANGUAGE = ENGLISH ;
57
57
private final CachingGlue glue = new CachingGlue (new TimeServiceEventBus (Clock .systemUTC (), UUID ::randomUUID ));
58
58
59
59
@ Test
@@ -70,7 +70,7 @@ void throws_duplicate_error_on_dupe_stepdefs() {
70
70
71
71
DuplicateStepDefinitionException exception = assertThrows (
72
72
DuplicateStepDefinitionException .class ,
73
- () -> glue .prepareGlue (stepTypeRegistry ));
73
+ () -> glue .prepareGlue (LANGUAGE ));
74
74
assertThat (exception .getMessage (), equalTo ("Duplicate step definitions in foo.bf:10 and bar.bf:90" ));
75
75
}
76
76
@@ -81,7 +81,7 @@ void throws_on_duplicate_default_parameter_transformer() {
81
81
82
82
DuplicateDefaultParameterTransformers exception = assertThrows (
83
83
DuplicateDefaultParameterTransformers .class ,
84
- () -> glue .prepareGlue (stepTypeRegistry ));
84
+ () -> glue .prepareGlue (LANGUAGE ));
85
85
assertThat (exception .getMessage (), equalTo ("" +
86
86
"There may not be more then one default parameter transformer. Found:\n " +
87
87
" - mocked default parameter transformer\n " +
@@ -95,7 +95,7 @@ void throws_on_duplicate_default_table_entry_transformer() {
95
95
96
96
DuplicateDefaultDataTableEntryTransformers exception = assertThrows (
97
97
DuplicateDefaultDataTableEntryTransformers .class ,
98
- () -> glue .prepareGlue (stepTypeRegistry ));
98
+ () -> glue .prepareGlue (LANGUAGE ));
99
99
assertThat (exception .getMessage (), equalTo ("" +
100
100
"There may not be more then one default data table entry. Found:\n " +
101
101
" - mocked default data table entry transformer\n " +
@@ -109,7 +109,7 @@ void throws_on_duplicate_default_table_cell_transformer() {
109
109
110
110
DuplicateDefaultDataTableCellTransformers exception = assertThrows (
111
111
DuplicateDefaultDataTableCellTransformers .class ,
112
- () -> glue .prepareGlue (stepTypeRegistry ));
112
+ () -> glue .prepareGlue (LANGUAGE ));
113
113
assertThat (exception .getMessage (), equalTo ("" +
114
114
"There may not be more then one default table cell transformers. Found:\n " +
115
115
" - mocked default data table cell transformer\n " +
@@ -135,7 +135,7 @@ void removes_glue_that_is_scenario_scoped() {
135
135
glue .addDefaultDataTableCellTransformer (new MockedDefaultDataTableCellTransformer ());
136
136
glue .addDefaultDataTableEntryTransformer (new MockedDefaultDataTableEntryTransformer ());
137
137
138
- glue .prepareGlue (stepTypeRegistry );
138
+ glue .prepareGlue (LANGUAGE );
139
139
140
140
assertAll (
141
141
() -> assertThat (glue .getStepDefinitions ().size (), is (equalTo (1 ))),
@@ -191,7 +191,7 @@ void returns_match_from_cache_if_single_found() throws AmbiguousStepDefinitionsE
191
191
StepDefinition stepDefinition2 = new MockedStepDefinition ("^pattern2" );
192
192
glue .addStepDefinition (stepDefinition1 );
193
193
glue .addStepDefinition (stepDefinition2 );
194
- glue .prepareGlue (stepTypeRegistry );
194
+ glue .prepareGlue (LANGUAGE );
195
195
196
196
URI uri = URI .create ("file:path/to.feature" );
197
197
String stepText = "pattern1" ;
@@ -219,7 +219,7 @@ void returns_match_from_cache_for_step_with_table() throws AmbiguousStepDefiniti
219
219
StepDefinition stepDefinition2 = new MockedStepDefinition ("^pattern2" , DataTable .class );
220
220
glue .addStepDefinition (stepDefinition1 );
221
221
glue .addStepDefinition (stepDefinition2 );
222
- glue .prepareGlue (stepTypeRegistry );
222
+ glue .prepareGlue (LANGUAGE );
223
223
224
224
URI uri = URI .create ("file:path/to.feature" );
225
225
String stepText = "pattern1" ;
@@ -260,7 +260,7 @@ void returns_match_from_cache_for_ste_with_doc_string() throws AmbiguousStepDefi
260
260
StepDefinition stepDefinition2 = new MockedStepDefinition ("^pattern2" , String .class );
261
261
glue .addStepDefinition (stepDefinition1 );
262
262
glue .addStepDefinition (stepDefinition2 );
263
- glue .prepareGlue (stepTypeRegistry );
263
+ glue .prepareGlue (LANGUAGE );
264
264
265
265
URI uri = URI .create ("file:path/to.feature" );
266
266
String stepText = "pattern1" ;
@@ -304,7 +304,7 @@ void returns_fresh_match_from_cache_after_evicting_scenario_scoped() throws Ambi
304
304
305
305
StepDefinition stepDefinition1 = new MockedScenarioScopedStepDefinition ("^pattern1" );
306
306
glue .addStepDefinition (stepDefinition1 );
307
- glue .prepareGlue (stepTypeRegistry );
307
+ glue .prepareGlue (LANGUAGE );
308
308
309
309
PickleStepDefinitionMatch pickleStepDefinitionMatch = glue .stepDefinitionMatch (uri , pickleStep1 );
310
310
assertThat (((CoreStepDefinition ) pickleStepDefinitionMatch .getStepDefinition ()).getStepDefinition (),
@@ -314,7 +314,7 @@ void returns_fresh_match_from_cache_after_evicting_scenario_scoped() throws Ambi
314
314
315
315
StepDefinition stepDefinition2 = new MockedScenarioScopedStepDefinition ("^pattern1" );
316
316
glue .addStepDefinition (stepDefinition2 );
317
- glue .prepareGlue (stepTypeRegistry );
317
+ glue .prepareGlue (LANGUAGE );
318
318
319
319
PickleStepDefinitionMatch pickleStepDefinitionMatch2 = glue .stepDefinitionMatch (uri , pickleStep1 );
320
320
assertThat (((CoreStepDefinition ) pickleStepDefinitionMatch2 .getStepDefinition ()).getStepDefinition (),
@@ -347,7 +347,7 @@ void disposes_of_scenario_scoped_beans() {
347
347
MockedDefaultParameterTransformer defaultParameterTransformer = new MockedDefaultParameterTransformer ();
348
348
glue .addDefaultParameterTransformer (defaultParameterTransformer );
349
349
350
- glue .prepareGlue (stepTypeRegistry );
350
+ glue .prepareGlue (LANGUAGE );
351
351
glue .removeScenarioScopedGlue ();
352
352
353
353
assertThat (stepDefinition .isDisposed (), is (true ));
@@ -371,15 +371,15 @@ void returns_no_match_after_evicting_scenario_scoped() throws AmbiguousStepDefin
371
371
372
372
StepDefinition stepDefinition1 = new MockedScenarioScopedStepDefinition ("^pattern1" );
373
373
glue .addStepDefinition (stepDefinition1 );
374
- glue .prepareGlue (stepTypeRegistry );
374
+ glue .prepareGlue (LANGUAGE );
375
375
376
376
PickleStepDefinitionMatch pickleStepDefinitionMatch = glue .stepDefinitionMatch (uri , pickleStep1 );
377
377
assertThat (((CoreStepDefinition ) pickleStepDefinitionMatch .getStepDefinition ()).getStepDefinition (),
378
378
is (equalTo (stepDefinition1 )));
379
379
380
380
glue .removeScenarioScopedGlue ();
381
381
382
- glue .prepareGlue (stepTypeRegistry );
382
+ glue .prepareGlue (LANGUAGE );
383
383
384
384
PickleStepDefinitionMatch pickleStepDefinitionMatch2 = glue .stepDefinitionMatch (uri , pickleStep1 );
385
385
assertThat (pickleStepDefinitionMatch2 , nullValue ());
@@ -393,7 +393,7 @@ void throws_ambiguous_steps_def_exception_when_many_patterns_match() {
393
393
glue .addStepDefinition (stepDefinition1 );
394
394
glue .addStepDefinition (stepDefinition2 );
395
395
glue .addStepDefinition (stepDefinition3 );
396
- glue .prepareGlue (stepTypeRegistry );
396
+ glue .prepareGlue (LANGUAGE );
397
397
398
398
URI uri = URI .create ("file:path/to.feature" );
399
399
@@ -480,7 +480,7 @@ void emits_hook_messages_to_bus() {
480
480
glue .addBeforeStepHook (new MockedScenarioScopedHookDefinition ());
481
481
glue .addAfterStepHook (new MockedScenarioScopedHookDefinition ());
482
482
483
- glue .prepareGlue (stepTypeRegistry );
483
+ glue .prepareGlue (LANGUAGE );
484
484
assertThat (events .size (), is (4 ));
485
485
}
486
486
@@ -497,7 +497,7 @@ void parameterTypeDefinition_without_source_reference_emits_parameterType_with_e
497
497
glue .addParameterType (new MockedParameterTypeDefinition ());
498
498
499
499
// When
500
- glue .prepareGlue (stepTypeRegistry );
500
+ glue .prepareGlue (LANGUAGE );
501
501
502
502
// Then
503
503
assertThat (events .size (), is (1 ));
@@ -519,7 +519,7 @@ void parameterTypeDefinition_with_source_reference_emits_parameterType_with_non_
519
519
glue .addParameterType (new MockedParameterTypeDefinitionWithSourceReference ());
520
520
521
521
// When
522
- glue .prepareGlue (stepTypeRegistry );
522
+ glue .prepareGlue (LANGUAGE );
523
523
524
524
// Then
525
525
assertThat (events .size (), is (1 ));
0 commit comments