io.restassured.response.Response.statusCode()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(203)

本文整理了Java中io.restassured.response.Response.statusCode方法的一些代码示例,展示了Response.statusCode的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.statusCode方法的具体详情如下:
包路径:io.restassured.response.Response
类名称:Response
方法名:statusCode

Response.statusCode介绍

暂无

代码示例

代码示例来源:origin: rest-assured/rest-assured

public T ifError() {
  if (response.statusCode() >= 400) {
    return logResponse(LogDetail.ALL);
  }
  return (T) this;
}

代码示例来源:origin: rest-assured/rest-assured

public T ifStatusCodeIsEqualTo(int statusCode) {
  if (response.statusCode() == statusCode) {
    return logResponse(LogDetail.ALL);
  }
  return (T) this;
}

代码示例来源:origin: rest-assured/rest-assured

public T ifStatusCodeMatches(Matcher<Integer> matcher) {
  notNull(matcher, "Matcher");
  if (matcher.matches(response.statusCode())) {
    return logResponse(LogDetail.ALL);
  }
  return (T) this;
}

代码示例来源:origin: rest-assured/rest-assured

public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {
  Response response = ctx.next(requestSpec, responseSpec);
  final int statusCode = response.statusCode();
  if (matcher.matches(statusCode)) {
    ResponsePrinter.print(response, response, stream, logDetail, shouldPrettyPrint);
    final byte[] responseBody;
    if (logDetail == LogDetail.BODY || logDetail == LogDetail.ALL) {
      responseBody = response.asByteArray();
    } else {
      responseBody = null;
    }
    response = cloneResponseIfNeeded(response, responseBody);
  }
  return response;
}

代码示例来源:origin: guru.nidi.raml/raml-tester

@Override
public int getStatus() {
  return response.statusCode();
}

代码示例来源:origin: nidi3/raml-tester

@Override
public int getStatus() {
  return response.statusCode();
}

代码示例来源:origin: org.bitbucket.iamkenos/cissnei-rest

public Integer responseStatus() {
  return response.statusCode();
}

代码示例来源:origin: lv.ctco.cukes/cukes-http

@Override
protected boolean matchesSafely(Response response) {
  return statusCodeMatches.matches(response.statusCode());
}

代码示例来源:origin: ctco/cukes

@Override
protected boolean matchesSafely(Response response) {
  return statusCodeMatches.matches(response.statusCode());
}

代码示例来源:origin: lv.ctco.cukes/cukes-http

@Override
  protected void describeMismatchSafely(Response item, Description mismatchDescription) {
    mismatchDescription.appendText("statusCode<").appendValue(item.statusCode() + "").appendText(">");
  }
};

代码示例来源:origin: ctco/cukes

@Override
  protected void describeMismatchSafely(Response item, Description mismatchDescription) {
    mismatchDescription.appendText("statusCode<").appendValue(item.statusCode() + "").appendText(">");
  }
};

代码示例来源:origin: epam/JDI

public ResponseStatus(Response response) {
    code = response.statusCode();
    type = ResponseStatusType.getStatusTypeFromCode(code);
    text = response.statusLine().substring(13);
  }
}

代码示例来源:origin: alfa-laboratory/akita

/**
 * Получает body из ответа и сохраняет в переменную
 *
 * @param variableName имя переменной, в которую будет сохранен ответ
 * @param response     ответ от http запроса
 */
public void getBodyAndSaveToVariable(String variableName, Response response) {
  if (response.statusCode() >= 200 && response.statusCode() < 300) {
    akitaScenario.setVar(variableName, response.getBody().asString());
    akitaScenario.write("Тело ответа : \n" + new Prettifier().getPrettifiedBodyIfPossible(response, response));
  } else {
    fail("Некорректный ответ на запрос: " + new Prettifier().getPrettifiedBodyIfPossible(response, response));
  }
}

代码示例来源:origin: com.adobe.ride/ride-core

if (responseSpec.getStatusCode().matches(response.statusCode())) {
 Reporter.log("Status code matched what was expected");
} else {

代码示例来源:origin: spring-cloud/spring-cloud-open-service-broker

@Test
public void validate_createServiceInstance() throws Exception {
  // given:
    RequestSpecification request = given()
        .header("Content-Type", "application/json")
        .body("{\"platform_instance_id\":null,\"api_info_location\":null,\"originating_identity\":null,\"async_accepted\":false,\"parameters\":{},\"context\":null,\"plan_id\":\"standard\",\"organization_guid\":null,\"space_guid\":null,\"service_instance_id\":null,\"service_definition\":null,\"service_id\":\"service-one-id\"}");
  // when:
    Response response = given().spec(request)
        .put("/v2/service_instances/service-instance-one-id?accepts_incomplete=false");
  // then:
    assertThat(response.statusCode()).isEqualTo(201);
}

代码示例来源:origin: ops4j/org.ops4j.pax.exam2

@Override
public RestResult getWithRetry(RestRequest r) {
  Response res = null;
  int retries = this.env.getRetries() * 3;
  Exception retryException = null;
  for (int i = 0;i<retries;i++) {
    try {
      res = given().auth().basic(clientConfig.getUser(), clientConfig.getPassword()).headers(r.getHeaders()).body(r.getBody()).when().get(r.getPath());
      if (res.statusCode() != 404) {
        return new RestResultImpl(res, null, retries);
      }
    } catch (Exception e ) {
      // retries..
      retryException = e;
    }
    try {
    TimeUnit.MILLISECONDS.sleep(200);
    } catch (InterruptedException e) {
      Thread.interrupted();
      return new RestResultImpl(null, e, retries);
    }
  }
  return new RestResultImpl(res, retryException, this.env.getRetries());
}

代码示例来源:origin: spring-cloud/spring-cloud-open-service-broker

@Test
public void validate_createServiceInstance() throws Exception {
  // given:
    RequestSpecification request = given()
        .header("Content-Type", "application/json")
        .body("{\"platform_instance_id\":null,\"api_info_location\":null,\"originating_identity\":null,\"async_accepted\":false,\"parameters\":{},\"context\":null,\"plan_id\":\"standard\",\"organization_guid\":null,\"space_guid\":null,\"service_instance_id\":null,\"service_definition\":null,\"service_id\":\"service-one-id\"}");
  // when:
    Response response = given().spec(request)
        .put("/v2/service_instances/service-instance-one-id?accepts_incomplete=false");
  // then:
    assertThat(response.statusCode()).isEqualTo(201);
}

代码示例来源:origin: marklogic/marklogic-data-hub

public String doLogin() {
  Response loginResponse =
      given()
        .body(loginInfo)
      .when()
        .post("/api/login");
  if(loginResponse.statusCode() == 200) {
    sessionID = StringUtils.substringBetween(loginResponse.getHeader("Set-Cookie"), "JSESSIONID=", ";");
  }
  // building cookie to use for subsequent endpoint requests
  buildCookie();
  return sessionID;
}

代码示例来源:origin: spring-cloud/spring-cloud-open-service-broker

assertThat(response.statusCode()).isEqualTo(200);
assertThat(response.header("Content-Type")).matches("application/json.*");

代码示例来源:origin: spring-cloud/spring-cloud-open-service-broker

assertThat(response.statusCode()).isEqualTo(200);
assertThat(response.header("Content-Type")).matches("application/json.*");

相关文章