Review Comment Incorporation
This commit is contained in:
committed by
mokhan
parent
db2bb252de
commit
5d7e0bc531
+23
-28
@@ -1,92 +1,87 @@
|
||||
package com.baeldung.spring.drools.service;
|
||||
|
||||
import com.baeldung.spring.drools.model.Fare;
|
||||
import com.baeldung.spring.drools.model.TaxiRide;
|
||||
import org.junit.Assert;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import com.baeldung.spring.drools.model.Fare;
|
||||
import com.baeldung.spring.drools.model.TaxiRide;
|
||||
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = TaxiFareConfiguration.class)
|
||||
public class TaxiFareCalculatorServiceIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private TaxiFareCalculatorService taxiFareCalculatorService;
|
||||
TaxiFareCalculatorService taxiFareCalculatorService;
|
||||
|
||||
@Test
|
||||
public void testCalculateFareScenario1() {
|
||||
public void whenNightSurchargeFalseAndDistanceLessThan10_thenFixFareWithoutNightSurcharge() {
|
||||
TaxiRide taxiRide = new TaxiRide();
|
||||
taxiRide.setbNightSurcharge(false);
|
||||
taxiRide.setIsNightSurcharge(false);
|
||||
taxiRide.setDistanceInMile(9L);
|
||||
Fare rideFare = new Fare();
|
||||
Long totalCharge = taxiFareCalculatorService.calculateFare(taxiRide, rideFare);
|
||||
|
||||
assertNotNull(totalCharge);
|
||||
assertEquals(Long.valueOf(70), totalCharge);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCalculateFareScenario2() {
|
||||
public void whenNightSurchargeTrueAndDistanceLessThan10_thenFixFareWithNightSurcharge() {
|
||||
TaxiRide taxiRide = new TaxiRide();
|
||||
taxiRide.setbNightSurcharge(true);
|
||||
taxiRide.setIsNightSurcharge(true);
|
||||
taxiRide.setDistanceInMile(5L);
|
||||
Fare rideFare = new Fare();
|
||||
Long totalCharge = taxiFareCalculatorService.calculateFare(taxiRide, rideFare);
|
||||
|
||||
assertNotNull(totalCharge);
|
||||
assertEquals(Long.valueOf(100), totalCharge);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCalculateFareScenario3() {
|
||||
public void whenNightSurchargeFalseAndDistanceLessThan100_thenDoubleFareWithoutNightSurcharge() {
|
||||
TaxiRide taxiRide = new TaxiRide();
|
||||
taxiRide.setbNightSurcharge(false);
|
||||
taxiRide.setIsNightSurcharge(false);
|
||||
taxiRide.setDistanceInMile(50L);
|
||||
Fare rideFare = new Fare();
|
||||
Long totalCharge = taxiFareCalculatorService.calculateFare(taxiRide, rideFare);
|
||||
|
||||
assertNotNull(totalCharge);
|
||||
assertEquals(Long.valueOf(170), totalCharge);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCalculateFareScenario4() {
|
||||
public void whenNightSurchargeTrueAndDistanceLessThan100_thenDoubleFareWithNightSurcharge() {
|
||||
TaxiRide taxiRide = new TaxiRide();
|
||||
taxiRide.setbNightSurcharge(true);
|
||||
taxiRide.setIsNightSurcharge(true);
|
||||
taxiRide.setDistanceInMile(50L);
|
||||
Fare rideFare = new Fare();
|
||||
Long totalCharge = taxiFareCalculatorService.calculateFare(taxiRide, rideFare);
|
||||
|
||||
assertNotNull(totalCharge);
|
||||
assertEquals(Long.valueOf(250), totalCharge);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCalculateFareScenario5() {
|
||||
public void whenNightSurchargeFalseAndDistanceGreaterThan100_thenExtraPercentFareWithoutNightSurcharge() {
|
||||
TaxiRide taxiRide = new TaxiRide();
|
||||
taxiRide.setbNightSurcharge(false);
|
||||
taxiRide.setIsNightSurcharge(false);
|
||||
taxiRide.setDistanceInMile(100L);
|
||||
Fare rideFare = new Fare();
|
||||
Long totalCharge = taxiFareCalculatorService.calculateFare(taxiRide, rideFare);
|
||||
|
||||
assertNotNull(totalCharge);
|
||||
assertEquals(Long.valueOf(220), totalCharge);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCalculateFareScenario6() {
|
||||
public void whenNightSurchargeTrueAndDistanceGreaterThan100_thenExtraPercentFareWithNightSurcharge() {
|
||||
TaxiRide taxiRide = new TaxiRide();
|
||||
taxiRide.setbNightSurcharge(true);
|
||||
taxiRide.setIsNightSurcharge(true);
|
||||
taxiRide.setDistanceInMile(100L);
|
||||
Fare rideFare = new Fare();
|
||||
Long totalCharge = taxiFareCalculatorService.calculateFare(taxiRide, rideFare);
|
||||
|
||||
assertNotNull(totalCharge);
|
||||
assertEquals(Long.valueOf(350), totalCharge);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user