diff --git a/faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java b/faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java index dba0cbf3..73fb2a96 100644 --- a/faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java +++ b/faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java @@ -170,8 +170,10 @@ private void handleStartObject() throws IOException { tokenStack.push(FaunaTokenType.START_PAGE); break; case REF_TAG: - throw new SerializationException( - "Token not implemented: " + jsonParser.getText()); + advanceTrue(); + currentFaunaTokenType = FaunaTokenType.START_REF; + tokenStack.push(FaunaTokenType.START_REF); + break; default: bufferedFaunaTokenType = FaunaTokenType.FIELD_NAME; tokenStack.push(FaunaTokenType.START_OBJECT); diff --git a/faunaJava/src/test/java/com/fauna/serialization/FaunaParserTest.java b/faunaJava/src/test/java/com/fauna/serialization/FaunaParserTest.java index 7d5d9cb5..e5e4d818 100644 --- a/faunaJava/src/test/java/com/fauna/serialization/FaunaParserTest.java +++ b/faunaJava/src/test/java/com/fauna/serialization/FaunaParserTest.java @@ -349,6 +349,24 @@ public void testReadSet() throws IOException { assertReader(reader, expectedTokens); } + @Test + public void testReadRef() throws IOException { + String s = "{\"@ref\": {\"id\": \"123\", \"coll\": {\"@mod\": \"Col\"}}}"; + + FaunaParser reader = new FaunaParser(new ByteArrayInputStream(s.getBytes())); + + List> expectedTokens = List.of( + new AbstractMap.SimpleEntry<>(FaunaTokenType.START_REF, null), + Map.entry(FaunaTokenType.FIELD_NAME, "id"), + Map.entry(FaunaTokenType.STRING, "123"), + Map.entry(FaunaTokenType.FIELD_NAME, "coll"), + Map.entry(FaunaTokenType.MODULE, new Module("Col")), + new AbstractMap.SimpleEntry<>(FaunaTokenType.END_REF, null) + ); + + assertReader(reader, expectedTokens); + } + private static void assertReader(FaunaParser reader, List> tokens) throws IOException { for (Map.Entry entry : tokens) {