@Test public void serializeTest() { EventMessage eventMessage = new EventMessage(1, 2, null, null, false, null, null); assertThat(eventMessage.getCode()).isEqualTo(36); assertThat(eventMessage.getSubscriptionId()).isEqualTo(1); assertThat(eventMessage.getPublicationId()).isEqualTo(2); assertThat(eventMessage.getTopic()).isNull(); assertThat(eventMessage.getPublisher()).isNull(); assertThat(eventMessage.isRetained()).isFalse(); assertThat(eventMessage.getArguments()).isNull(); assertThat(eventMessage.getArgumentsKw()).isNull(); String json = serializeToJson(eventMessage); assertThat(json).isEqualTo("[36,1,2,{}]"); eventMessage = new EventMessage(1, 2, null, null, false, Collections.singletonList("Hello, world!"), null); assertThat(eventMessage.getCode()).isEqualTo(36); assertThat(eventMessage.getSubscriptionId()).isEqualTo(1); assertThat(eventMessage.getPublicationId()).isEqualTo(2); assertThat(eventMessage.getTopic()).isNull(); assertThat(eventMessage.getPublisher()).isNull(); assertThat(eventMessage.isRetained()).isFalse(); assertThat(eventMessage.getArguments()).containsExactly("Hello, world!"); assertThat(eventMessage.getArgumentsKw()).isNull(); json = serializeToJson(eventMessage); assertThat(json).isEqualTo("[36,1,2,{},[\"Hello, world!\"]]"); Map<String, Object> argumentsKw = new HashMap<>(); argumentsKw.put("firstname", "John"); argumentsKw.put("surname", "Doe"); eventMessage = new EventMessage(1, 2, null, null, false, Arrays.asList("johnny"), argumentsKw); assertThat(eventMessage.getCode()).isEqualTo(36); assertThat(eventMessage.getSubscriptionId()).isEqualTo(1); assertThat(eventMessage.getPublicationId()).isEqualTo(2); assertThat(eventMessage.getTopic()).isNull(); assertThat(eventMessage.getPublisher()).isNull(); assertThat(eventMessage.isRetained()).isFalse(); assertThat(eventMessage.getArguments()).containsExactly("johnny"); assertThat(eventMessage.getArgumentsKw()).containsExactly( MapEntry.entry("firstname", "John"), MapEntry.entry("surname", "Doe")); json = serializeToJson(eventMessage); assertThat(json).isEqualTo( "[36,1,2,{},[\"johnny\"],{\"firstname\":\"John\",\"surname\":\"Doe\"}]"); eventMessage = new EventMessage(1, 2, null, null, false, null, argumentsKw); assertThat(eventMessage.getCode()).isEqualTo(36); assertThat(eventMessage.getSubscriptionId()).isEqualTo(1); assertThat(eventMessage.getPublicationId()).isEqualTo(2); assertThat(eventMessage.getTopic()).isNull(); assertThat(eventMessage.getPublisher()).isNull(); assertThat(eventMessage.isRetained()).isFalse(); assertThat(eventMessage.getArguments()).isNull(); assertThat(eventMessage.getArgumentsKw()).containsExactly( MapEntry.entry("firstname", "John"), MapEntry.entry("surname", "Doe")); json = serializeToJson(eventMessage); assertThat(json) .isEqualTo("[36,1,2,{},[],{\"firstname\":\"John\",\"surname\":\"Doe\"}]"); eventMessage = new EventMessage(1, 2, "topic", null, false, Collections.singletonList(42), null); assertThat(eventMessage.getCode()).isEqualTo(36); assertThat(eventMessage.getSubscriptionId()).isEqualTo(1); assertThat(eventMessage.getPublicationId()).isEqualTo(2); assertThat(eventMessage.getTopic()).isEqualTo("topic"); assertThat(eventMessage.getPublisher()).isNull(); assertThat(eventMessage.isRetained()).isFalse(); assertThat(eventMessage.getArguments()).containsExactly(42); assertThat(eventMessage.getArgumentsKw()).isNull(); json = serializeToJson(eventMessage); assertThat(json).isEqualTo("[36,1,2,{\"topic\":\"topic\"},[42]]"); eventMessage = new EventMessage(1, 2, "topic", 123, false, Collections.singletonList(42), null); assertThat(eventMessage.getCode()).isEqualTo(36); assertThat(eventMessage.getSubscriptionId()).isEqualTo(1); assertThat(eventMessage.getPublicationId()).isEqualTo(2); assertThat(eventMessage.getTopic()).isEqualTo("topic"); assertThat(eventMessage.getPublisher()).isEqualTo(123); assertThat(eventMessage.isRetained()).isFalse(); assertThat(eventMessage.getArguments()).containsExactly(42); assertThat(eventMessage.getArgumentsKw()).isNull(); json = serializeToJson(eventMessage); assertThat(json) .isEqualTo("[36,1,2,{\"topic\":\"topic\",\"publisher\":123},[42]]"); eventMessage = new EventMessage(1, 2, null, null, true, Collections.singletonList(43), null); assertThat(eventMessage.getCode()).isEqualTo(36); assertThat(eventMessage.getSubscriptionId()).isEqualTo(1); assertThat(eventMessage.getPublicationId()).isEqualTo(2); assertThat(eventMessage.getTopic()).isNull(); assertThat(eventMessage.getPublisher()).isNull(); assertThat(eventMessage.isRetained()).isTrue(); assertThat(eventMessage.getArguments()).containsExactly(43); assertThat(eventMessage.getArgumentsKw()).isNull(); json = serializeToJson(eventMessage); assertThat(json).isEqualTo("[36,1,2,{\"retained\":true},[43]]"); }
@Override public void serialize(JsonGenerator generator) throws IOException { generator.writeNumber(getCode()); generator.writeNumber(this.subscriptionId); generator.writeNumber(this.publicationId); generator.writeStartObject(); if (this.topic != null) { generator.writeStringField("topic", this.topic); } if (this.publisher != null) { generator.writeNumberField("publisher", this.publisher.longValue()); } if (this.retained) { generator.writeBooleanField("retained", this.retained); } generator.writeEndObject(); if (this.argumentsKw != null) { if (this.arguments == null) { generator.writeStartArray(); generator.writeEndArray(); } else { generator.writeObject(this.arguments); } generator.writeObject(this.argumentsKw); } else if (this.arguments != null) { generator.writeObject(this.arguments); } }
EventMessage extends WampMessage { @Override public void serialize(JsonGenerator generator) throws IOException { generator.writeNumber(getCode()); generator.writeNumber(this.subscriptionId); generator.writeNumber(this.publicationId); generator.writeStartObject(); if (this.topic != null) { generator.writeStringField("topic", this.topic); } if (this.publisher != null) { generator.writeNumberField("publisher", this.publisher.longValue()); } if (this.retained) { generator.writeBooleanField("retained", this.retained); } generator.writeEndObject(); if (this.argumentsKw != null) { if (this.arguments == null) { generator.writeStartArray(); generator.writeEndArray(); } else { generator.writeObject(this.arguments); } generator.writeObject(this.argumentsKw); } else if (this.arguments != null) { generator.writeObject(this.arguments); } } }
EventMessage extends WampMessage { @Override public void serialize(JsonGenerator generator) throws IOException { generator.writeNumber(getCode()); generator.writeNumber(this.subscriptionId); generator.writeNumber(this.publicationId); generator.writeStartObject(); if (this.topic != null) { generator.writeStringField("topic", this.topic); } if (this.publisher != null) { generator.writeNumberField("publisher", this.publisher.longValue()); } if (this.retained) { generator.writeBooleanField("retained", this.retained); } generator.writeEndObject(); if (this.argumentsKw != null) { if (this.arguments == null) { generator.writeStartArray(); generator.writeEndArray(); } else { generator.writeObject(this.arguments); } generator.writeObject(this.argumentsKw); } else if (this.arguments != null) { generator.writeObject(this.arguments); } } EventMessage(long subscriptionId, long publicationId, @Nullable String topic,
			@Nullable Number publisher, boolean retained,
			@Nullable List<Object> arguments, @Nullable Map<String, Object> argumentsKw);  EventMessage(@Nullable String receiverWebSocketSessionId, long subscription,
			long publication, @Nullable String topic, @Nullable Number publisher,
			boolean retained, PublishMessage publishMessage); }
