package com.rules; import junit.framework.TestCase; import com.booking.*; /* * JUnit test for the business rules in the * application. * * This also acts a 'simulator' for the business * rules - allowing us to specify the inputs, * examine the outputs and see if they match our * expectations before letting the code loose in * the real world. */ public class PricingRulesTest extends TestCase { /** * Tests fare calculation */ public void testGeneratePrice() throws Exception{ //Run the rules PricingRules pr = new PricingRules(); Reservation res = new Reservation(); res.setAccommodation("SUPERVALUE"); res.setBookingDate(new java.util.Date()); res.setOrigin("MNL"); res.setDestination("CTC"); res.setIsSeniorCitizen("Y"); Booking book = pr.generatePrice(res); System.out.println("applicable rate: "+ book.getApplicableRate()); System.out.println("highest disc: "+ book.getHighestDiscount()); //Is it what we expected? assertTrue( book.getHighestDiscount() == 600.00); } public static void main(String[] args) { PricingRulesTest priceTest = new PricingRulesTest(); try { priceTest.testGeneratePrice(); } catch (Exception e) { e.printStackTrace(); } } }