### Question:
PathSerializer implements JsonSerializer<Path> { @Override public JsonElement serialize(Path src, Type typeOfSrc, JsonSerializationContext context) { return new JsonPrimitive(src.toString()); }  @Override JsonElement serialize(Path src, Type typeOfSrc, JsonSerializationContext context);  }### Answer:
@Test public void testSerialize() { Path file = Paths.get("/this/is/a/path/to/a/file.txt"); String jsonExpected = String.format("{\"path\":\"%s\"}", file.toString()); FileRecoveryMessage message = new FileRecoveryMessage(); message.setPath(file); Gson gson = createGsonInstance(); String jsonSerialized = gson.toJson(message); assertNotNull(jsonSerialized); assertEquals(jsonExpected, jsonSerialized); }