Kata/collections/checkpoint/exercise#49
Kata/collections/checkpoint/exercise#49vikrantdheer wants to merge 4 commits intoserenity-dojo:kata/collections/startfrom
Conversation
wakaleo
left a comment
There was a problem hiding this comment.
This is a great effort; if you resolve the issues mentioned here, it will deepen your understanding of the Screenplay question mechanics.
| @Step("{0} checks-in #pet into #petHotel") | ||
| @Override | ||
| public <T extends Actor> void performAs(T actor) { | ||
| BookingResponse bookingResponse = petHotel.checkIn(pet); |
There was a problem hiding this comment.
Here, you never use the 'bookingResponse' variable, so you never actually check the response coming back from the hotel.
| */ | ||
| public class TheBookingStatus implements Question<Boolean> { | ||
|
|
||
| private BookingResponse bookingResponse = new BookingResponse(true); |
There was a problem hiding this comment.
Here, BookingResponse always created with a parameter of 'true', so the question will always return true.
| private Pet pet; | ||
|
|
||
| public TheBookingStatus(Pet pet) { | ||
| this.pet = pet; |
There was a problem hiding this comment.
The pet is never actually used. Remember, the booking status isn't directly related to the pet, but is the outcome the booking process when you try to book a pet into a hotel.
|
|
||
| //THEN | ||
| then(vikrant).should(seeThat(TheWaitingStatus.of(goldy).isConfirmed(), is(false))); | ||
| } |
There was a problem hiding this comment.
This test is missing an edge case. If the hotel is full, the booking status should fail, e.g.
@Test
public void should_notify_owner_that_the_hotel_is_full() throws Exception {
//GIVEN
PetHotel petHotel = APetHotel.with(19).checkedIn();
Pet tommy = Pet.dog().named("Tommy");
Pet goldy = Pet.fish().named("Goldy");
//WHEN
when(vikrant).attemptsTo(CheckIn.aPet(tommy).in(petHotel), CheckIn.aPet(goldy).in(petHotel));
//THEN
then(vikrant).should(seeThat(TheBookingStatus.of(goldy).isConfirmed(), is(false)));
and(vikrant).should(seeThat(TheWaitingStatus.of(goldy).isConfirmed(), is(false)));
}
| public BookingResponse checkIn(Pet pet) { | ||
| return (registeredPets.size() < DEFAULT_MAXIMUM_CAPACITY) | ||
| ? new BookingResponse(registeredPets.add(pet)) | ||
| : new BookingResponse(waitingListOfPets.add(pet)); |
There was a problem hiding this comment.
This will return a positive booking response in both cases, so there is no way for the customer to know if the pet was successfully booked or not.
No description provided.