@Test public void deserializeTest() throws IOException { String json = "[32,1,{\"match\":\"prefix\"},\"topic\"]"; SubscribeMessage subscribeMessage = WampMessage.deserialize(getJsonFactory(), json.getBytes(StandardCharsets.UTF_8)); assertThat(subscribeMessage.getCode()).isEqualTo(32); assertThat(subscribeMessage.getRequestId()).isEqualTo(1); assertThat(subscribeMessage.getTopic()).isEqualTo("topic"); assertThat(subscribeMessage.getMatchPolicy()).isEqualTo(MatchPolicy.PREFIX); assertThat(subscribeMessage.isGetRetained()).isFalse(); json = "[32,2,{},\"topic2\"]"; subscribeMessage = WampMessage.deserialize(getJsonFactory(), json.getBytes(StandardCharsets.UTF_8)); assertThat(subscribeMessage.getCode()).isEqualTo(32); assertThat(subscribeMessage.getRequestId()).isEqualTo(2); assertThat(subscribeMessage.getTopic()).isEqualTo("topic2"); assertThat(subscribeMessage.getMatchPolicy()).isEqualTo(MatchPolicy.EXACT); assertThat(subscribeMessage.isGetRetained()).isFalse(); json = "[32,2,{\"get_retained\":false},\"topic2\"]"; subscribeMessage = WampMessage.deserialize(getJsonFactory(), json.getBytes(StandardCharsets.UTF_8)); assertThat(subscribeMessage.getCode()).isEqualTo(32); assertThat(subscribeMessage.getRequestId()).isEqualTo(2); assertThat(subscribeMessage.getTopic()).isEqualTo("topic2"); assertThat(subscribeMessage.getMatchPolicy()).isEqualTo(MatchPolicy.EXACT); assertThat(subscribeMessage.isGetRetained()).isFalse(); json = "[32,2,{\"get_retained\":true},\"topic2\"]"; subscribeMessage = WampMessage.deserialize(getJsonFactory(), json.getBytes(StandardCharsets.UTF_8)); assertThat(subscribeMessage.getCode()).isEqualTo(32); assertThat(subscribeMessage.getRequestId()).isEqualTo(2); assertThat(subscribeMessage.getTopic()).isEqualTo("topic2"); assertThat(subscribeMessage.getMatchPolicy()).isEqualTo(MatchPolicy.EXACT); assertThat(subscribeMessage.isGetRetained()).isTrue(); json = "[32,2,{\"match\":\"wildcard\",\"get_retained\":true},\"topic2\"]"; subscribeMessage = WampMessage.deserialize(getJsonFactory(), json.getBytes(StandardCharsets.UTF_8)); assertThat(subscribeMessage.getCode()).isEqualTo(32); assertThat(subscribeMessage.getRequestId()).isEqualTo(2); assertThat(subscribeMessage.getTopic()).isEqualTo("topic2"); assertThat(subscribeMessage.getMatchPolicy()).isEqualTo(MatchPolicy.WILDCARD); assertThat(subscribeMessage.isGetRetained()).isTrue(); }
public static SubscribeMessage deserialize(JsonParser jp) throws IOException { jp.nextToken(); long request = jp.getLongValue(); MatchPolicy match = MatchPolicy.EXACT; jp.nextToken(); boolean getRetained = false; Map<String, Object> options = ParserUtil.readObject(jp); if (options != null) { String extValue = (String) options.get("match"); if (extValue != null) { match = MatchPolicy.fromExtValue(extValue); if (match == null) { match = MatchPolicy.EXACT; } } getRetained = (boolean) options.getOrDefault("get_retained", false); } jp.nextToken(); String topic = jp.getValueAsString(); return new SubscribeMessage(request, topic, match, getRetained); }
SubscribeMessage extends WampMessage { public static SubscribeMessage deserialize(JsonParser jp) throws IOException { jp.nextToken(); long request = jp.getLongValue(); MatchPolicy match = MatchPolicy.EXACT; jp.nextToken(); boolean getRetained = false; Map<String, Object> options = ParserUtil.readObject(jp); if (options != null) { String extValue = (String) options.get("match"); if (extValue != null) { match = MatchPolicy.fromExtValue(extValue); if (match == null) { match = MatchPolicy.EXACT; } } getRetained = (boolean) options.getOrDefault("get_retained", false); } jp.nextToken(); String topic = jp.getValueAsString(); return new SubscribeMessage(request, topic, match, getRetained); } }
SubscribeMessage extends WampMessage { public static SubscribeMessage deserialize(JsonParser jp) throws IOException { jp.nextToken(); long request = jp.getLongValue(); MatchPolicy match = MatchPolicy.EXACT; jp.nextToken(); boolean getRetained = false; Map<String, Object> options = ParserUtil.readObject(jp); if (options != null) { String extValue = (String) options.get("match"); if (extValue != null) { match = MatchPolicy.fromExtValue(extValue); if (match == null) { match = MatchPolicy.EXACT; } } getRetained = (boolean) options.getOrDefault("get_retained", false); } jp.nextToken(); String topic = jp.getValueAsString(); return new SubscribeMessage(request, topic, match, getRetained); } SubscribeMessage(long requestId, String topic);  SubscribeMessage(long requestId, String topic, boolean get_retained);  SubscribeMessage(long requestId, String topic, MatchPolicy match);  SubscribeMessage(long requestId, String topic, MatchPolicy match,
			boolean getRetained); }
