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

generator.server.springboot.cucumber.rest.HeaderAssertions.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 java.util.List;

class HeaderAssertions {

  private final String header;

  HeaderAssertions(String header) {
    this.header = header;

    assertThat(CucumberRestTestContext.getResponseHeader(header)).as("Can't find header " + header).isNotEmpty();
  }

  public void containing(String value) {
    List values = CucumberRestTestContext.getResponseHeader(header);
    assertThat(values)
      .as("Expecting header " + header + " to contain " + value + " but can't find it, current values are " + displayValues(values))
      .contains(value);
  }

  public void startingWith(String prefix) {
    List values = CucumberRestTestContext.getResponseHeader(header);

    assertThat(values)
      .as("Expecting header " + header + " to start with " + prefix + " but can't find it, current values are " + displayValues(values))
      .anyMatch(content -> content.startsWith(prefix));
  }

  private String displayValues(List values) {
    return String.join(", ", values);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy