// Path: src/main/java/com/frameworkium/core/api/tests/BaseAPITest.java
// @Listeners({MethodInterceptor.class,
//     TestListener.class,
//     ResultLoggerListener.class})
// @Test(groups = "base-api")
// public abstract class BaseAPITest {
// 
//   protected final Logger logger = LogManager.getLogger(this);
// 
//   /**
//    * Creates the allure properties for the report, after the test run.
//    */
//   @AfterSuite(alwaysRun = true)
//   public static void createAllureProperties() {
//     AllureProperties.createAPI();
//   }
// 
// }
// 
// Path: src/main/java/com/frameworkium/core/common/retry/RetryFlakyTest.java
// public class RetryFlakyTest implements IRetryAnalyzer {
// 
//   /**
//    * Maximum retry count of failed tests, defaults to 1.
//    */
//   static final int MAX_RETRY_COUNT =
//       Property.MAX_RETRY_COUNT.getIntWithDefault(1);
// 
//   private int retryCount = 0;
// 
//   @Override
//   public boolean retry(ITestResult result) {
//     return retryCount++ < MAX_RETRY_COUNT;
//   }
// }
// 
// Path: src/test/java/com/frameworkium/integration/restfulbooker/api/service/booking/BookingService.java
// public class BookingService extends AbstractBookerService {
// 
//     public List<BookingID> listBookings() {
//         return get(BookerEndpoint.BOOKING.getUrl())
//                 .jsonPath().getList(".", BookingID.class);
//     }
// 
//     public Booking getBooking(int id) {
//         return get(BookerEndpoint.BOOKING_ID.getUrl(id))
//                 .as(Booking.class);
//     }
// 
//     public CreateBookingResponse createBooking(Booking booking) {
//         return post(booking, BookerEndpoint.BOOKING.getUrl())
//                 .as(CreateBookingResponse.class);
//     }
// 
//     public List<BookingID> search(Map<String, String> searchParams) {
//         return request(Method.GET, searchParams, BookerEndpoint.BOOKING.getUrl())
//                 .jsonPath().getList(".", BookingID.class);
//     }
// 
//     public String createAuthToken(String username, String password) {
//         return post(
//                 ImmutableMap.of("username", username, "password", password),
//                 BookerEndpoint.AUTH.getUrl())
//                 .jsonPath().get("token");
//     }
// 
//     public void delete(int bookingID, String token) {
//         getRequestSpec()
//                 .cookie("token", token)
//                 .delete(BookerEndpoint.BOOKING_ID.getUrl(bookingID))
//                 // API does not match documentation
//                 // .then()
//                 // .statusCode(HttpStatus.SC_NO_CONTENT)
//                 ;
//     }
// 
//     public boolean doesBookingExist(int bookingID) {
//         final int statusCode = getRequestSpec()
//                 .get(BookerEndpoint.BOOKING_ID.getUrl(bookingID))
//                 .then()
//                 .extract()
//                 .statusCode();
//         if (statusCode == 200) {
//             return true;
//         } else if (statusCode == 404) {
//             return false;
//         } else {
//             throw new IllegalStateException("Unexpected return code");
//         }
//     }
// }
// 
// Path: src/test/java/com/frameworkium/integration/restfulbooker/api/service/ping/PingService.java
// public class PingService extends AbstractBookerService {
// 
//     public String ping() {
//         return get(BookerEndpoint.PING.getUrl())
//                 .body().asString();
//     }
// 
//     /**
//      * Used in template method {@link AbstractBookerService#get(String)}
//      */
//     @Override
//     protected ResponseSpecification getResponseSpec() {
//         return RestAssured.expect().response()
//                 .statusCode(HttpStatus.SC_CREATED);
//     }
// }


import com.frameworkium.core.api.tests.BaseAPITest;
import com.frameworkium.core.common.retry.RetryFlakyTest;
import com.frameworkium.integration.restfulbooker.api.dto.booking.*;
import com.frameworkium.integration.restfulbooker.api.service.booking.BookingService;
import com.frameworkium.integration.restfulbooker.api.service.ping.PingService;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static com.google.common.truth.Truth.assertThat;
package com.frameworkium.integration.restfulbooker.api.tests;



// app resets every 10m, so could happen in the middle of this test
@Test(retryAnalyzer = RetryFlakyTest.class)
public class BookerTest extends BaseAPITest {

