@Test public void deserializeTest() throws IOException { String json = "[8, 64, 25349185, {}, \"wamp.error.procedure_already_exists\"]"; ErrorMessage errorMessage = WampMessage.deserialize(getJsonFactory(), json.getBytes(StandardCharsets.UTF_8)); 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(); json = "[8, 66, 788923562, {}, \"wamp.error.no_such_registration\",[\"No such registration\"]]"; errorMessage = WampMessage.deserialize(getJsonFactory(), json.getBytes(StandardCharsets.UTF_8)); 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 = "[8, 68, 6131533, {}, \"com.myapp.error.object_write_protected\", [\"Object is write protected.\"], {\"severity\": 3}]"; errorMessage = WampMessage.deserialize(getJsonFactory(), json.getBytes(StandardCharsets.UTF_8)); 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)); }
public static ErrorMessage deserialize(JsonParser jp) throws IOException { jp.nextToken(); int type = jp.getIntValue(); jp.nextToken(); long request = jp.getLongValue(); jp.nextToken(); ParserUtil.readObject(jp); jp.nextToken(); String error = jp.getValueAsString(); List<Object> arguments = null; JsonToken token = jp.nextToken(); if (token == JsonToken.START_ARRAY) { arguments = ParserUtil.readArray(jp); } Map<String, Object> argumentsKw = null; token = jp.nextToken(); if (token == JsonToken.START_OBJECT) { argumentsKw = ParserUtil.readObject(jp); } return new ErrorMessage(type, request, error, arguments, argumentsKw); }
ErrorMessage extends WampMessage { public static ErrorMessage deserialize(JsonParser jp) throws IOException { jp.nextToken(); int type = jp.getIntValue(); jp.nextToken(); long request = jp.getLongValue(); jp.nextToken(); ParserUtil.readObject(jp); jp.nextToken(); String error = jp.getValueAsString(); List<Object> arguments = null; JsonToken token = jp.nextToken(); if (token == JsonToken.START_ARRAY) { arguments = ParserUtil.readArray(jp); } Map<String, Object> argumentsKw = null; token = jp.nextToken(); if (token == JsonToken.START_OBJECT) { argumentsKw = ParserUtil.readObject(jp); } return new ErrorMessage(type, request, error, arguments, argumentsKw); } }
ErrorMessage extends WampMessage { public static ErrorMessage deserialize(JsonParser jp) throws IOException { jp.nextToken(); int type = jp.getIntValue(); jp.nextToken(); long request = jp.getLongValue(); jp.nextToken(); ParserUtil.readObject(jp); jp.nextToken(); String error = jp.getValueAsString(); List<Object> arguments = null; JsonToken token = jp.nextToken(); if (token == JsonToken.START_ARRAY) { arguments = ParserUtil.readArray(jp); } Map<String, Object> argumentsKw = null; token = jp.nextToken(); if (token == JsonToken.START_OBJECT) { argumentsKw = ParserUtil.readObject(jp); } return new ErrorMessage(type, request, error, arguments, argumentsKw); } 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 { public static ErrorMessage deserialize(JsonParser jp) throws IOException { jp.nextToken(); int type = jp.getIntValue(); jp.nextToken(); long request = jp.getLongValue(); jp.nextToken(); ParserUtil.readObject(jp); jp.nextToken(); String error = jp.getValueAsString(); List<Object> arguments = null; JsonToken token = jp.nextToken(); if (token == JsonToken.START_ARRAY) { arguments = ParserUtil.readArray(jp); } Map<String, Object> argumentsKw = null; token = jp.nextToken(); if (token == JsonToken.START_OBJECT) { argumentsKw = ParserUtil.readObject(jp); } return new ErrorMessage(type, request, error, arguments, argumentsKw); } 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 { public static ErrorMessage deserialize(JsonParser jp) throws IOException { jp.nextToken(); int type = jp.getIntValue(); jp.nextToken(); long request = jp.getLongValue(); jp.nextToken(); ParserUtil.readObject(jp); jp.nextToken(); String error = jp.getValueAsString(); List<Object> arguments = null; JsonToken token = jp.nextToken(); if (token == JsonToken.START_ARRAY) { arguments = ParserUtil.readArray(jp); } Map<String, Object> argumentsKw = null; token = jp.nextToken(); if (token == JsonToken.START_OBJECT) { argumentsKw = ParserUtil.readObject(jp); } return new ErrorMessage(type, request, error, arguments, argumentsKw); } 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();  }