@Test public void serializeTest() { CallMessage callMessage = new CallMessage(1, "call"); assertThat(callMessage.getCode()).isEqualTo(48); assertThat(callMessage.getRequestId()).isEqualTo(1); assertThat(callMessage.getProcedure()).isEqualTo("call"); assertThat(callMessage.isDiscloseMe()).isFalse(); assertThat(callMessage.getArguments()).isNull(); assertThat(callMessage.getArgumentsKw()).isNull(); String json = serializeToJson(callMessage); assertThat(json).isEqualTo("[48,1,{},\"call\"]"); callMessage = new CallMessage(1, "call", Arrays.asList("Hello world")); assertThat(callMessage.getCode()).isEqualTo(48); assertThat(callMessage.getRequestId()).isEqualTo(1); assertThat(callMessage.getProcedure()).isEqualTo("call"); assertThat(callMessage.isDiscloseMe()).isFalse(); assertThat(callMessage.getArguments()).containsExactly("Hello world"); assertThat(callMessage.getArgumentsKw()).isNull(); json = serializeToJson(callMessage); assertThat(json).isEqualTo("[48,1,{},\"call\",[\"Hello world\"]]"); Map<String, Object> argumentsKw = new HashMap<>(); argumentsKw.put("firstname", "John"); argumentsKw.put("surname", "Doe"); callMessage = new CallMessage(1, "call", Arrays.asList("johnny"), argumentsKw, false); assertThat(callMessage.getCode()).isEqualTo(48); assertThat(callMessage.getRequestId()).isEqualTo(1); assertThat(callMessage.getProcedure()).isEqualTo("call"); assertThat(callMessage.isDiscloseMe()).isFalse(); assertThat(callMessage.getArguments()).containsExactly("johnny"); assertThat(callMessage.getArgumentsKw()).containsExactly( MapEntry.entry("firstname", "John"), MapEntry.entry("surname", "Doe")); json = serializeToJson(callMessage); assertThat(json).isEqualTo( "[48,1,{},\"call\",[\"johnny\"],{\"firstname\":\"John\",\"surname\":\"Doe\"}]"); callMessage = new CallMessage(1, "call", Arrays.asList("Hello world"), null, true); assertThat(callMessage.getCode()).isEqualTo(48); assertThat(callMessage.getRequestId()).isEqualTo(1); assertThat(callMessage.getProcedure()).isEqualTo("call"); assertThat(callMessage.isDiscloseMe()).isTrue(); assertThat(callMessage.getArguments()).containsExactly("Hello world"); assertThat(callMessage.getArgumentsKw()).isNull(); json = serializeToJson(callMessage); assertThat(json) .isEqualTo("[48,1,{\"disclose_me\":true},\"call\",[\"Hello world\"]]"); }
@Override public void serialize(JsonGenerator generator) throws IOException { generator.writeNumber(getCode()); generator.writeNumber(this.requestId); generator.writeStartObject(); if (this.discloseMe) { generator.writeBooleanField("disclose_me", this.discloseMe); } generator.writeEndObject(); generator.writeString(this.procedure); 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); } }
CallMessage extends WampMessage { @Override public void serialize(JsonGenerator generator) throws IOException { generator.writeNumber(getCode()); generator.writeNumber(this.requestId); generator.writeStartObject(); if (this.discloseMe) { generator.writeBooleanField("disclose_me", this.discloseMe); } generator.writeEndObject(); generator.writeString(this.procedure); 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); } } }
CallMessage extends WampMessage { @Override public void serialize(JsonGenerator generator) throws IOException { generator.writeNumber(getCode()); generator.writeNumber(this.requestId); generator.writeStartObject(); if (this.discloseMe) { generator.writeBooleanField("disclose_me", this.discloseMe); } generator.writeEndObject(); generator.writeString(this.procedure); 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); } } CallMessage(long request, String procedure);  CallMessage(long request, String procedure, @Nullable List<Object> arguments);  CallMessage(long request, String procedure,
			@Nullable Map<String, Object> argumentsKw);  CallMessage(long requestId, String procedure, @Nullable List<Object> arguments,
			@Nullable Map<String, Object> argumentsKw, boolean discloseMe); }
CallMessage extends WampMessage { @Override public void serialize(JsonGenerator generator) throws IOException { generator.writeNumber(getCode()); generator.writeNumber(this.requestId); generator.writeStartObject(); if (this.discloseMe) { generator.writeBooleanField("disclose_me", this.discloseMe); } generator.writeEndObject(); generator.writeString(this.procedure); 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); } } CallMessage(long request, String procedure);  CallMessage(long request, String procedure, @Nullable List<Object> arguments);  CallMessage(long request, String procedure,
			@Nullable Map<String, Object> argumentsKw);  CallMessage(long requestId, String procedure, @Nullable List<Object> arguments,
			@Nullable Map<String, Object> argumentsKw, boolean discloseMe); static CallMessage deserialize(JsonParser jp); @Override void serialize(JsonGenerator generator); long getRequestId(); String getProcedure(); @Nullable List<Object> getArguments(); @Nullable Map<String, Object> getArgumentsKw(); boolean isDiscloseMe(); @Override String toString(); }
CallMessage extends WampMessage { @Override public void serialize(JsonGenerator generator) throws IOException { generator.writeNumber(getCode()); generator.writeNumber(this.requestId); generator.writeStartObject(); if (this.discloseMe) { generator.writeBooleanField("disclose_me", this.discloseMe); } generator.writeEndObject(); generator.writeString(this.procedure); 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); } } CallMessage(long request, String procedure);  CallMessage(long request, String procedure, @Nullable List<Object> arguments);  CallMessage(long request, String procedure,
			@Nullable Map<String, Object> argumentsKw);  CallMessage(long requestId, String procedure, @Nullable List<Object> arguments,
			@Nullable Map<String, Object> argumentsKw, boolean discloseMe); static CallMessage deserialize(JsonParser jp); @Override void serialize(JsonGenerator generator); long getRequestId(); String getProcedure(); @Nullable List<Object> getArguments(); @Nullable Map<String, Object> getArgumentsKw(); boolean isDiscloseMe(); @Override String toString(); static final int CODE; }