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

hope.kola.contract.api.CookieVerifications Maven / Gradle / Ivy

There is a newer version: 1.1.2-RELEASE
Show newest version
package hope.kola.contract.api;

import groovy.lang.Closure;
import groovy.lang.DelegatesTo;
import hope.kola.contract.assertj.bridge.StringAssert;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.function.Consumer;

public class CookieVerifications {

  protected final Set entries = new LinkedHashSet<>();

  public boolean hasEntries() {
    return !entries.isEmpty();
  }

  public Set entries() {
    return entries;
  }

  /**
   * And Assert logic for specific Cookie Verification
   *
   * @param key the name of this Cookie
   * @param consumer function to define the {@link StringAssert}
   */
  public void assertThat(final String key, @DelegatesTo(StringAssert.class) Closure consumer) {
    StringAssert stringAssert = new StringAssert();
    CookieVerification verification = new CookieVerification(key, stringAssert);
    consumer.setDelegate(stringAssert);
    consumer.call();
    entries.add(verification);
  }

  /**
   * (JAVA) And Assert logic for specific Cookie Verification
   *
   * @param key key the name of this Cookie
   * @param consumer function to define the {@link StringAssert}
   */
  public void assertThat(final String key, Consumer consumer) {
    StringAssert stringAssert = new StringAssert();
    CookieVerification verification = new CookieVerification(key, stringAssert);
    consumer.accept(stringAssert);
    entries.add(verification);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy