Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BT-4418] FaunaParser Set values #25

Merged
merged 3 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,12 @@ private void handleStartObject() throws IOException {
currentFaunaTokenType = FaunaTokenType.START_DOCUMENT;
tokenStack.push(FaunaTokenType.START_DOCUMENT);
break;
case REF_TAG:
case SET_TAG:
advanceTrue();
currentFaunaTokenType = FaunaTokenType.START_PAGE;
tokenStack.push(FaunaTokenType.START_PAGE);
break;
case REF_TAG:
throw new SerializationException(
"Token not implemented: " + jsonParser.getText());
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,30 @@ public void testReadDocumentTokens() throws IOException {
assertReader(reader, expectedTokens);
}

@Test
public void testReadSet() throws IOException {
String s = "{\n" +
" \"@set\": {\n" +
" \"data\": [{\"@int\": \"99\"}],\n" +
" \"after\": \"afterme\"\n" +
" }\n" +
"}";
FaunaParser reader = new FaunaParser(new ByteArrayInputStream(s.getBytes()));

List<Map.Entry<FaunaTokenType, Object>> expectedTokens = List.of(
new AbstractMap.SimpleEntry<>(FaunaTokenType.START_PAGE, null),
Map.entry(FaunaTokenType.FIELD_NAME, "data"),
new AbstractMap.SimpleEntry<>(FaunaTokenType.START_ARRAY, null),
Map.entry(FaunaTokenType.INT, 99),
new AbstractMap.SimpleEntry<>(FaunaTokenType.END_ARRAY, null),
Map.entry(FaunaTokenType.FIELD_NAME, "after"),
Map.entry(FaunaTokenType.STRING, "afterme"),
new AbstractMap.SimpleEntry<>(FaunaTokenType.END_PAGE, null)
);

assertReader(reader, expectedTokens);
}

private static void assertReader(FaunaParser reader,
List<Map.Entry<FaunaTokenType, Object>> tokens) throws IOException {
for (Map.Entry<FaunaTokenType, Object> entry : tokens) {
Expand Down
Loading