Java Code Examples for org.openqa.selenium.json.JsonInput#read()
The following examples show how to use
org.openqa.selenium.json.JsonInput#read() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CreateSessionResponse.java From selenium with Apache License 2.0 | 6 votes |
private static CreateSessionResponse fromJson(JsonInput input) { Session session = null; byte[] downstreamResponse = null; input.beginObject(); while (input.hasNext()) { switch (input.nextName()) { case "downstreamEncodedResponse": downstreamResponse = Base64.getDecoder().decode(input.nextString()); break; case "session": session = input.read(Session.class); break; default: input.skipValue(); break; } } input.endObject(); return new CreateSessionResponse(session, downstreamResponse); }
Example 2
Source File: DistributorStatus.java From selenium with Apache License 2.0 | 6 votes |
private static DistributorStatus fromJson(JsonInput input) { Set<NodeSummary> nodes = null; input.beginObject(); while (input.hasNext()) { switch (input.nextName()) { case "nodes": nodes = input.read(SUMMARIES_TYPES); break; default: input.skipValue(); } } input.endObject(); return new DistributorStatus(nodes); }
Example 3
Source File: Command.java From selenium with Apache License 2.0 | 5 votes |
private static Command fromJson(JsonInput input) { input.beginObject(); SessionId sessionId = null; String name = null; Map<String, Object> parameters = null; while (input.hasNext()) { switch (input.nextName()) { case "name": name = input.nextString(); break; case "parameters": parameters = input.read(MAP_TYPE); break; case "sessionId": sessionId = input.read(SessionId.class); break; default: input.skipValue(); break; } } input.endObject(); return new Command(sessionId, name, parameters); }
Example 4
Source File: ImageSummary.java From selenium with Apache License 2.0 | 5 votes |
static ImageSummary fromJson(JsonInput input) { input.beginObject(); ImageId id = null; List<String> repoTags = new ArrayList<>(); while (input.hasNext()) { switch (input.nextName()) { case "Id": id = new ImageId(input.nextString()); break; case "RepoTags": // This is a required field, but can be null. *sigh* List<String> tags = input.read(LIST_OF_STRING); if (tags != null) { repoTags = tags; } break; default: input.skipValue(); break; } } input.endObject(); return new ImageSummary(id, repoTags); }
Example 5
Source File: CreateSessionRequest.java From selenium with Apache License 2.0 | 5 votes |
private static CreateSessionRequest fromJson(JsonInput input) { Set<Dialect> downstreamDialects = null; Capabilities capabilities = null; Map<String, Object> metadata = null; input.beginObject(); while (input.hasNext()) { switch (input.nextName()) { case "capabilities": capabilities = input.read(Capabilities.class); break; case "downstreamDialects": downstreamDialects = input.read(new TypeToken<Set<Dialect>>(){}.getType()); break; case "metadata": metadata = input.read(MAP_TYPE); break; default: input.skipValue(); } } input.endObject(); return new CreateSessionRequest(downstreamDialects, capabilities, metadata); }
Example 6
Source File: DistributorStatus.java From selenium with Apache License 2.0 | 5 votes |
private static Map<Capabilities, Integer> readCapabilityCounts(JsonInput input) { Map<Capabilities, Integer> toReturn = new HashMap<>(); input.beginArray(); while (input.hasNext()) { Capabilities caps = null; int count = 0; input.beginObject(); while (input.hasNext()) { switch (input.nextName()) { case "capabilities": caps = input.read(Capabilities.class); break; case "count": count = input.nextNumber().intValue(); break; default: input.skipValue(); break; } } input.endObject(); toReturn.put(caps, count); } input.endArray(); return toReturn; }
Example 7
Source File: DistributorStatus.java From selenium with Apache License 2.0 | 4 votes |
private static NodeSummary fromJson(JsonInput input) { UUID nodeId = null; URI uri = null; boolean up = false; int maxSessionCount = 0; Map<Capabilities, Integer> stereotypes = new HashMap<>(); Map<Capabilities, Integer> used = new HashMap<>(); input.beginObject(); while (input.hasNext()) { switch (input.nextName()) { case "maxSessionCount": maxSessionCount = input.nextNumber().intValue(); break; case "nodeId": nodeId = input.read(UUID.class); break; case "stereotypes": stereotypes = readCapabilityCounts(input); break; case "up": up = input.nextBoolean(); break; case "uri": uri = input.read(URI.class); break; case "usedStereotypes": used = readCapabilityCounts(input); break; default: input.skipValue(); break; } } input.endObject(); return new NodeSummary(nodeId, uri, up, maxSessionCount, stereotypes, used); }