Closed zohaibbadarpura closed 5 years ago
Now there are two possible ways to debug this issue:-
Unit Test
package hotel;
import static org.junit.Assert.*;
import java.util.Date;
import java.util.List;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import hotel.credit.CreditCard;
import hotel.credit.CreditCardType;
import hotel.entities.Booking;
import hotel.entities.Guest;
import hotel.entities.Room;
import hotel.entities.RoomType;
import hotel.entities.ServiceCharge;
import hotel.entities.ServiceType;
public class CheckoutServiceCostTesting {
static Booking bookingTest;
static Guest guest;
static Room room;
static Date bookedArrival;
static int stayLength;
static int numberOfOccupants;
static long confirmationNumber;
static CreditCard testCreditCard;
static CreditCardType type;
static int creditcardNumber = 555555555;
static int ccv;
static int roomId;
static List <ServiceCharge> actualCharge;
@BeforeClass
public static void beforeClass() {
bookedArrival = new Date();
stayLength = 10;
numberOfOccupants=2;
roomId = 1234;
type = type.VISA;
ccv = 786;
testCreditCard = new CreditCard(type, creditcardNumber, ccv);
guest = new Guest("Adrian", "Melburn", 123456);
room = new Room(roomId, RoomType.SINGLE);
}
@AfterClass
public static void tearDownAfterClass() {
}
@Before
public void setUp(){
bookingTest = new Booking (guest, room, bookedArrival, stayLength, numberOfOccupants, testCreditCard);
}
@After
public void tearDown(){
bookingTest = null;
}
@Test
public void testCheckoutServiceCost(){
double actualServiceCost = 45.6;
bookingTest.addServiceCharge(ServiceType.ROOM_SERVICE, actualServiceCost);
bookingTest.checkOut();
assertEquals(bookingTest.getCharges().get(0).getCost(), actualServiceCost, 0.0000);
}
}
Using this test case, I came to know that value being return by the following function is 0.0 $
public double getCost() {
return cost;
}
Which means that value being saved should be checked
Now at this state, function of class booking is check which add services that is addServiceCharge(ServiceType, Cost)
bookingTest.addServiceCharge(ServiceType.ROOM_SERVICE, 45.6);
Looking at this function, issue is found that there is typo mistake that was as follows:-
![Uploading image.png…]()
Now testing test I have checked that now it shows pass result.
Console Output Booking Process with Parameters:-
Check-in Process after providing parameters
Recording Service against room ID
Checking Out and we can see the used services are zero
Result after bug Fix 👍
After customer's / guest's checked out, he still available to be charged with Hotel Services. Which is an issue.
Pre Condition: Customer booked, and checked in against hotel ID. Customer successfully checked out.
Post Condition: Customer must not be able to be charged with services, after confirming successful sign out.