
hope.kola.contract.api.CookieVerifications Maven / Gradle / Ivy
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