@Test public void serializeTest() { ErrorMessage errorMessage = new ErrorMessage(64, 25349185L, "wamp.error.procedure_already_exists", null, null); assertThat(errorMessage.getCode()).isEqualTo(8); assertThat(errorMessage.getType()).isEqualTo(64); assertThat(errorMessage.getRequestId()).isEqualTo(25349185L); assertThat(errorMessage.getError()) .isEqualTo("wamp.error.procedure_already_exists"); assertThat(errorMessage.getArguments()).isNull(); assertThat(errorMessage.getArgumentsKw()).isNull(); String json = serializeToJson(errorMessage); assertThat(json) .isEqualTo("[8,64,25349185,{},\"wamp.error.procedure_already_exists\"]"); errorMessage = new ErrorMessage(66, 788923562L, "wamp.error.no_such_registration", Collections.singletonList("No such registration"), null); assertThat(errorMessage.getCode()).isEqualTo(8); assertThat(errorMessage.getType()).isEqualTo(66); assertThat(errorMessage.getRequestId()).isEqualTo(788923562L); assertThat(errorMessage.getError()).isEqualTo("wamp.error.no_such_registration"); assertThat(errorMessage.getArguments()).containsExactly("No such registration"); assertThat(errorMessage.getArgumentsKw()).isNull(); json = serializeToJson(errorMessage); assertThat(json).isEqualTo( "[8,66,788923562,{},\"wamp.error.no_such_registration\",[\"No such registration\"]]"); errorMessage = new ErrorMessage(68, 6131533L, "com.myapp.error.object_write_protected", Collections.singletonList("Object is write protected."), Collections.singletonMap("severity", 3)); assertThat(errorMessage.getCode()).isEqualTo(8); assertThat(errorMessage.getType()).isEqualTo(68); assertThat(errorMessage.getRequestId()).isEqualTo(6131533L); assertThat(errorMessage.getError()) .isEqualTo("com.myapp.error.object_write_protected"); assertThat(errorMessage.getArguments()) .containsExactly("Object is write protected."); assertThat(errorMessage.getArgumentsKw()) .containsExactly(MapEntry.entry("severity", 3)); json = serializeToJson(errorMessage); assertThat(json).isEqualTo( "[8,68,6131533,{},\"com.myapp.error.object_write_protected\",[\"Object is write protected.\"],{\"severity\":3}]"); }
@Override public void serialize(JsonGenerator generator) throws IOException { generator.writeNumber(getCode()); generator.writeNumber(this.type); generator.writeNumber(this.requestId); generator.writeStartObject(); generator.writeEndObject(); generator.writeString(this.error); 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); } }
ErrorMessage extends WampMessage { @Override public void serialize(JsonGenerator generator) throws IOException { generator.writeNumber(getCode()); generator.writeNumber(this.type); generator.writeNumber(this.requestId); generator.writeStartObject(); generator.writeEndObject(); generator.writeString(this.error); 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); } } }
ErrorMessage extends WampMessage { @Override public void serialize(JsonGenerator generator) throws IOException { generator.writeNumber(getCode()); generator.writeNumber(this.type); generator.writeNumber(this.requestId); generator.writeStartObject(); generator.writeEndObject(); generator.writeString(this.error); 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); } } ErrorMessage(int type, long requestId, String error,
			@Nullable List<Object> arguments, @Nullable Map<String, Object> argumentsKw);  ErrorMessage(ErrorMessage errorMessage, CallMessage callMessage);  ErrorMessage(SubscribeMessage subscribeMessage, WampError error);  ErrorMessage(UnsubscribeMessage unsubscribeMessage, WampError error);  ErrorMessage(PublishMessage publishMessage, WampError error);  ErrorMessage(RegisterMessage registerMessage, WampError error);  ErrorMessage(UnregisterMessage unregisterMessage, WampError error);  ErrorMessage(CallMessage callMessage, WampError error);  ErrorMessage(CallMessage callMessage, String error,
			@Nullable List<Object> arguments, @Nullable Map<String, Object> argumentsKw);  ErrorMessage(InvocationMessage invocationMessage, WampError error); }
ErrorMessage extends WampMessage { @Override public void serialize(JsonGenerator generator) throws IOException { generator.writeNumber(getCode()); generator.writeNumber(this.type); generator.writeNumber(this.requestId); generator.writeStartObject(); generator.writeEndObject(); generator.writeString(this.error); 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); } } ErrorMessage(int type, long requestId, String error,
			@Nullable List<Object> arguments, @Nullable Map<String, Object> argumentsKw);  ErrorMessage(ErrorMessage errorMessage, CallMessage callMessage);  ErrorMessage(SubscribeMessage subscribeMessage, WampError error);  ErrorMessage(UnsubscribeMessage unsubscribeMessage, WampError error);  ErrorMessage(PublishMessage publishMessage, WampError error);  ErrorMessage(RegisterMessage registerMessage, WampError error);  ErrorMessage(UnregisterMessage unregisterMessage, WampError error);  ErrorMessage(CallMessage callMessage, WampError error);  ErrorMessage(CallMessage callMessage, String error,
			@Nullable List<Object> arguments, @Nullable Map<String, Object> argumentsKw);  ErrorMessage(InvocationMessage invocationMessage, WampError error); static ErrorMessage deserialize(JsonParser jp); @Override void serialize(JsonGenerator generator); int getType(); long getRequestId(); String getError(); @Nullable List<Object> getArguments(); @Nullable Map<String, Object> getArgumentsKw(); @Override String toString(); }
ErrorMessage extends WampMessage { @Override public void serialize(JsonGenerator generator) throws IOException { generator.writeNumber(getCode()); generator.writeNumber(this.type); generator.writeNumber(this.requestId); generator.writeStartObject(); generator.writeEndObject(); generator.writeString(this.error); 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); } } ErrorMessage(int type, long requestId, String error,
			@Nullable List<Object> arguments, @Nullable Map<String, Object> argumentsKw);  ErrorMessage(ErrorMessage errorMessage, CallMessage callMessage);  ErrorMessage(SubscribeMessage subscribeMessage, WampError error);  ErrorMessage(UnsubscribeMessage unsubscribeMessage, WampError error);  ErrorMessage(PublishMessage publishMessage, WampError error);  ErrorMessage(RegisterMessage registerMessage, WampError error);  ErrorMessage(UnregisterMessage unregisterMessage, WampError error);  ErrorMessage(CallMessage callMessage, WampError error);  ErrorMessage(CallMessage callMessage, String error,
			@Nullable List<Object> arguments, @Nullable Map<String, Object> argumentsKw);  ErrorMessage(InvocationMessage invocationMessage, WampError error); static ErrorMessage deserialize(JsonParser jp); @Override void serialize(JsonGenerator generator); int getType(); long getRequestId(); String getError(); @Nullable List<Object> getArguments(); @Nullable Map<String, Object> getArgumentsKw(); @Override String toString();  }