23
23
import com .swirlds .common .context .PlatformContext ;
24
24
import com .swirlds .common .test .fixtures .platform .TestPlatformContextBuilder ;
25
25
import com .swirlds .common .wiring .model .WiringModel ;
26
- import com .swirlds .common .wiring .schedulers .TaskScheduler ;
27
- import com .swirlds .common .wiring .schedulers .builders .TaskSchedulerType ;
26
+ import com .swirlds .common .wiring .schedulers .builders .TaskSchedulerConfiguration ;
28
27
import com .swirlds .common .wiring .wires .input .InputWire ;
29
28
import com .swirlds .common .wiring .wires .output .OutputWire ;
30
29
import edu .umd .cs .findbugs .annotations .NonNull ;
@@ -109,6 +108,7 @@ public long getRunningValue() {
109
108
}
110
109
}
111
110
111
+ @ SchedulerLabel ("actuallyCallThisSomethingDifferent" )
112
112
private interface ComponentWithListOutput {
113
113
@ NonNull
114
114
List <String > handleInputA (@ NonNull String s );
@@ -154,14 +154,11 @@ void methodNotOnComponentTest() {
154
154
155
155
final WiringModel wiringModel = WiringModel .create (platformContext , ForkJoinPool .commonPool ());
156
156
157
- final TaskScheduler <Long > scheduler = wiringModel
158
- .schedulerBuilder ("test" )
159
- .withType (TaskSchedulerType .DIRECT )
160
- .build ()
161
- .cast ();
157
+ final TaskSchedulerConfiguration schedulerConfiguration = TaskSchedulerConfiguration .parse ("DIRECT" );
162
158
163
159
final ComponentWiring <FooBarBaz , Long > fooBarBazWiring =
164
- new ComponentWiring <>(wiringModel , FooBarBaz .class , scheduler );
160
+ new ComponentWiring <>(wiringModel , FooBarBaz .class , schedulerConfiguration );
161
+ assertEquals ("FooBarBaz" , fooBarBazWiring .getSchedulerName ());
165
162
166
163
assertThrows (IllegalArgumentException .class , () -> fooBarBazWiring .getInputWire ((x , y ) -> 0L ));
167
164
assertThrows (IllegalArgumentException .class , () -> fooBarBazWiring .getInputWire ((x , y ) -> {}));
@@ -178,14 +175,11 @@ void simpleComponentTest(final int bindLocation) {
178
175
179
176
final WiringModel wiringModel = WiringModel .create (platformContext , ForkJoinPool .commonPool ());
180
177
181
- final TaskScheduler <Long > scheduler = wiringModel
182
- .schedulerBuilder ("test" )
183
- .withType (TaskSchedulerType .DIRECT )
184
- .build ()
185
- .cast ();
178
+ final TaskSchedulerConfiguration schedulerConfiguration = TaskSchedulerConfiguration .parse ("DIRECT" );
186
179
187
180
final ComponentWiring <FooBarBaz , Long > fooBarBazWiring =
188
- new ComponentWiring <>(wiringModel , FooBarBaz .class , scheduler );
181
+ new ComponentWiring <>(wiringModel , FooBarBaz .class , schedulerConfiguration );
182
+ assertEquals ("FooBarBaz" , fooBarBazWiring .getSchedulerName ());
189
183
190
184
final FooBarBazImpl fooBarBazImpl = new FooBarBazImpl ();
191
185
@@ -270,16 +264,13 @@ void transformerTest(final int bindLocation) {
270
264
271
265
final WiringModel wiringModel = WiringModel .create (platformContext , ForkJoinPool .commonPool ());
272
266
273
- final TaskScheduler <Long > scheduler = wiringModel
274
- .schedulerBuilder ("test" )
275
- .withType (TaskSchedulerType .DIRECT )
276
- .build ()
277
- .cast ();
267
+ final TaskSchedulerConfiguration schedulerConfiguration = TaskSchedulerConfiguration .parse ("DIRECT" );
278
268
279
269
final FooBarBazImpl fooBarBazImpl = new FooBarBazImpl ();
280
270
281
271
final ComponentWiring <FooBarBaz , Long > fooBarBazWiring =
282
- new ComponentWiring <>(wiringModel , FooBarBaz .class , scheduler );
272
+ new ComponentWiring <>(wiringModel , FooBarBaz .class , schedulerConfiguration );
273
+ assertEquals ("FooBarBaz" , fooBarBazWiring .getSchedulerName ());
283
274
284
275
if (bindLocation == 0 ) {
285
276
fooBarBazWiring .bind (fooBarBazImpl );
@@ -342,16 +333,13 @@ void filterTest(final int bindLocation) {
342
333
343
334
final WiringModel wiringModel = WiringModel .create (platformContext , ForkJoinPool .commonPool ());
344
335
345
- final TaskScheduler <Long > scheduler = wiringModel
346
- .schedulerBuilder ("test" )
347
- .withType (TaskSchedulerType .DIRECT )
348
- .build ()
349
- .cast ();
336
+ final TaskSchedulerConfiguration schedulerConfiguration = TaskSchedulerConfiguration .parse ("DIRECT" );
350
337
351
338
final FooBarBazImpl fooBarBazImpl = new FooBarBazImpl ();
352
339
353
340
final ComponentWiring <FooBarBaz , Long > fooBarBazWiring =
354
- new ComponentWiring <>(wiringModel , FooBarBaz .class , scheduler );
341
+ new ComponentWiring <>(wiringModel , FooBarBaz .class , schedulerConfiguration );
342
+ assertEquals ("FooBarBaz" , fooBarBazWiring .getSchedulerName ());
355
343
356
344
if (bindLocation == 0 ) {
357
345
fooBarBazWiring .bind (fooBarBazImpl );
@@ -416,14 +404,11 @@ void splitterTest(final int bindLocation) {
416
404
417
405
final WiringModel wiringModel = WiringModel .create (platformContext , ForkJoinPool .commonPool ());
418
406
419
- final TaskScheduler <List <String >> scheduler = wiringModel
420
- .schedulerBuilder ("test" )
421
- .withType (TaskSchedulerType .DIRECT )
422
- .build ()
423
- .cast ();
407
+ final TaskSchedulerConfiguration schedulerConfiguration = TaskSchedulerConfiguration .parse ("DIRECT" );
424
408
425
409
final ComponentWiring <ComponentWithListOutput , List <String >> componentWiring =
426
- new ComponentWiring <>(wiringModel , ComponentWithListOutput .class , scheduler );
410
+ new ComponentWiring <>(wiringModel , ComponentWithListOutput .class , schedulerConfiguration );
411
+ assertEquals ("actuallyCallThisSomethingDifferent" , componentWiring .getSchedulerName ());
427
412
428
413
if (bindLocation == 0 ) {
429
414
componentWiring .bind (new ComponentWithListOutputImpl ());
@@ -458,14 +443,11 @@ void filteredSplitterTest(final int bindLocation) {
458
443
459
444
final WiringModel wiringModel = WiringModel .create (platformContext , ForkJoinPool .commonPool ());
460
445
461
- final TaskScheduler <List <String >> scheduler = wiringModel
462
- .schedulerBuilder ("test" )
463
- .withType (TaskSchedulerType .DIRECT )
464
- .build ()
465
- .cast ();
446
+ final TaskSchedulerConfiguration schedulerConfiguration = TaskSchedulerConfiguration .parse ("DIRECT" );
466
447
467
448
final ComponentWiring <ComponentWithListOutput , List <String >> componentWiring =
468
- new ComponentWiring <>(wiringModel , ComponentWithListOutput .class , scheduler );
449
+ new ComponentWiring <>(wiringModel , ComponentWithListOutput .class , schedulerConfiguration );
450
+ assertEquals ("actuallyCallThisSomethingDifferent" , componentWiring .getSchedulerName ());
469
451
470
452
if (bindLocation == 0 ) {
471
453
componentWiring .bind (new ComponentWithListOutputImpl ());
@@ -509,17 +491,11 @@ void transformedSplitterTest(final int bindLocation) {
509
491
510
492
final WiringModel wiringModel = WiringModel .create (platformContext , ForkJoinPool .commonPool ());
511
493
512
- final TaskScheduler <List <String >> scheduler = wiringModel
513
- .schedulerBuilder ("test" )
514
- .withType (TaskSchedulerType .DIRECT )
515
- .withUncaughtExceptionHandler ((t , e ) -> {
516
- e .printStackTrace ();
517
- })
518
- .build ()
519
- .cast ();
494
+ final TaskSchedulerConfiguration schedulerConfiguration = TaskSchedulerConfiguration .parse ("DIRECT" );
520
495
521
496
final ComponentWiring <ComponentWithListOutput , List <String >> componentWiring =
522
- new ComponentWiring <>(wiringModel , ComponentWithListOutput .class , scheduler );
497
+ new ComponentWiring <>(wiringModel , ComponentWithListOutput .class , schedulerConfiguration );
498
+ assertEquals ("actuallyCallThisSomethingDifferent" , componentWiring .getSchedulerName ());
523
499
524
500
if (bindLocation == 0 ) {
525
501
componentWiring .bind (new ComponentWithListOutputImpl ());
0 commit comments