SubscribeMessage extends WampMessage { public static SubscribeMessage deserialize(JsonParser jp) throws IOException { jp.nextToken(); long request = jp.getLongValue(); MatchPolicy match = MatchPolicy.EXACT; jp.nextToken(); boolean getRetained = false; Map<String, Object> options = ParserUtil.readObject(jp); if (options != null) { String extValue = (String) options.get("match"); if (extValue != null) { match = MatchPolicy.fromExtValue(extValue); if (match == null) { match = MatchPolicy.EXACT; } } getRetained = (boolean) options.getOrDefault("get_retained", false); } jp.nextToken(); String topic = jp.getValueAsString(); return new SubscribeMessage(request, topic, match, getRetained); } SubscribeMessage(long requestId, String topic);  SubscribeMessage(long requestId, String topic, boolean get_retained);  SubscribeMessage(long requestId, String topic, MatchPolicy match);  SubscribeMessage(long requestId, String topic, MatchPolicy match,
			boolean getRetained); static SubscribeMessage deserialize(JsonParser jp); @Override void serialize(JsonGenerator generator); long getRequestId(); MatchPolicy getMatchPolicy(); String getTopic(); boolean isGetRetained(); @Override String toString(); }
SubscribeMessage extends WampMessage { public static SubscribeMessage deserialize(JsonParser jp) throws IOException { jp.nextToken(); long request = jp.getLongValue(); MatchPolicy match = MatchPolicy.EXACT; jp.nextToken(); boolean getRetained = false; Map<String, Object> options = ParserUtil.readObject(jp); if (options != null) { String extValue = (String) options.get("match"); if (extValue != null) { match = MatchPolicy.fromExtValue(extValue); if (match == null) { match = MatchPolicy.EXACT; } } getRetained = (boolean) options.getOrDefault("get_retained", false); } jp.nextToken(); String topic = jp.getValueAsString(); return new SubscribeMessage(request, topic, match, getRetained); } SubscribeMessage(long requestId, String topic);  SubscribeMessage(long requestId, String topic, boolean get_retained);  SubscribeMessage(long requestId, String topic, MatchPolicy match);  SubscribeMessage(long requestId, String topic, MatchPolicy match,
			boolean getRetained); static SubscribeMessage deserialize(JsonParser jp); @Override void serialize(JsonGenerator generator); long getRequestId(); MatchPolicy getMatchPolicy(); String getTopic(); boolean isGetRetained(); @Override String toString(); static final int CODE; }