### Question:
ResultMessage extends WampMessage { @Override public void serialize(JsonGenerator generator) throws IOException { generator.writeNumber(getCode()); generator.writeNumber(this.requestId); generator.writeStartObject(); 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); } } ResultMessage(long requestId, @Nullable List<Object> arguments,
			@Nullable Map<String, Object> argumentsKw);  ResultMessage(CallMessage callMessage, @Nullable List<Object> arguments,
			@Nullable Map<String, Object> argumentsKw);  ResultMessage(YieldMessage yieldMessage, CallMessage callMessage); static ResultMessage deserialize(JsonParser jp); @Override void serialize(JsonGenerator generator); long getRequestId(); @Nullable List<Object> getArguments(); @Nullable Map<String, Object> getArgumentsKw(); @Override String toString(); final long requestId; }### Answer:
@Test public void serializeTest() { ResultMessage resultMessage = new ResultMessage(111, null, null); assertThat(resultMessage.getCode()).isEqualTo(50); assertThat(resultMessage.getRequestId()).isEqualTo(111); assertThat(resultMessage.getArguments()).isNull(); assertThat(resultMessage.getArgumentsKw()).isNull(); String json = serializeToJson(resultMessage); assertThat(json).isEqualTo("[50,111,{}]"); resultMessage = new ResultMessage(111, Arrays.asList("Hello world"), null); assertThat(resultMessage.getCode()).isEqualTo(50); assertThat(resultMessage.getRequestId()).isEqualTo(111); assertThat(resultMessage.getArguments()).containsExactly("Hello world"); assertThat(resultMessage.getArgumentsKw()).isNull(); json = serializeToJson(resultMessage); assertThat(json).isEqualTo("[50,111,{},[\"Hello world\"]]"); Map<String, Object> argumentsKw = new HashMap<>(); argumentsKw.put("firstname", "John"); argumentsKw.put("surname", "Doe"); resultMessage = new ResultMessage(111, Arrays.asList("johnny"), argumentsKw); assertThat(resultMessage.getCode()).isEqualTo(50); assertThat(resultMessage.getRequestId()).isEqualTo(111); assertThat(resultMessage.getArguments()).containsExactly("johnny"); assertThat(resultMessage.getArgumentsKw()).containsExactly( MapEntry.entry("firstname", "John"), MapEntry.entry("surname", "Doe")); json = serializeToJson(resultMessage); assertThat(json).isEqualTo( "[50,111,{},[\"johnny\"],{\"firstname\":\"John\",\"surname\":\"Doe\"}]"); argumentsKw = new HashMap<>(); argumentsKw.put("firstname", "John"); argumentsKw.put("surname", "Doe"); resultMessage = new ResultMessage(111, null, argumentsKw); assertThat(resultMessage.getCode()).isEqualTo(50); assertThat(resultMessage.getRequestId()).isEqualTo(111); assertThat(resultMessage.getArguments()).isNull(); assertThat(resultMessage.getArgumentsKw()).containsExactly( MapEntry.entry("firstname", "John"), MapEntry.entry("surname", "Doe")); json = serializeToJson(resultMessage); assertThat(json) .isEqualTo("[50,111,{},[],{\"firstname\":\"John\",\"surname\":\"Doe\"}]"); }