2bittester/rbp-data-set huggingface dataset:
Question: How does the method updateBookingTest work for BookingServiceTest?
Answer:
@Test
public void updateBookingTest() throws SQLException
{
    Booking booking = createGenericBooking();
    CreatedBooking createdBooking = new CreatedBooking(1, booking);
    when(authRequests.postCheckAuth("abc123")).thenReturn(true);
    when(dateCheckValidator.isValid(booking.getBookingDates())).thenReturn(true);
    when(bookingDB.checkForBookingConflict(booking)).thenReturn(false);
    when(bookingDB.update(1, booking)).thenReturn(createdBooking);
    BookingResult bookingResult = bookingService.updateBooking(1, booking, "abc123");
    assertEquals(HttpStatus.OK, bookingResult.getStatus());
    assertEquals("CreatedBooking{bookingid=1, booking=Booking{roomid=2, firstname='Mark', lastname='Dean', depositpaid=true, bookingDates=BookingDates{checkin=2019-09-01, checkout=2019-09-02}}}", bookingResult.getCreatedBooking().toString());
}
Question: How does the method updateBookingNotFoundTest work for BookingServiceTest?
Answer:
@Test
public void updateBookingNotFoundTest() throws SQLException
{
    Booking booking = createGenericBooking();
    when(authRequests.postCheckAuth("abc123")).thenReturn(true);
    when(dateCheckValidator.isValid(booking.getBookingDates())).thenReturn(true);
    when(bookingDB.checkForBookingConflict(booking)).thenReturn(false);
    when(bookingDB.update(100, booking)).thenReturn(null);
    BookingResult bookingResult = bookingService.updateBooking(100, booking, "abc123");
    assertEquals(HttpStatus.NOT_FOUND, bookingResult.getStatus());
    assertNull(bookingResult.getCreatedBooking());
}
Question: How does the method updateBookingDatesTest work for BookingServiceTest?
Answer:
@Test
public void updateBookingDatesTest() throws SQLException
{
    Booking booking = createGenericBooking();
    when(authRequests.postCheckAuth("abc123")).thenReturn(true);
    when(dateCheckValidator.isValid(booking.getBookingDates())).thenReturn(true);
    when(bookingDB.checkForBookingConflict(booking)).thenReturn(true);
    BookingResult bookingResult = bookingService.updateBooking(100, booking, "abc123");
    assertEquals(HttpStatus.CONFLICT, bookingResult.getStatus());
}
Question: How does the method updateBookingBadDatesTest work for BookingServiceTest?
Answer:
@Test
public void updateBookingBadDatesTest() throws SQLException
{
    Booking booking = createGenericBooking();
    when(authRequests.postCheckAuth("abc123")).thenReturn(true);
    when(dateCheckValidator.isValid(booking.getBookingDates())).thenReturn(false);
    BookingResult bookingResult = bookingService.updateBooking(100, booking, "abc123");
    assertEquals(HttpStatus.CONFLICT, bookingResult.getStatus());
}
Question: How does the method createBookingTest work for BookingServiceTest?
Answer:
@Test
public void createBookingTest() throws SQLException
{
    Booking booking = createGenericBooking();
    when(bookingDB.create(booking)).thenReturn(new CreatedBooking(3, booking));
    when(dateCheckValidator.isValid(booking.getBookingDates())).thenReturn(true);
    BookingResult bookingResult = bookingService.createBooking(booking);
    assertEquals(HttpStatus.CREATED, bookingResult.getStatus());
    assertEquals("CreatedBooking{bookingid=3, booking=Booking{roomid=2, firstname='Mark', lastname='Dean', depositpaid=true, bookingDates=BookingDates{checkin=2019-09-01, checkout=2019-09-02}}}", bookingResult.getCreatedBooking().toString());
}
Question: How does the method createBookingDateConflictTest work for BookingServiceTest?
Answer:
@Test
public void createBookingDateConflictTest() throws SQLException
{
    Booking booking = createGenericBooking();
    when(bookingDB.checkForBookingConflict(booking)).thenReturn(true);
    when(dateCheckValidator.isValid(booking.getBookingDates())).thenReturn(true);
    BookingResult bookingResult = bookingService.createBooking(booking);
    assertEquals(HttpStatus.CONFLICT, bookingResult.getStatus());
}
Question: How does the method createBookingDateInvalidTest work for BookingServiceTest?
Answer:
@Test
public void createBookingDateInvalidTest() throws SQLException
{
    Booking booking = createGenericBooking();
    when(dateCheckValidator.isValid(booking.getBookingDates())).thenReturn(false);
    BookingResult bookingResult = bookingService.createBooking(booking);
    assertEquals(HttpStatus.CONFLICT, bookingResult.getStatus());
}
Question: How does the method createGenericBooking work for BookingServiceTest?
Answer:
private Booking createGenericBooking()
{
    LocalDate startDate = LocalDate.of(2019, Month.SEPTEMBER, 1);
    LocalDate endDate = LocalDate.of(2019, Month.SEPTEMBER, 2);
    BookingDates bookingDates = new BookingDates(startDate, endDate);
    return new Booking(1, 2, "Mark", "Dean", true, bookingDates);
}
Question: What package does BookingValidationIT belong to
Answer:
package com.automationintesting.integration;
Question: What is the class declaration for BookingValidationIT
Answer:
@ExtendWith
@SpringBootTest
@ActiveProfiles
public class BookingValidationIT {

}
Question: How does the method testPostValidation work for BookingValidationIT?
Answer:
@Test
public void testPostValidation()
{
    Booking bookingPayload = new Booking.BookingBuilder().setEmail("mark@mwtestconsultancy.co.uk").setPhone("01234123123").build();
    Response response = given().contentType(ContentType.JSON).body(bookingPayload).when().post("http://localhost:3000/booking/");
    assertEquals(400, response.statusCode());
}
Question: How does the method testPutValidation work for BookingValidationIT?
Answer:
@Test
public void testPutValidation()
{
    Booking bookingPayload = new Booking.BookingBuilder().setEmail("mark@mwtestconsultancy.co.uk").setPhone("01234123123").build();
    Response response = given().contentType(ContentType.JSON).body(bookingPayload).when().put("http://localhost:3000/booking/1");
    assertEquals(400, response.statusCode());
}
Question: What package does ContractIT belong to
Answer:
package com.automationintesting.integration.examples;
Question: What is the class declaration for ContractIT
Answer:
@ExtendWith
@SpringBootTest
@ActiveProfiles
public class ContractIT {

}
Question: How does the method setupRestito work for ContractIT?
Answer:
@BeforeEach
public void setupRestito()
{
    whenHttp(server).match(post("/auth/validate")).then(status(HttpStatus.OK_200));
}
Question: How does the method stopServer work for ContractIT?
Answer:
@AfterEach
public void stopServer() throws InterruptedException
{
    server.stop();
    Thread.sleep(1500);
}
Question: How does the method checkAuthContract work for ContractIT?
Answer:
@Test
public void checkAuthContract() throws JSONException, FileNotFoundException, URISyntaxException
{
    Response response = given().get("http://localhost:3000/booking/1");
    JSONObject parsedResponse = new JSONObject(response.body().prettyPrint());
    File file = ResourceUtils.getFile(this.getClass().getResource("/contract.json"));
    String testObject = new Scanner(file).useDelimiter("\\Z").next();
    JSONAssert.assertEquals(testObject, parsedResponse, true);
}
Question: What package does BookingIntegrationIT belong to
Answer:
package com.automationintesting.integration.examples;
Question: What is the class declaration for BookingIntegrationIT
Answer:
@ExtendWith
@SpringBootTest
@ActiveProfiles
public class BookingIntegrationIT {

}
Question: List variables declared in BookingIntegrationIT
Answer:
private StubServer server;
Question: How does the method setupRestito work for BookingIntegrationIT?
Answer:
@BeforeEach
public void setupRestito()
{
    server = new StubServer(3006).run();
    whenHttp(server).match(post("/message/")).then(status(HttpStatus.OK_200));
}
Question: How does the method stopServer work for BookingIntegrationIT?
Answer:
@AfterEach
public void stopServer()
{
    server.stop();
}
Question: How does the method testCreateBooking work for BookingIntegrationIT?
Answer:
@Test
public void testCreateBooking()
{
    LocalDate checkindate = LocalDate.of(1991, Month.JANUARY, 1);
    LocalDate checkoutdate = LocalDate.of(1991, Month.JANUARY, 2);
    Booking bookingPayload = new Booking.BookingBuilder().setRoomid(1).setFirstname("Mark").setLastname("Winteringham").setDepositpaid(true).setCheckin(checkindate).setCheckout(checkoutdate).setEmail("mark@mwtestconsultancy.co.uk").setPhone("01928123456").build();
    Response bookingResponse = given().contentType(ContentType.JSON).body(bookingPayload).when().post("http://localhost:3000/booking/");
    System.out.println(bookingResponse.getBody().prettyPrint());
    CreatedBooking response = bookingResponse.as(CreatedBooking.class);
    assertThat(response.getBooking().getFirstname(), is("Mark"));
    assertThat(response.getBooking().getLastname(), is("Winteringham"));
    assertThat(response.getBooking().isDepositpaid(), is(true));
    assertThat(response.getBooking().getBookingDates().getCheckin(), is(checkindate));
    assertThat(response.getBooking().getBookingDates().getCheckout(), is(checkoutdate));
}
Question: What package does MessageRequestIT belong to
Answer:
package com.automationintesting.integration;
Question: What is the class declaration for MessageRequestIT
Answer:
@ExtendWith
@SpringBootTest
@ActiveProfiles
public class MessageRequestIT {

}
Question: How does the method setupRestito work for MessageRequestIT?
Answer:
@BeforeEach
public void setupRestito()
{
    whenHttp(server).match(post("/message/")).then(status(HttpStatus.OK_200));
}
Question: How does the method stopServer work for MessageRequestIT?
Answer:
@AfterEach
public void stopServer()
{
    server.stop();
}
Question: How does the method testSendingToMessageAPI work for MessageRequestIT?
Answer:
@Test
public void testSendingToMessageAPI()
{
    LocalDate checkindate = LocalDate.of(1990, Month.FEBRUARY, 1);
    LocalDate checkoutdate = LocalDate.of(1990, Month.FEBRUARY, 2);
    Booking bookingPayload = new Booking.BookingBuilder().setRoomid(1).setFirstname("Mark").setLastname("Winteringham").setDepositpaid(true).setCheckin(checkindate).setCheckout(checkoutdate).setEmail("mark@mwtestconsultancy.co.uk").setPhone("01292123456").build();
    Response bookingResponse = given().contentType(ContentType.JSON).body(bookingPayload).when().post("http://localhost:3000/booking/");
    Approvals.verify(server.getCalls().get(0).getPostBody());
}
Question: What package does BookingDateConflictIT belong to
Answer:
package com.automationintesting.integration;
Question: What is the class declaration for BookingDateConflictIT
Answer:
@ExtendWith
@SpringBootTest
@ActiveProfiles
public class BookingDateConflictIT {

}
Question: How does the method testBookingConflict work for BookingDateConflictIT?
Answer:
@Test
public void testBookingConflict()
{
    String token = "abc123";
    LocalDate checkindate = LocalDate.of(2020, Month.FEBRUARY, 1);
    LocalDate checkoutdate = LocalDate.of(2020, Month.FEBRUARY, 2);
    Booking bookingPayload = new Booking.BookingBuilder().setRoomid(1).setFirstname("Mark").setLastname("Winteringham").setDepositpaid(true).setCheckin(checkindate).setCheckout(checkoutdate).setEmail("mark@mwtestconsultancy.co.uk").setPhone("01234123123").build();
    given().cookie("token", token).contentType(ContentType.JSON).body(bookingPayload).when().post("http://localhost:3000/booking/");
    Response bookingResponse = given().cookie("token", token).contentType(ContentType.JSON).body(bookingPayload).when().post("http://localhost:3000/booking/");
    assertEquals(409, bookingResponse.statusCode());
}
Question: How does the method testBookingDatesInvalid work for BookingDateConflictIT?
Answer:
@Test
public void testBookingDatesInvalid()
{
    LocalDate checkindate = LocalDate.of(2018, Month.JANUARY, 1);
    LocalDate checkoutdate = LocalDate.of(2018, Month.JANUARY, 5);
    Booking bookingPayload = new Booking.BookingBuilder().setRoomid(1).setFirstname("Mark").setLastname("Winteringham").setDepositpaid(true).setCheckin(checkindate).setCheckout(checkoutdate).setEmail("mark@mwtestconsultancy.co.uk").setPhone("01234123123").build();
    given().contentType(ContentType.JSON).body(bookingPayload).when().post("http://localhost:3000/booking/");
    Response bookingResponse = given().contentType(ContentType.JSON).body(bookingPayload).when().post("http://localhost:3000/booking/");
    assertEquals(409, bookingResponse.statusCode());
}
Question: What package does GetBookingIT belong to
Answer:
package com.automationintesting.integration;
Question: What is the class declaration for GetBookingIT
Answer:
@ExtendWith
@SpringBootTest
@ActiveProfiles
public class GetBookingIT {

}
Question: How does the method setupRestito work for GetBookingIT?
Answer:
@BeforeEach
public void setupRestito()
{
    whenHttp(server).match(post("/auth/validate")).then(status(HttpStatus.OK_200));
}
Question: How does the method stopServer work for GetBookingIT?
Answer:
@AfterEach
public void stopServer() throws InterruptedException
{
    server.stop();
    Thread.sleep(1500);
}
Question: How does the method getValidBooking work for GetBookingIT?
Answer:
@Test
public void getValidBooking()
{
    Response response = given().cookie("token", "abc123").get("http://localhost:3000/booking/1");
    assertEquals(200, response.getStatusCode());
}
Question: How does the method getInvalidBooking work for GetBookingIT?
Answer:
@Test
public void getInvalidBooking()
{
    Response response = given().cookie("token", "abc123").get("http://localhost:3000/booking/1000");
    response.getBody().prettyPrint();
    assertEquals(404, response.getStatusCode());
}
Question: What package does MessageRequests belong to
Answer:
package com.automationintesting.requests;
Question: What is the class declaration for MessageRequests
Answer:
public class MessageRequests {

}
Question: List variables declared in MessageRequests
Answer:
private String host;
Question: How does the method postMessage work for MessageRequests?
Answer:
public boolean postMessage(Message message)
{
    RestTemplate restTemplate = new RestTemplate();
    HttpHeaders requestHeaders = new HttpHeaders();
    requestHeaders.setContentType(MediaType.APPLICATION_JSON);
    requestHeaders.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
    HttpEntity<Message> httpEntity = new HttpEntity<Message>(message, requestHeaders);
    try {
        ResponseEntity<String> response = restTemplate.exchange(host + "/message/", HttpMethod.POST, httpEntity, String.class);
        return response.getStatusCodeValue() == 200;
    } catch (HttpClientErrorException e) {
        return false;
    }
}
Question: What package does Message belong to
Answer:
package com.automationintesting.model.db;
Question: What is the class declaration for Message
Answer:
@Entity
public class Message {

}
Question: List variables declared in Message
Answer:
@JsonProperty
private String name;
Question: List variables declared in Message
Answer:
@JsonProperty
private String email;
Question: List variables declared in Message
Answer:
@JsonProperty
private String phone;
Question: List variables declared in Message
Answer:
@JsonProperty
private String subject;
Question: List variables declared in Message
Answer:
@JsonProperty
private String description;
Question: How does the method getName work for Message?
Answer:
public String getName()
{
    return name;
}
Question: How does the method getEmail work for Message?
Answer:
public String getEmail()
{
    return email;
}
Question: How does the method getPhone work for Message?
Answer:
public String getPhone()
{
    return phone;
}
Question: How does the method getSubject work for Message?
Answer:
public String getSubject()
{
    return subject;
}
Question: How does the method getDescription work for Message?
Answer:
public String getDescription()
{
    return description;
}
Question: How does the method setName work for Message?
Answer:
public void setName(String name)
{
    this.name = name;
}
Question: How does the method setEmail work for Message?
Answer:
public void setEmail(String email)
{
    this.email = email;
}
Question: How does the method setPhone work for Message?
Answer:
public void setPhone(String phone)
{
    this.phone = phone;
}
Question: How does the method setSubject work for Message?
Answer:
public void setSubject(String subject)
{
    this.subject = subject;
}
Question: How does the method setDescription work for Message?
Answer:
public void setDescription(String description)
{
    this.description = description;
}
Question: How does the method toString work for Message?
Answer:
@Override
public String toString()
{
    return "Message{" + ", name='" + name + '\'' + ", email='" + email + '\'' + ", phone='" + phone + '\'' + ", subject='" + subject + '\'' + ", description='" + description + '\'' + '}';
}
Question: What package does Booking belong to
Answer:
package com.automationintesting.model.db;
Question: What is the class declaration for Booking
Answer:
@Entity
@JsonInclude
public class Booking {

}
Question: List variables declared in Booking
Answer:
@JsonProperty
private int bookingid;
Question: List variables declared in Booking
Answer:
@JsonProperty
@Min
private int roomid;
Question: List variables declared in Booking
Answer:
@JsonProperty
@NotBlank
@Size
private String firstname;
Question: List variables declared in Booking
Answer:
@JsonProperty
@NotBlank
@Size
private String lastname;
Question: List variables declared in Booking
Answer:
@JsonProperty
@NotNull
private boolean depositpaid;
Question: List variables declared in Booking
Answer:
@JsonProperty
@Valid
private BookingDates bookingDates;
Question: List variables declared in Booking
Answer:
@JsonProperty
private Optional<String> email;
Question: List variables declared in Booking
Answer:
@JsonProperty
private Optional<String> phone;
Question: How does the method getFirstname work for Booking?
Answer:
public String getFirstname()
{
    return firstname;
}
Question: How does the method getLastname work for Booking?
Answer:
public String getLastname()
{
    return lastname;
}
Question: How does the method isDepositpaid work for Booking?
Answer:
public boolean isDepositpaid()
{
    return depositpaid;
}
Question: How does the method getBookingDates work for Booking?
Answer:
public BookingDates getBookingDates()
{
    return bookingDates;
}
Question: How does the method getRoomid work for Booking?
Answer:
public int getRoomid()
{
    return roomid;
}
Question: How does the method getBookingid work for Booking?
Answer:
public int getBookingid()
{
    return bookingid;
}
Question: How does the method getEmail work for Booking?
Answer:
public Optional<String> getEmail()
{
    return email;
}
Question: How does the method getPhone work for Booking?
Answer:
public Optional<String> getPhone()
{
    return phone;
}
Question: How does the method setFirstname work for Booking?
Answer:
public void setFirstname(String firstname)
{
    this.firstname = firstname;
}
Question: How does the method setLastname work for Booking?
Answer:
public void setLastname(String lastname)
{
    this.lastname = lastname;
}
Question: How does the method setDepositpaid work for Booking?
Answer:
public void setDepositpaid(boolean depositpaid)
{
    this.depositpaid = depositpaid;
}
Question: How does the method setBookingDates work for Booking?
Answer:
public void setBookingDates(BookingDates bookingDates)
{
    this.bookingDates = bookingDates;
}
Question: How does the method setRoomid work for Booking?
Answer:
public void setRoomid(int roomid)
{
    this.roomid = roomid;
}
Question: How does the method setBookingid work for Booking?
Answer:
public void setBookingid(int bookingid)
{
    this.bookingid = bookingid;
}
Question: How does the method setEmail work for Booking?
Answer:
public void setEmail(String email)
{
    this.email = Optional.of(email);
}
Question: How does the method setPhone work for Booking?
Answer:
public void setPhone(String phone)
{
    this.phone = Optional.of(phone);
}
Question: How does the method toString work for Booking?
Answer:
@Override
public String toString()
{
    return "Booking{" + "roomid=" + roomid + ", firstname='" + firstname + '\'' + ", lastname='" + lastname + '\'' + ", depositpaid=" + depositpaid + ", bookingDates=" + bookingDates + '}';
}
Question: What is the class declaration for Booking
Answer:
public class BookingBuilder {

}
Question: List variables declared in Booking
Answer:
private int bookingid;
Question: List variables declared in Booking
Answer:
private int roomid;
Question: List variables declared in Booking
Answer:
private String firstname;
Question: List variables declared in Booking
Answer:
private String lastname;
Question: List variables declared in Booking
Answer:
private boolean depositpaid;
Question: List variables declared in Booking
Answer:
private LocalDate checkin;
Question: List variables declared in Booking
Answer:
private LocalDate checkout;
Question: List variables declared in Booking
Answer:
private String email;
Question: List variables declared in Booking
Answer:
private String phone;
Question: How does the method setBookingid work for Booking?
Answer:
public BookingBuilder setBookingid(int bookingid)
{
    this.bookingid = bookingid;
    return this;
}
Question: How does the method setRoomid work for Booking?
Answer:
public BookingBuilder setRoomid(int roomid)
{
    this.roomid = roomid;
    return this;
}
Question: How does the method setFirstname work for Booking?
Answer:
public BookingBuilder setFirstname(String firstname)
{
    this.firstname = firstname;
    return this;
}
Question: How does the method setLastname work for Booking?
Answer:
public BookingBuilder setLastname(String lastname)
{
    this.lastname = lastname;
    return this;
}
Question: How does the method setDepositpaid work for Booking?
Answer:
public BookingBuilder setDepositpaid(boolean depositpaid)
{
    this.depositpaid = depositpaid;
    return this;
}
Question: How does the method setCheckin work for Booking?
Answer:
public BookingBuilder setCheckin(LocalDate checkin)
{
    this.checkin = checkin;
    return this;
}
Question: How does the method setCheckout work for Booking?
Answer:
public BookingBuilder setCheckout(LocalDate checkout)
{
    this.checkout = checkout;
    return this;
}
Question: How does the method setEmail work for Booking?
Answer:
public BookingBuilder setEmail(String email)
{
    this.email = email;
    return this;
}
Question: How does the method setPhone work for Booking?
Answer:
public BookingBuilder setPhone(String phone)
{
    this.phone = phone;
    return this;
}
Question: How does the method build work for Booking?
Answer:
public Booking build()
{
    BookingDates bookingDates = new BookingDates(checkin, checkout);
    if (email == null && phone == null) {
        return new Booking(bookingid, roomid, firstname, lastname, depositpaid, bookingDates);
    } else {
        return new Booking(bookingid, roomid, firstname, lastname, depositpaid, bookingDates, email, phone);
    }
}
Question: What package does CreatedBooking belong to
Answer:
package com.automationintesting.model.db;
Question: What is the class declaration for CreatedBooking
Answer:
public class CreatedBooking {

}
Question: List variables declared in CreatedBooking
Answer:
@JsonProperty
private int bookingid;
Question: List variables declared in CreatedBooking
Answer:
@JsonProperty
private Booking booking;
Question: How does the method getBookingid work for CreatedBooking?
Answer:
public int getBookingid()
{
    return bookingid;
}
Question: How does the method setBookingid work for CreatedBooking?
Answer:
public void setBookingid(int bookingid)
{
    this.bookingid = bookingid;
}
Question: How does the method getBooking work for CreatedBooking?
Answer:
public Booking getBooking()
{
    return booking;
}
Question: How does the method setBooking work for CreatedBooking?
Answer:
public void setBooking(Booking booking)
{
    this.booking = booking;
}
Question: How does the method toString work for CreatedBooking?
Answer:
@Override
public String toString()
{
    return "CreatedBooking{" + "bookingid=" + bookingid + ", booking=" + booking.toString() + '}';
}
Question: What package does BookingSummary belong to
Answer:
package com.automationintesting.model.db;
Question: What is the class declaration for BookingSummary
Answer:
public class BookingSummary {

}
Question: List variables declared in BookingSummary
Answer:
private BookingDates bookingDates;