Search in sources :

Example 1 with GET_SESSION

use of io.appium.java_client.MobileCommand.GET_SESSION in project java-client by appium.

the class HasSessionDetails method getSessionDetails.

/**
 * The current session details.
 *
 * @return a map with values that hold session details.
 */
@SuppressWarnings("unchecked")
default Map<String, Object> getSessionDetails() {
    Response response = execute(GET_SESSION);
    Map<String, Object> resultMap = Map.class.cast(response.getValue());
    // results of further operations should be simply interpreted by users
    return ImmutableMap.<String, Object>builder().putAll(resultMap.entrySet().stream().filter(entry -> {
        String key = entry.getKey();
        Object value = entry.getValue();
        return !isBlank(key) && value != null && !isBlank(String.valueOf(value));
    }).collect(toMap(Map.Entry::getKey, Map.Entry::getValue))).build();
}
Also used : Response(org.openqa.selenium.remote.Response) Response(org.openqa.selenium.remote.Response) GET_SESSION(io.appium.java_client.MobileCommand.GET_SESSION) Collectors.toMap(java.util.stream.Collectors.toMap) StringUtils.isBlank(org.apache.commons.lang3.StringUtils.isBlank) ImmutableMap(com.google.common.collect.ImmutableMap) Optional.ofNullable(java.util.Optional.ofNullable) Map(java.util.Map) Nullable(javax.annotation.Nullable) Collectors.toMap(java.util.stream.Collectors.toMap) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map)

Aggregations

ImmutableMap (com.google.common.collect.ImmutableMap)1 GET_SESSION (io.appium.java_client.MobileCommand.GET_SESSION)1 Map (java.util.Map)1 Optional.ofNullable (java.util.Optional.ofNullable)1 Collectors.toMap (java.util.stream.Collectors.toMap)1 Nullable (javax.annotation.Nullable)1 StringUtils.isBlank (org.apache.commons.lang3.StringUtils.isBlank)1 Response (org.openqa.selenium.remote.Response)1