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

io.nosqlbench.driver.webdriver.verbs.CookieJar Maven / Gradle / Ivy

Go to download

A nosqlbench driver module; Provides the ability to drive steps through the webdriver API.

There is a newer version: 4.15.102
Show newest version
package io.nosqlbench.driver.webdriver.verbs;

import org.openqa.selenium.Cookie;

import java.sql.Date;
import java.util.Map;
import java.util.Optional;

public class CookieJar {
    public static Cookie cookie(Map props) {
        String name = props.get("name");
        String value = props.getOrDefault("value","");
        Cookie.Builder builder = new Cookie.Builder(name, value);
        Optional.ofNullable(props.get("domain")).ifPresent(builder::domain);
        Optional.ofNullable(props.get("expiry")).map(Date::valueOf).ifPresent(builder::expiresOn);
        Optional.ofNullable(props.get("ishttponly")).map(Boolean::valueOf).ifPresent(builder::isHttpOnly);
        Optional.ofNullable(props.get("issecure")).map(Boolean::valueOf).ifPresent(builder::isSecure);
        Optional.ofNullable(props.get("path")).ifPresent(builder::path);
        return builder.build();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy