@Test public void deserializeTest() throws IOException { String json = "[35, 85346237]"; UnsubscribedMessage unsubscribedMessage = WampMessage .deserialize(getJsonFactory(), json.getBytes(StandardCharsets.UTF_8)); assertThat(unsubscribedMessage.getCode()).isEqualTo(35); assertThat(unsubscribedMessage.getRequestId()).isEqualTo(85346237L); assertThat(unsubscribedMessage.getSubscriptionId()).isNull(); assertThat(unsubscribedMessage.getReason()).isNull(); json = "[35, 0, {\"subscription\":1213,\"reason\":\"the reason\"}]"; unsubscribedMessage = WampMessage.deserialize(getJsonFactory(), json.getBytes(StandardCharsets.UTF_8)); assertThat(unsubscribedMessage.getCode()).isEqualTo(35); assertThat(unsubscribedMessage.getRequestId()).isEqualTo(0); assertThat(unsubscribedMessage.getSubscriptionId()).isEqualTo(1213L); assertThat(unsubscribedMessage.getReason()).isEqualTo("the reason"); }
public static UnsubscribedMessage deserialize(JsonParser jp) throws IOException { jp.nextToken(); long request = jp.getLongValue(); Long subscriptionId = null; String reason = null; JsonToken token = jp.nextToken(); if (token == JsonToken.START_OBJECT) { Map<String, Object> details = ParserUtil.readObject(jp); reason = (String) details.get("reason"); Object subscriptionObj = details.get("subscription"); if (subscriptionObj != null) { subscriptionId = ((Number) subscriptionObj).longValue(); } } return new UnsubscribedMessage(request, subscriptionId, reason); }
UnsubscribedMessage extends WampMessage { public static UnsubscribedMessage deserialize(JsonParser jp) throws IOException { jp.nextToken(); long request = jp.getLongValue(); Long subscriptionId = null; String reason = null; JsonToken token = jp.nextToken(); if (token == JsonToken.START_OBJECT) { Map<String, Object> details = ParserUtil.readObject(jp); reason = (String) details.get("reason"); Object subscriptionObj = details.get("subscription"); if (subscriptionObj != null) { subscriptionId = ((Number) subscriptionObj).longValue(); } } return new UnsubscribedMessage(request, subscriptionId, reason); } }
UnsubscribedMessage extends WampMessage { public static UnsubscribedMessage deserialize(JsonParser jp) throws IOException { jp.nextToken(); long request = jp.getLongValue(); Long subscriptionId = null; String reason = null; JsonToken token = jp.nextToken(); if (token == JsonToken.START_OBJECT) { Map<String, Object> details = ParserUtil.readObject(jp); reason = (String) details.get("reason"); Object subscriptionObj = details.get("subscription"); if (subscriptionObj != null) { subscriptionId = ((Number) subscriptionObj).longValue(); } } return new UnsubscribedMessage(request, subscriptionId, reason); } UnsubscribedMessage(long requestId);  UnsubscribedMessage(long requestId, @Nullable Long subscriptionId,
			@Nullable String reason);  UnsubscribedMessage(UnsubscribeMessage unsubscribeMessage); }
UnsubscribedMessage extends WampMessage { public static UnsubscribedMessage deserialize(JsonParser jp) throws IOException { jp.nextToken(); long request = jp.getLongValue(); Long subscriptionId = null; String reason = null; JsonToken token = jp.nextToken(); if (token == JsonToken.START_OBJECT) { Map<String, Object> details = ParserUtil.readObject(jp); reason = (String) details.get("reason"); Object subscriptionObj = details.get("subscription"); if (subscriptionObj != null) { subscriptionId = ((Number) subscriptionObj).longValue(); } } return new UnsubscribedMessage(request, subscriptionId, reason); } UnsubscribedMessage(long requestId);  UnsubscribedMessage(long requestId, @Nullable Long subscriptionId,
			@Nullable String reason);  UnsubscribedMessage(UnsubscribeMessage unsubscribeMessage); static UnsubscribedMessage deserialize(JsonParser jp); @Override void serialize(JsonGenerator generator); long getRequestId(); @Nullable Long getSubscriptionId(); @Nullable String getReason(); @Override String toString(); }
UnsubscribedMessage extends WampMessage { public static UnsubscribedMessage deserialize(JsonParser jp) throws IOException { jp.nextToken(); long request = jp.getLongValue(); Long subscriptionId = null; String reason = null; JsonToken token = jp.nextToken(); if (token == JsonToken.START_OBJECT) { Map<String, Object> details = ParserUtil.readObject(jp); reason = (String) details.get("reason"); Object subscriptionObj = details.get("subscription"); if (subscriptionObj != null) { subscriptionId = ((Number) subscriptionObj).longValue(); } } return new UnsubscribedMessage(request, subscriptionId, reason); } UnsubscribedMessage(long requestId);  UnsubscribedMessage(long requestId, @Nullable Long subscriptionId,
			@Nullable String reason);  UnsubscribedMessage(UnsubscribeMessage unsubscribeMessage); static UnsubscribedMessage deserialize(JsonParser jp); @Override void serialize(JsonGenerator generator); long getRequestId(); @Nullable Long getSubscriptionId(); @Nullable String getReason(); @Override String toString();  }