All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.teststeps.thekla4j.http.httpConn.HcHttpResult Maven / Gradle / Ivy

package com.teststeps.thekla4j.http.httpConn;

import com.teststeps.thekla4j.http.commons.Cookie;
import com.teststeps.thekla4j.http.core.HttpResult;
import io.vavr.collection.HashMap;
import io.vavr.collection.List;

public class HcHttpResult implements HttpResult {

  private String response = "";
  private Integer statusCode = 0;
  private HashMap> headers = HashMap.empty();
  private List cookies = List.empty();


  public static HcHttpResult response(String response) {
    return new HcHttpResult(response);
  }

  public HcHttpResult statusCode(Integer statusCode) {
    this.statusCode = statusCode;
    return this;
  }

  public HcHttpResult headers(HashMap> headers) {
    this.headers = headers;
    return this;
  }

  public HcHttpResult cookies(List cookies) {
    this.cookies = cookies;
    return this;
  }

  private HcHttpResult(String response) {
    this.response = response;
  }

  @Override
  public Integer statusCode() {
    return this.statusCode;
  }

  @Override
  public String response() {
    return this.response;
  }

  public HashMap> headers() {
    return this.headers;
  }

  @Override
  public List cookies() {
    return this.cookies;
  }

  public String toString() {
    return this.toString(0);
  }

  public String toString(int indent) {
//    return JSON.logOf(this).replace("\n", "\t".repeat(indent) + "\n");
        return
            "ResponseBody: " + this.response + "\n" +
            "StatusCode: " + this.statusCode + "\n" +
            "Response: " + this.response  + "\n" +
            "Headers: " + this.headers + "\n" +
            "Cookies: " + this.cookies + "\n";
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy