11package com .baeldung .spring .drools .service ;
22
3+ import com .baeldung .spring .drools .model .Fare ;
4+ import com .baeldung .spring .drools .model .TaxiRide ;
35import org .junit .Assert ;
4- import org .junit .Before ;
56import org .junit .Test ;
67import org .junit .runner .RunWith ;
78import org .springframework .beans .factory .annotation .Autowired ;
8- import org .springframework .context .ApplicationContext ;
9- import org .springframework .context .annotation .AnnotationConfigApplicationContext ;
109import org .springframework .test .context .ContextConfiguration ;
1110import org .springframework .test .context .junit4 .SpringJUnit4ClassRunner ;
12- import org .springframework .test .context .support .AnnotationConfigContextLoader ;
1311
14- import com . baeldung . spring . drools . model . TaxiRide ;
15- import com . baeldung . spring . drools . model . Fare ;
12+ import static org . junit . Assert . assertEquals ;
13+ import static org . junit . Assert . assertNotNull ;
1614
1715@ RunWith (SpringJUnit4ClassRunner .class )
1816@ ContextConfiguration (classes = TaxiFareConfiguration .class )
1917public class TaxiFareCalculatorServiceTest {
2018
2119 @ Autowired
22- TaxiFareCalculatorService taxiFareCalculatorService ;
20+ private TaxiFareCalculatorService taxiFareCalculatorService ;
2321
2422 @ Test
2523 public void testCalculateFareScenario1 () {
@@ -28,19 +26,21 @@ public void testCalculateFareScenario1() {
2826 taxiRide .setDistanceInMile (9L );
2927 Fare rideFare = new Fare ();
3028 Long totalCharge = taxiFareCalculatorService .calculateFare (taxiRide , rideFare );
31- Assert .assertNotNull (totalCharge );
32- Assert .assertEquals (Long .valueOf (70 ), totalCharge );
29+
30+ assertNotNull (totalCharge );
31+ assertEquals (Long .valueOf (70 ), totalCharge );
3332 }
34-
33+
3534 @ Test
3635 public void testCalculateFareScenario2 () {
3736 TaxiRide taxiRide = new TaxiRide ();
3837 taxiRide .setbNightSurcharge (true );
3938 taxiRide .setDistanceInMile (5L );
4039 Fare rideFare = new Fare ();
4140 Long totalCharge = taxiFareCalculatorService .calculateFare (taxiRide , rideFare );
42- Assert .assertNotNull (totalCharge );
43- Assert .assertEquals (Long .valueOf (100 ), totalCharge );
41+
42+ assertNotNull (totalCharge );
43+ assertEquals (Long .valueOf (100 ), totalCharge );
4444 }
4545
4646 @ Test
@@ -50,41 +50,45 @@ public void testCalculateFareScenario3() {
5050 taxiRide .setDistanceInMile (50L );
5151 Fare rideFare = new Fare ();
5252 Long totalCharge = taxiFareCalculatorService .calculateFare (taxiRide , rideFare );
53- Assert .assertNotNull (totalCharge );
54- Assert .assertEquals (Long .valueOf (170 ), totalCharge );
53+
54+ assertNotNull (totalCharge );
55+ assertEquals (Long .valueOf (170 ), totalCharge );
5556 }
56-
57+
5758 @ Test
5859 public void testCalculateFareScenario4 () {
5960 TaxiRide taxiRide = new TaxiRide ();
6061 taxiRide .setbNightSurcharge (true );
6162 taxiRide .setDistanceInMile (50L );
6263 Fare rideFare = new Fare ();
6364 Long totalCharge = taxiFareCalculatorService .calculateFare (taxiRide , rideFare );
64- Assert .assertNotNull (totalCharge );
65- Assert .assertEquals (Long .valueOf (250 ), totalCharge );
65+
66+ assertNotNull (totalCharge );
67+ assertEquals (Long .valueOf (250 ), totalCharge );
6668 }
67-
69+
6870 @ Test
6971 public void testCalculateFareScenario5 () {
7072 TaxiRide taxiRide = new TaxiRide ();
7173 taxiRide .setbNightSurcharge (false );
7274 taxiRide .setDistanceInMile (100L );
7375 Fare rideFare = new Fare ();
7476 Long totalCharge = taxiFareCalculatorService .calculateFare (taxiRide , rideFare );
75- Assert .assertNotNull (totalCharge );
76- Assert .assertEquals (Long .valueOf (220 ), totalCharge );
77+
78+ assertNotNull (totalCharge );
79+ assertEquals (Long .valueOf (220 ), totalCharge );
7780 }
78-
81+
7982 @ Test
8083 public void testCalculateFareScenario6 () {
8184 TaxiRide taxiRide = new TaxiRide ();
8285 taxiRide .setbNightSurcharge (true );
8386 taxiRide .setDistanceInMile (100L );
8487 Fare rideFare = new Fare ();
8588 Long totalCharge = taxiFareCalculatorService .calculateFare (taxiRide , rideFare );
86- Assert .assertNotNull (totalCharge );
87- Assert .assertEquals (Long .valueOf (350 ), totalCharge );
89+
90+ assertNotNull (totalCharge );
91+ assertEquals (Long .valueOf (350 ), totalCharge );
8892 }
89-
93+
9094}
0 commit comments