(Map<String, Object> json)
| 81 | } |
| 82 | |
| 83 | private static Response fromJson(Map<String, Object> json) { |
| 84 | Response response = new Response(); |
| 85 | |
| 86 | if (json.get("error") instanceof String) { |
| 87 | response.setState((String) json.get("error")); |
| 88 | response.setValue(json.get("message")); |
| 89 | } |
| 90 | |
| 91 | if (json.get("state") instanceof String) { |
| 92 | response.setState((String) json.get("state")); |
| 93 | } |
| 94 | |
| 95 | if (json.get("status") != null) { |
| 96 | Object status = json.get("status"); |
| 97 | if (status instanceof String) { |
| 98 | response.setState((String) status); |
| 99 | } else { |
| 100 | // JSON Wire payloads carry an integer status; read it, but only as the W3C state. |
| 101 | response.setState(new ErrorCodes().toState(((Number) status).intValue())); |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | if (json.get("sessionId") instanceof String) { |
| 106 | response.setSessionId((String) json.get("sessionId")); |
| 107 | } |
| 108 | |
| 109 | response.setValue(json.getOrDefault("value", json)); |
| 110 | |
| 111 | return response; |
| 112 | } |
| 113 | } |
nothing calls this directly
no test coverage detected