EventMessage extends WampMessage { @Override public void serialize(JsonGenerator generator) throws IOException { generator.writeNumber(getCode()); generator.writeNumber(this.subscriptionId); generator.writeNumber(this.publicationId); generator.writeStartObject(); if (this.topic != null) { generator.writeStringField("topic", this.topic); } if (this.publisher != null) { generator.writeNumberField("publisher", this.publisher.longValue()); } if (this.retained) { generator.writeBooleanField("retained", this.retained); } generator.writeEndObject(); if (this.argumentsKw != null) { if (this.arguments == null) { generator.writeStartArray(); generator.writeEndArray(); } else { generator.writeObject(this.arguments); } generator.writeObject(this.argumentsKw); } else if (this.arguments != null) { generator.writeObject(this.arguments); } } EventMessage(long subscriptionId, long publicationId, @Nullable String topic,
			@Nullable Number publisher, boolean retained,
			@Nullable List<Object> arguments, @Nullable Map<String, Object> argumentsKw);  EventMessage(@Nullable String receiverWebSocketSessionId, long subscription,
			long publication, @Nullable String topic, @Nullable Number publisher,
			boolean retained, PublishMessage publishMessage); static EventMessage deserialize(JsonParser jp); @Override void serialize(JsonGenerator generator); long getSubscriptionId(); long getPublicationId(); @Nullable String getTopic(); @Nullable Number getPublisher(); boolean isRetained(); @Nullable List<Object> getArguments(); @Nullable Map<String, Object> getArgumentsKw(); @Override String toString(); }
EventMessage extends WampMessage { @Override public void serialize(JsonGenerator generator) throws IOException { generator.writeNumber(getCode()); generator.writeNumber(this.subscriptionId); generator.writeNumber(this.publicationId); generator.writeStartObject(); if (this.topic != null) { generator.writeStringField("topic", this.topic); } if (this.publisher != null) { generator.writeNumberField("publisher", this.publisher.longValue()); } if (this.retained) { generator.writeBooleanField("retained", this.retained); } generator.writeEndObject(); if (this.argumentsKw != null) { if (this.arguments == null) { generator.writeStartArray(); generator.writeEndArray(); } else { generator.writeObject(this.arguments); } generator.writeObject(this.argumentsKw); } else if (this.arguments != null) { generator.writeObject(this.arguments); } } EventMessage(long subscriptionId, long publicationId, @Nullable String topic,
			@Nullable Number publisher, boolean retained,
			@Nullable List<Object> arguments, @Nullable Map<String, Object> argumentsKw);  EventMessage(@Nullable String receiverWebSocketSessionId, long subscription,
			long publication, @Nullable String topic, @Nullable Number publisher,
			boolean retained, PublishMessage publishMessage); static EventMessage deserialize(JsonParser jp); @Override void serialize(JsonGenerator generator); long getSubscriptionId(); long getPublicationId(); @Nullable String getTopic(); @Nullable Number getPublisher(); boolean isRetained(); @Nullable List<Object> getArguments(); @Nullable Map<String, Object> getArgumentsKw(); @Override String toString(); static final int CODE; }