From df782e425b4857af670fd17b9dd73b48d6ecd2a3 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Fri, 30 Jun 2017 06:35:55 +0200 Subject: [PATCH] Reformat (#2177) --- .../baeldung/spring/drools/model/Fare.java | 7 --- .../drools/service/TaxiFareConfiguration.java | 9 ++-- .../TaxiFareCalculatorServiceTest.java | 52 ++++++++++--------- 3 files changed, 31 insertions(+), 37 deletions(-) diff --git a/spring-drools/src/main/java/com/baeldung/spring/drools/model/Fare.java b/spring-drools/src/main/java/com/baeldung/spring/drools/model/Fare.java index a67156f167..86044b281a 100644 --- a/spring-drools/src/main/java/com/baeldung/spring/drools/model/Fare.java +++ b/spring-drools/src/main/java/com/baeldung/spring/drools/model/Fare.java @@ -4,12 +4,10 @@ public class Fare { private Long nightSurcharge; private Long rideFare; - private Long totalFare; public Fare() { nightSurcharge = 0L; rideFare = 0L; - totalFare = 0L; } public Long getNightSurcharge() { @@ -31,9 +29,4 @@ public class Fare { public Long getTotalFare() { return nightSurcharge + rideFare; } - - public void setTotalFare(Long totalFare) { - this.totalFare = totalFare; - } - } diff --git a/spring-drools/src/main/java/com/baeldung/spring/drools/service/TaxiFareConfiguration.java b/spring-drools/src/main/java/com/baeldung/spring/drools/service/TaxiFareConfiguration.java index 8fed574639..8da1d4b992 100644 --- a/spring-drools/src/main/java/com/baeldung/spring/drools/service/TaxiFareConfiguration.java +++ b/spring-drools/src/main/java/com/baeldung/spring/drools/service/TaxiFareConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; @Configuration public class TaxiFareConfiguration { - public static final String drlFile = "TAXI_FARE_RULE.drl"; + private static final String drlFile = "TAXI_FARE_RULE.drl"; @Bean public KieContainer kieContainer() { @@ -25,14 +25,11 @@ public class TaxiFareConfiguration { kieBuilder.buildAll(); KieModule kieModule = kieBuilder.getKieModule(); - KieContainer kContainer = kieServices.newKieContainer(kieModule.getReleaseId()); - - return kContainer; + return kieServices.newKieContainer(kieModule.getReleaseId()); } @Bean public TaxiFareCalculatorService taxiFareCalculatorService() { - TaxiFareCalculatorService taxiFareCalculatorService = new TaxiFareCalculatorService(); - return taxiFareCalculatorService; + return new TaxiFareCalculatorService(); } } diff --git a/spring-drools/src/test/java/com/baeldung/spring/drools/service/TaxiFareCalculatorServiceTest.java b/spring-drools/src/test/java/com/baeldung/spring/drools/service/TaxiFareCalculatorServiceTest.java index 5569772c48..d329300a2b 100644 --- a/spring-drools/src/test/java/com/baeldung/spring/drools/service/TaxiFareCalculatorServiceTest.java +++ b/spring-drools/src/test/java/com/baeldung/spring/drools/service/TaxiFareCalculatorServiceTest.java @@ -1,25 +1,23 @@ 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 org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; -import com.baeldung.spring.drools.model.TaxiRide; -import com.baeldung.spring.drools.model.Fare; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = TaxiFareConfiguration.class) public class TaxiFareCalculatorServiceTest { @Autowired - TaxiFareCalculatorService taxiFareCalculatorService; + private TaxiFareCalculatorService taxiFareCalculatorService; @Test public void testCalculateFareScenario1() { @@ -28,10 +26,11 @@ public class TaxiFareCalculatorServiceTest { taxiRide.setDistanceInMile(9L); Fare rideFare = new Fare(); Long totalCharge = taxiFareCalculatorService.calculateFare(taxiRide, rideFare); - Assert.assertNotNull(totalCharge); - Assert.assertEquals(Long.valueOf(70), totalCharge); + + assertNotNull(totalCharge); + assertEquals(Long.valueOf(70), totalCharge); } - + @Test public void testCalculateFareScenario2() { TaxiRide taxiRide = new TaxiRide(); @@ -39,8 +38,9 @@ public class TaxiFareCalculatorServiceTest { taxiRide.setDistanceInMile(5L); Fare rideFare = new Fare(); Long totalCharge = taxiFareCalculatorService.calculateFare(taxiRide, rideFare); - Assert.assertNotNull(totalCharge); - Assert.assertEquals(Long.valueOf(100), totalCharge); + + assertNotNull(totalCharge); + assertEquals(Long.valueOf(100), totalCharge); } @Test @@ -50,10 +50,11 @@ public class TaxiFareCalculatorServiceTest { taxiRide.setDistanceInMile(50L); Fare rideFare = new Fare(); Long totalCharge = taxiFareCalculatorService.calculateFare(taxiRide, rideFare); - Assert.assertNotNull(totalCharge); - Assert.assertEquals(Long.valueOf(170), totalCharge); + + assertNotNull(totalCharge); + assertEquals(Long.valueOf(170), totalCharge); } - + @Test public void testCalculateFareScenario4() { TaxiRide taxiRide = new TaxiRide(); @@ -61,10 +62,11 @@ public class TaxiFareCalculatorServiceTest { taxiRide.setDistanceInMile(50L); Fare rideFare = new Fare(); Long totalCharge = taxiFareCalculatorService.calculateFare(taxiRide, rideFare); - Assert.assertNotNull(totalCharge); - Assert.assertEquals(Long.valueOf(250), totalCharge); + + assertNotNull(totalCharge); + assertEquals(Long.valueOf(250), totalCharge); } - + @Test public void testCalculateFareScenario5() { TaxiRide taxiRide = new TaxiRide(); @@ -72,10 +74,11 @@ public class TaxiFareCalculatorServiceTest { taxiRide.setDistanceInMile(100L); Fare rideFare = new Fare(); Long totalCharge = taxiFareCalculatorService.calculateFare(taxiRide, rideFare); - Assert.assertNotNull(totalCharge); - Assert.assertEquals(Long.valueOf(220), totalCharge); + + assertNotNull(totalCharge); + assertEquals(Long.valueOf(220), totalCharge); } - + @Test public void testCalculateFareScenario6() { TaxiRide taxiRide = new TaxiRide(); @@ -83,8 +86,9 @@ public class TaxiFareCalculatorServiceTest { taxiRide.setDistanceInMile(100L); Fare rideFare = new Fare(); Long totalCharge = taxiFareCalculatorService.calculateFare(taxiRide, rideFare); - Assert.assertNotNull(totalCharge); - Assert.assertEquals(Long.valueOf(350), totalCharge); + + assertNotNull(totalCharge); + assertEquals(Long.valueOf(350), totalCharge); } - + }