/** Created by Maksi_000 on 2/11/2016. */
public class CrudMethods {
  WrestlerData wrestlerData = new WrestlerData();
  String authJson = wrestlerData.getCreds();

  public Map<String, String> authorization() {
    return given()
        .contentType(ContentType.JSON)
        .body(authJson)
        .expect()
        .statusCode(200)
        .when()
        .post("http://streamtv.net.ua/base/php/login.php")
        .getCookies();
  }

  public String createWrestler() {
    String myJson = wrestlerData.getNewWrestler();
    Map<String, String> cookies = authorization();
    Response response =
        given()
            .contentType(ContentType.JSON)
            .body(myJson)
            .with()
            .cookies(cookies)
            .post("http://streamtv.net.ua/base/php/wrestler/create.php");
    String JSONResponseBody = response.getBody().asString();
    JsonPath jsonPath = new JsonPath(JSONResponseBody);
    return jsonPath.get("id").toString();
  }
}
 public String createWrestler() {
   String myJson = wrestlerData.getNewWrestler();
   Map<String, String> cookies = authorization();
   Response response =
       given()
           .contentType(ContentType.JSON)
           .body(myJson)
           .with()
           .cookies(cookies)
           .post("http://streamtv.net.ua/base/php/wrestler/create.php");
   String JSONResponseBody = response.getBody().asString();
   JsonPath jsonPath = new JsonPath(JSONResponseBody);
   return jsonPath.get("id").toString();
 }