    @BeforeClass
    public void ensure_site_is_up_by_using_ping_service() {
// Path: src/main/java/com/frameworkium/core/api/tests/BaseAPITest.java
// @Listeners({MethodInterceptor.class,
//     TestListener.class,
//     ResultLoggerListener.class})
// @Test(groups = "base-api")
// public abstract class BaseAPITest {
// 
//   protected final Logger logger = LogManager.getLogger(this);
// 
//   /**
//    * Creates the allure properties for the report, after the test run.
//    */
//   @AfterSuite(alwaysRun = true)
//   public static void createAllureProperties() {
//     AllureProperties.createAPI();
//   }
// 
// }
// 
// Path: src/main/java/com/frameworkium/core/common/retry/RetryFlakyTest.java
// public class RetryFlakyTest implements IRetryAnalyzer {
// 
//   /**
//    * Maximum retry count of failed tests, defaults to 1.
//    */
//   static final int MAX_RETRY_COUNT =
//       Property.MAX_RETRY_COUNT.getIntWithDefault(1);
// 
//   private int retryCount = 0;
// 
//   @Override
//   public boolean retry(ITestResult result) {
//     return retryCount++ < MAX_RETRY_COUNT;
//   }
// }
// 
// Path: src/test/java/com/frameworkium/integration/restfulbooker/api/service/booking/BookingService.java
// public class BookingService extends AbstractBookerService {
// 
//     public List<BookingID> listBookings() {
//         return get(BookerEndpoint.BOOKING.getUrl())
//                 .jsonPath().getList(".", BookingID.class);
//     }
// 
//     public Booking getBooking(int id) {
//         return get(BookerEndpoint.BOOKING_ID.getUrl(id))
//                 .as(Booking.class);
//     }
// 
//     public CreateBookingResponse createBooking(Booking booking) {
//         return post(booking, BookerEndpoint.BOOKING.getUrl())
//                 .as(CreateBookingResponse.class);
//     }
// 
//     public List<BookingID> search(Map<String, String> searchParams) {
//         return request(Method.GET, searchParams, BookerEndpoint.BOOKING.getUrl())
//                 .jsonPath().getList(".", BookingID.class);
//     }
// 
//     public String createAuthToken(String username, String password) {
//         return post(
//                 ImmutableMap.of("username", username, "password", password),
//                 BookerEndpoint.AUTH.getUrl())
//                 .jsonPath().get("token");
//     }
// 
//     public void delete(int bookingID, String token) {
//         getRequestSpec()
//                 .cookie("token", token)
//                 .delete(BookerEndpoint.BOOKING_ID.getUrl(bookingID))
//                 // API does not match documentation
//                 // .then()
//                 // .statusCode(HttpStatus.SC_NO_CONTENT)
//                 ;
//     }
// 
//     public boolean doesBookingExist(int bookingID) {
//         final int statusCode = getRequestSpec()
//                 .get(BookerEndpoint.BOOKING_ID.getUrl(bookingID))
//                 .then()
//                 .extract()
//                 .statusCode();
//         if (statusCode == 200) {
//             return true;
//         } else if (statusCode == 404) {
//             return false;
//         } else {
//             throw new IllegalStateException("Unexpected return code");
//         }
//     }
// }
// 
// Path: src/test/java/com/frameworkium/integration/restfulbooker/api/service/ping/PingService.java
// public class PingService extends AbstractBookerService {
// 
//     public String ping() {
//         return get(BookerEndpoint.PING.getUrl())
//                 .body().asString();
//     }
// 
//     /**
//      * Used in template method {@link AbstractBookerService#get(String)}
//      */
//     @Override
//     protected ResponseSpecification getResponseSpec() {
//         return RestAssured.expect().response()
//                 .statusCode(HttpStatus.SC_CREATED);
//     }
// }


// Path: src/test/java/com/frameworkium/integration/restfulbooker/api/tests/BookerTest.java
import com.frameworkium.core.api.tests.BaseAPITest;
import com.frameworkium.core.common.retry.RetryFlakyTest;
import com.frameworkium.integration.restfulbooker.api.dto.booking.*;
import com.frameworkium.integration.restfulbooker.api.service.booking.BookingService;
import com.frameworkium.integration.restfulbooker.api.service.ping.PingService;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static com.google.common.truth.Truth.assertThat;

package com.frameworkium.integration.restfulbooker.api.tests;



// app resets every 10m, so could happen in the middle of this test
@Test(retryAnalyzer = RetryFlakyTest.class)
public class BookerTest extends BaseAPITest {

    @BeforeClass
    public void ensure_site_is_up_by_using_ping_service() {
        assertThat(new PingService().ping())