Skip to content

Conversation

@vikrantdheer
Copy link

No description provided.

Copy link
Contributor

@wakaleo wakaleo left a 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);
Copy link
Contributor

@wakaleo wakaleo Sep 21, 2016

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);
Copy link
Contributor

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;
Copy link
Contributor

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)));
}
Copy link
Contributor

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));
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants