MessageFromClient { static List<String> getArgumentsFromMessage(JsonArray argArray) { List<String> params = new ArrayList<>(); for (JsonValue arg : argArray) { if (logger.isDebugEnabled()) { logger.debug("Get argument Type : '{}'. Value : '{}'", arg.getValueType().name(), arg); } params.add(arg.toString()); } return params; }  String getId(); void setId(String messageId); String getDataService(); void setDataService(String dataService); String getOperation(); void setOperation(String operation); List<String> getParameters(); void setParameters(List<String> parameters); @Override int hashCode(); @Override boolean equals(Object obj); static MessageFromClient createFromJson(String json);  }
@Test public void getArgumentsFromMessageTest() { System.out.println("getArgumentsFromMessage"); try (JsonReader reader = Json.createReader(new StringReader("[]"))) { JsonArray array = reader.readArray(); List<String> result = MessageFromClient.getArgumentsFromMessage(array); assertThat(result).isEmpty(); } try (JsonReader reader = Json.createReader(new StringReader("[\"foo\"]"))) { JsonArray array = reader.readArray(); List<String> result = MessageFromClient.getArgumentsFromMessage(array); assertThat(result).hasSize(1); } try (JsonReader reader = Json.createReader(new StringReader("[\"foo\", 5]"))) { JsonArray array = reader.readArray(); List<String> result = MessageFromClient.getArgumentsFromMessage(array); assertThat(result).hasSize(2); assertThat(result.get(0)).isEqualTo("\"foo\""); assertThat(result.get(1)).isEqualTo("5"); } }
@Test public void getArgumentNamesFromMessageTest() { System.out.println("getArgumentNamesFromMessage"); try (JsonReader reader = Json.createReader(new StringReader("[]"))) { JsonArray array = reader.readArray(); List<String> result = MessageFromClientTest.getArgumentNamesFromMessage(array); assertThat(result).isEmpty(); } try (JsonReader reader = Json.createReader(new StringReader("[\"arg1\"]"))) { JsonArray array = reader.readArray(); List<String> result = MessageFromClient.getArgumentsFromMessage(array); assertThat(result).hasSize(1); } try (JsonReader reader = Json.createReader(new StringReader("[\"arg1\", \"arg2\"]"))) { JsonArray array = reader.readArray(); List<String> result = MessageFromClient.getArgumentsFromMessage(array); assertThat(result).hasSize(2); assertThat(result.get(0)).isEqualTo("\"arg1\""); assertThat(result.get(1)).isEqualTo("\"arg2\""); } }