-
Notifications
You must be signed in to change notification settings - Fork 195
Kata/collections/checkpoint/exercise #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: kata/collections/start
Are you sure you want to change the base?
Kata/collections/checkpoint/exercise #49
Conversation
wakaleo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.