@Test public void serializeTest() { SubscribeMessage subscribeMessage = new SubscribeMessage(1, "topic", MatchPolicy.PREFIX, false); 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(); String json = serializeToJson(subscribeMessage); assertThat(json).isEqualTo("[32,1,{\"match\":\"prefix\"},\"topic\"]"); subscribeMessage = new SubscribeMessage(2, "topic2"); 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 = serializeToJson(subscribeMessage); assertThat(json).isEqualTo("[32,2,{},\"topic2\"]"); subscribeMessage = new SubscribeMessage(2, "topic2", true); 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 = serializeToJson(subscribeMessage); assertThat(json).isEqualTo("[32,2,{\"get_retained\":true},\"topic2\"]"); subscribeMessage = new SubscribeMessage(2, "topic2", MatchPolicy.WILDCARD, true); 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(); json = serializeToJson(subscribeMessage); assertThat(json).isEqualTo( "[32,2,{\"match\":\"wildcard\",\"get_retained\":true},\"topic2\"]"); }
@Override public void serialize(JsonGenerator generator) throws IOException { generator.writeNumber(getCode()); generator.writeNumber(this.requestId); generator.writeStartObject(); if (this.matchPolicy != MatchPolicy.EXACT) { generator.writeStringField("match", this.matchPolicy.getExternalValue()); } if (this.getRetained) { generator.writeBooleanField("get_retained", this.getRetained); } generator.writeEndObject(); generator.writeString(this.topic); }
SubscribeMessage extends WampMessage { @Override public void serialize(JsonGenerator generator) throws IOException { generator.writeNumber(getCode()); generator.writeNumber(this.requestId); generator.writeStartObject(); if (this.matchPolicy != MatchPolicy.EXACT) { generator.writeStringField("match", this.matchPolicy.getExternalValue()); } if (this.getRetained) { generator.writeBooleanField("get_retained", this.getRetained); } generator.writeEndObject(); generator.writeString(this.topic); } }
SubscribeMessage extends WampMessage { @Override public void serialize(JsonGenerator generator) throws IOException { generator.writeNumber(getCode()); generator.writeNumber(this.requestId); generator.writeStartObject(); if (this.matchPolicy != MatchPolicy.EXACT) { generator.writeStringField("match", this.matchPolicy.getExternalValue()); } if (this.getRetained) { generator.writeBooleanField("get_retained", this.getRetained); } generator.writeEndObject(); generator.writeString(this.topic); } 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 { @Override public void serialize(JsonGenerator generator) throws IOException { generator.writeNumber(getCode()); generator.writeNumber(this.requestId); generator.writeStartObject(); if (this.matchPolicy != MatchPolicy.EXACT) { generator.writeStringField("match", this.matchPolicy.getExternalValue()); } if (this.getRetained) { generator.writeBooleanField("get_retained", this.getRetained); } generator.writeEndObject(); generator.writeString(this.topic); } 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 { @Override public void serialize(JsonGenerator generator) throws IOException { generator.writeNumber(getCode()); generator.writeNumber(this.requestId); generator.writeStartObject(); if (this.matchPolicy != MatchPolicy.EXACT) { generator.writeStringField("match", this.matchPolicy.getExternalValue()); } if (this.getRetained) { generator.writeBooleanField("get_retained", this.getRetained); } generator.writeEndObject(); generator.writeString(this.topic); } 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; }