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

generator.server.springboot.cucumber.rest.SyncResponseAsserter.mustache Maven / Gradle / Ivy

There is a newer version: 1.22.0
Show newest version
package {{packageName}}.cucumber.rest;

import static org.assertj.core.api.Assertions.*;

import org.springframework.http.HttpStatus;

class SyncResponseAsserter implements ResponseAsserter {

  @Override
  public SyncResponseAsserter hasHttpStatus(HttpStatus status) {
    CucumberRestAssertions.assertHttpStatus(status);

    return this;
  }

  @Override
  public ResponseAsserter hasHttpStatusIn(HttpStatus... statuses) {
    CucumberRestAssertions.assertHttpStatusIn(statuses);

    return this;
  }

  @Override
  public SyncElementAsserter hasElement(String jsonPath) {
    return new SyncElementAsserter(this, jsonPath);
  }

  @Override
  public SyncHeaderAsserter hasHeader(String header) {
    return new SyncHeaderAsserter(this, header);
  }

  public SyncResponseAsserter doNotHaveElement(String jsonPath) {
    int elementsCount = CucumberRestTestContext.countEntries(jsonPath);

    assertThat(elementsCount).as("Expecting " + jsonPath + " to not exists " + CucumberRestAssertions.callContext()).isZero();

    return this;
  }

  @Override
  public SyncResponseAsserter hasRawBody(String info) {
    assertThat(CucumberRestAssertions.responseBody()).isEqualTo(info);

    return this;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy