@Test void shouldSerializeLiteralMap() { Map<String, Literal> input = new HashMap<>(); Literal integer = Literal.of(Scalar.of(Primitive.ofInteger(1337L))); Literal map = Literal.of(singletonMap("b", integer)); Literal list = Literal.of(singletonList(integer)); input.put("string", Literal.of(Scalar.of(Primitive.ofString("string")))); input.put("integer", integer); input.put("float", Literal.of(Scalar.of(Primitive.ofFloat(2.0)))); input.put("boolean", Literal.of(Scalar.of(Primitive.ofBoolean(true)))); input.put("datetime", Literal.of(Scalar.of(Primitive.ofDatetime(Instant.ofEpochSecond(60L))))); input.put("duration", Literal.of(Scalar.of(Primitive.ofDuration(Duration.ofSeconds(61))))); input.put("list", list); input.put("map", map); input.put("listOfList", Literal.of(ImmutableList.of(list, integer))); input.put("mapOfMap", Literal.of(ImmutableMap.of("a", map, "c", integer))); Map<String, String> expected = new HashMap<>(); expected.put("string", "string"); expected.put("integer", "1337"); expected.put("float", "2.0"); expected.put("boolean", "true"); expected.put("datetime", "1970-01-01T00:01:00Z"); expected.put("duration", "PT1M1S"); expected.put("list", "[1337]"); expected.put("listOfList", "[[1337], 1337]"); expected.put("map", "{b=1337}"); expected.put("mapOfMap", "{a={b=1337}, c=1337}"); Map<String, String> output = StringUtil.serializeLiteralMap(input); Assert.assertEquals(expected, output); }
static Map<String, String> serializeLiteralMap(Map<String, Literal> outputs) { Map<String, String> map = new HashMap<>(); outputs.forEach((key, value) -> map.put(key, serialize(value))); return map; }
StringUtil { static Map<String, String> serializeLiteralMap(Map<String, Literal> outputs) { Map<String, String> map = new HashMap<>(); outputs.forEach((key, value) -> map.put(key, serialize(value))); return map; } }
StringUtil { static Map<String, String> serializeLiteralMap(Map<String, Literal> outputs) { Map<String, String> map = new HashMap<>(); outputs.forEach((key, value) -> map.put(key, serialize(value))); return map; } private  StringUtil(); }
StringUtil { static Map<String, String> serializeLiteralMap(Map<String, Literal> outputs) { Map<String, String> map = new HashMap<>(); outputs.forEach((key, value) -> map.put(key, serialize(value))); return map; } private  StringUtil();  }
StringUtil { static Map<String, String> serializeLiteralMap(Map<String, Literal> outputs) { Map<String, String> map = new HashMap<>(); outputs.forEach((key, value) -> map.put(key, serialize(value))); return map; } private  StringUtil();   }