@Test public void deserializeTest() throws IOException { String json = "[68, 6131533, 9823526, {}]"; InvocationMessage invocationMessage = WampMessage.deserialize(getJsonFactory(), json.getBytes(StandardCharsets.UTF_8)); assertThat(invocationMessage.getCode()).isEqualTo(68); assertThat(invocationMessage.getRequestId()).isEqualTo(6131533L); assertThat(invocationMessage.getRegistrationId()).isEqualTo(9823526L); assertThat(invocationMessage.getCaller()).isNull(); assertThat(invocationMessage.getArguments()).isNull(); assertThat(invocationMessage.getArgumentsKw()).isNull(); json = "[68, 6131533, 9823527, {}, [\"Hello, world!\"]]"; invocationMessage = WampMessage.deserialize(getJsonFactory(), json.getBytes(StandardCharsets.UTF_8)); assertThat(invocationMessage.getCode()).isEqualTo(68); assertThat(invocationMessage.getRequestId()).isEqualTo(6131533L); assertThat(invocationMessage.getRegistrationId()).isEqualTo(9823527L); assertThat(invocationMessage.getCaller()).isNull(); assertThat(invocationMessage.getArguments()).containsExactly("Hello, world!"); assertThat(invocationMessage.getArgumentsKw()).isNull(); json = "[68, 6131533, 9823528, {}, [23, 7]]"; invocationMessage = WampMessage.deserialize(getJsonFactory(), json.getBytes(StandardCharsets.UTF_8)); assertThat(invocationMessage.getCode()).isEqualTo(68); assertThat(invocationMessage.getRequestId()).isEqualTo(6131533L); assertThat(invocationMessage.getRegistrationId()).isEqualTo(9823528L); assertThat(invocationMessage.getCaller()).isNull(); assertThat(invocationMessage.getArguments()).containsExactly(23, 7); assertThat(invocationMessage.getArgumentsKw()).isNull(); json = "[68, 6131533, 9823529, {}, [\"johnny\"], {\"firstname\": \"John\",\"surname\": \"Doe\"}]"; invocationMessage = WampMessage.deserialize(getJsonFactory(), json.getBytes(StandardCharsets.UTF_8)); assertThat(invocationMessage.getCode()).isEqualTo(68); assertThat(invocationMessage.getRequestId()).isEqualTo(6131533L); assertThat(invocationMessage.getRegistrationId()).isEqualTo(9823529L); assertThat(invocationMessage.getCaller()).isNull(); assertThat(invocationMessage.getArguments()).containsExactly("johnny"); assertThat(invocationMessage.getArgumentsKw()).containsExactly( MapEntry.entry("firstname", "John"), MapEntry.entry("surname", "Doe")); json = "[68, 6131533, 9823528, {\"caller\": 3335656}, [23, 7]]"; invocationMessage = WampMessage.deserialize(getJsonFactory(), json.getBytes(StandardCharsets.UTF_8)); assertThat(invocationMessage.getCode()).isEqualTo(68); assertThat(invocationMessage.getRequestId()).isEqualTo(6131533L); assertThat(invocationMessage.getRegistrationId()).isEqualTo(9823528L); assertThat(invocationMessage.getCaller()).isEqualTo(3335656); assertThat(invocationMessage.getArguments()).containsExactly(23, 7); assertThat(invocationMessage.getArgumentsKw()).isNull(); }
public static InvocationMessage deserialize(JsonParser jp) throws IOException { jp.nextToken(); long request = jp.getLongValue(); jp.nextToken(); long registration = jp.getLongValue(); jp.nextToken(); Number caller = null; Map<String, Object> details = ParserUtil.readObject(jp); if (details != null) { caller = (Number) details.get("caller"); } 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 InvocationMessage(request, registration, caller, arguments, argumentsKw); }
InvocationMessage extends WampMessage { public static InvocationMessage deserialize(JsonParser jp) throws IOException { jp.nextToken(); long request = jp.getLongValue(); jp.nextToken(); long registration = jp.getLongValue(); jp.nextToken(); Number caller = null; Map<String, Object> details = ParserUtil.readObject(jp); if (details != null) { caller = (Number) details.get("caller"); } 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 InvocationMessage(request, registration, caller, arguments, argumentsKw); } }
InvocationMessage extends WampMessage { public static InvocationMessage deserialize(JsonParser jp) throws IOException { jp.nextToken(); long request = jp.getLongValue(); jp.nextToken(); long registration = jp.getLongValue(); jp.nextToken(); Number caller = null; Map<String, Object> details = ParserUtil.readObject(jp); if (details != null) { caller = (Number) details.get("caller"); } 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 InvocationMessage(request, registration, caller, arguments, argumentsKw); } InvocationMessage(long requestId, long registrationId, @Nullable Number caller,
			@Nullable List<Object> arguments, @Nullable Map<String, Object> argumentsKw);  InvocationMessage(Procedure procedure, CallMessage callMessage); }
InvocationMessage extends WampMessage { public static InvocationMessage deserialize(JsonParser jp) throws IOException { jp.nextToken(); long request = jp.getLongValue(); jp.nextToken(); long registration = jp.getLongValue(); jp.nextToken(); Number caller = null; Map<String, Object> details = ParserUtil.readObject(jp); if (details != null) { caller = (Number) details.get("caller"); } 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 InvocationMessage(request, registration, caller, arguments, argumentsKw); } InvocationMessage(long requestId, long registrationId, @Nullable Number caller,
			@Nullable List<Object> arguments, @Nullable Map<String, Object> argumentsKw);  InvocationMessage(Procedure procedure, CallMessage callMessage); static InvocationMessage deserialize(JsonParser jp); @Override void serialize(JsonGenerator generator); long getRequestId(); long getRegistrationId(); @Nullable List<Object> getArguments(); @Nullable Map<String, Object> getArgumentsKw(); @Nullable Number getCaller(); @Override String toString(); }
InvocationMessage extends WampMessage { public static InvocationMessage deserialize(JsonParser jp) throws IOException { jp.nextToken(); long request = jp.getLongValue(); jp.nextToken(); long registration = jp.getLongValue(); jp.nextToken(); Number caller = null; Map<String, Object> details = ParserUtil.readObject(jp); if (details != null) { caller = (Number) details.get("caller"); } 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 InvocationMessage(request, registration, caller, arguments, argumentsKw); } InvocationMessage(long requestId, long registrationId, @Nullable Number caller,
			@Nullable List<Object> arguments, @Nullable Map<String, Object> argumentsKw);  InvocationMessage(Procedure procedure, CallMessage callMessage); static InvocationMessage deserialize(JsonParser jp); @Override void serialize(JsonGenerator generator); long getRequestId(); long getRegistrationId(); @Nullable List<Object> getArguments(); @Nullable Map<String, Object> getArgumentsKw(); @Nullable Number getCaller(); @Override String toString(); static final int CODE; }