com.github.hi_fi.httprequestlibrary.keywords.Put Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of robotframework-httprequestlibrary Show documentation
Show all versions of robotframework-httprequestlibrary Show documentation
A Robot Framework library for HTTP request testing.
The newest version!
package com.github.hi_fi.httprequestlibrary.keywords;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
import org.robotframework.javalib.annotation.ArgumentNames;
import org.robotframework.javalib.annotation.RobotKeyword;
import org.robotframework.javalib.annotation.RobotKeywords;
import com.github.hi_fi.httpclient.RestClient;
import com.github.hi_fi.httpclient.domain.ResponseData;
import com.github.hi_fi.httprequestlibrary.utils.Robot;
@RobotKeywords
public class Put {
@RobotKeyword(" Send a PUT request on the session object found using the\n\n"
+ "given `alias`\n\n"
+ "``alias`` that will be used to identify the Session object in the cache\n\n"
+ "``uri`` to send the PUT request to\n\n"
+ "``data`` a dictionary of key-value pairs that will be urlencoded and sent as PUT data or binary data that is sent as the raw body content\n\n"
+ "``params`` url parameters to append to the uri\n\n"
+ "``headers`` a dictionary of headers to use with the request\n\n"
+ "``files`` a dictionary of file names containing file data to PUT to the server\n\n"
+ "\n\n"
+ "``allow_redirects`` Boolean. Set to False if redirect following is not allowed.\n\n"
+ "``timeout`` connection timeout")
@ArgumentNames({ "alias", "uri", "data=''", "params=", "headers=", "files=", "allow_redirects=True",
"timeout=0" })
public ResponseData putRequest(String alias, String uri, Object dataList, Map paramSetup, Map headerSetup, Map filesSetup, Boolean allowRedirects, Integer timeout) {
RestClient rc = new RestClient();
Map params = paramSetup != null ? paramSetup.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> (String)e.getValue())): new HashMap();
Map headers = headerSetup != null ? headerSetup.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> (String)e.getValue())): new HashMap();
Map files = filesSetup != null ? filesSetup.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> (String)e.getValue())): new HashMap();
if (Robot.isDictionary(dataList.toString())) {
dataList = (Map) Robot.parseRobotDictionary(dataList.toString());
}
rc.makePutRequest(alias, uri, dataList, params, headers, files, allowRedirects);
return rc.getSession(alias).getResponseData();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy