6
6
import org .junit .jupiter .api .Assertions ;
7
7
import org .junit .jupiter .api .Test ;
8
8
import org .junit .jupiter .api .extension .RegisterExtension ;
9
+ import org .junit .jupiter .params .ParameterizedTest ;
10
+ import org .junit .jupiter .params .provider .ValueSource ;
9
11
import org .matsim .api .core .v01 .Coord ;
10
12
import org .matsim .api .core .v01 .Id ;
11
13
import org .matsim .api .core .v01 .Scenario ;
@@ -79,7 +81,7 @@ private static List<DrivingCycleSecond> readCycle(Path path){
79
81
return drivingCycleSeconds ;
80
82
}
81
83
82
- /**
84
+ /** TODO Remove
83
85
* Reads a csv (header: time,speed,acceleration) containing a wltp cycle and converts it into a MATSim test-network, with links representing the
84
86
* phases of the cycle. The first link has its origin at (0,0) and the test-track extends into positive x.
85
87
* @param network Network to put in the links
@@ -354,8 +356,9 @@ private void testValueDeviation(List<WLTPLinkComparison> refComparison, List<WLT
354
356
}
355
357
356
358
// TODO Petrol and diesel
357
- @ Test
358
- public void test () throws IOException , URISyntaxException {
359
+ @ ParameterizedTest
360
+ @ ValueSource (strings = {"petrol" , "diesel" }) // TODO Add diesel
361
+ public void test (String fuel ) throws IOException , URISyntaxException {
359
362
// Prepare emission-config
360
363
EmissionsConfigGroup ecg = new EmissionsConfigGroup ();
361
364
ecg .setHbefaVehicleDescriptionSource ( EmissionsConfigGroup .HbefaVehicleDescriptionSource .usingVehicleTypeId );
@@ -377,14 +380,22 @@ public void test() throws IOException, URISyntaxException {
377
380
wltpLinkAttributes .add (new WLTPLinkAttributes (455 , 7158 , 27.06 , "RUR/MW/100" ));
378
381
wltpLinkAttributes .add (new WLTPLinkAttributes (323 , 8254 , 36.47 , "RUR/MW/130" ));
379
382
380
- Path dir = Paths .get (utils .getClassInputDirectory ()).resolve ("sumo_petrol_output .csv" );
383
+ Path dir = Paths .get (utils .getClassInputDirectory ()).resolve ("sumo_" + fuel + "_output .csv" );
381
384
List <PHEMTest .SumoEntry > sumoSegments = readSumoEmissionsForLinks (dir , wltpLinkAttributes );
382
385
383
386
// Define vehicle
384
387
HbefaVehicleAttributes vehicleAttributes = new HbefaVehicleAttributes ();
385
- vehicleAttributes .setHbefaTechnology ("petrol (4S)" );
386
- vehicleAttributes .setHbefaSizeClass ("average" );
387
- vehicleAttributes .setHbefaEmConcept ("PC P Euro-4" );
388
+ switch (fuel ){
389
+ case "petrol" :
390
+ vehicleAttributes .setHbefaTechnology ("petrol (4S)" );
391
+ vehicleAttributes .setHbefaEmConcept ("PC P Euro-4" );
392
+ break ;
393
+ case "diesel" :
394
+ vehicleAttributes .setHbefaTechnology ("diesel" );
395
+ vehicleAttributes .setHbefaEmConcept ("PC D Euro-4" );
396
+ break ;
397
+ }
398
+ vehicleAttributes .setHbefaSizeClass ("average" ); // TODO Fix table for final tests
388
399
Tuple <HbefaVehicleCategory , HbefaVehicleAttributes > vehHbefaInfo = new Tuple <>(
389
400
HbefaVehicleCategory .PASSENGER_CAR ,
390
401
vehicleAttributes );
@@ -459,7 +470,7 @@ public void test() throws IOException, URISyntaxException {
459
470
460
471
// Print out the results as csv
461
472
CSVPrinter writer = new CSVPrinter (
462
- IOUtils .getBufferedWriter (utils .getOutputDirectory () + "diff_out .csv" ),
473
+ IOUtils .getBufferedWriter (utils .getOutputDirectory () + "diff_" + fuel + "_out .csv" ),
463
474
CSVFormat .DEFAULT );
464
475
writer .printRecord (
465
476
"segment" ,
@@ -490,8 +501,8 @@ public void test() throws IOException, URISyntaxException {
490
501
for (int i = 0 ; i < comparison .size (); i ++){
491
502
writer .printRecord (
492
503
i ,
493
- currentSecond ,
494
- wltpLinkAttributes .get (i ).time ,
504
+ comparison . get ( i ). startTime ,
505
+ comparison .get (i ).travelTime ,
495
506
496
507
comparison .get (i ).CO [0 ],
497
508
comparison .get (i ).CO [1 ],
@@ -523,7 +534,7 @@ public void test() throws IOException, URISyntaxException {
523
534
writer .close ();
524
535
525
536
// Start the tests
526
- var refComparison = readReferenceComparison (Paths .get (utils .getClassInputDirectory ()).resolve ("diff_ref .csv" ));
537
+ var refComparison = readReferenceComparison (Paths .get (utils .getClassInputDirectory ()).resolve ("diff_" + fuel + "_ref .csv" ));
527
538
testHbefaV4_1 (refComparison , comparison );
528
539
testValueDeviation (refComparison , comparison );
529
540
0 commit comments