### Question:
UastNode { public static UastNode from(Reader reader) throws IOException { return Unmarshaller.unmarshal(reader); } UastNode(Set<Kind> kinds, String nativeNode, @Nullable Token token, List<UastNode> children); static UastNode from(Reader reader); Optional<UastNode> getChild(Kind kind); Optional<UastNode> getAncestor(Kind ancestorKind); List<UastNode> getChildren(Kind... kinds); void getDescendants(Kind kind, Consumer<UastNode> consumer, Kind... stopKinds); void getDescendants(Kind kind, Consumer<UastNode> consumer); boolean hasDescendant(Kind... kinds); Token firstToken(); Token lastToken(); String joinTokens(); boolean is(Kind... kinds); boolean isNot(Kind... kinds); @Override String toString(); final Set<Kind> kinds; final String nativeNode; @Nullable
  final Token token; final List<UastNode> children; }### Answer:
@Test void parse_kind() throws Exception { UastNode node = UastNode.from(new StringReader("{ kinds: [ 'IDENTIFIER', 'UNKNOWN1', 'IDENTIFIER', 'UNKNOWN2' ] }")); assertEquals(EnumSet.of(UastNode.Kind.IDENTIFIER), node.kinds); }
@Test void parse_native_node() throws Exception { UastNode node = UastNode.from(new StringReader("{ nativeNode: 'foo' }")); assertEquals("foo", node.nativeNode); }
@Test void parse_token() throws Exception { UastNode node = UastNode.from(new StringReader("{ token: { line: 1, column: 1, value: null } }")); assertEquals(Collections.emptyList(), node.children); assertNotNull(node.token); assertEquals(1, node.token.line); assertEquals(1, node.token.column); assertEquals("", node.token.value); node = UastNode.from(new StringReader("{ token: { line: 12, column: 34, value: 'foo' } }")); assertNotNull(node.token); assertEquals(12, node.token.line); assertEquals(34, node.token.column); assertEquals("foo", node.token.value); node = UastNode.from(new StringReader("{ kinds: [ 'EOF' ], token: { line: 345, column: 1 } }")); assertEquals(EnumSet.of(UastNode.Kind.EOF), node.kinds); assertNotNull(node.token); assertEquals(345, node.token.line); assertEquals(1, node.token.column); assertEquals("", node.token.value); }
@Test void parse_invalid_token() { assertEquals("Attributes 'line' and 'column' are mandatory on 'token' object.", assertThrows(JsonParseException.class, () -> UastNode.from(new StringReader("{ token: { } }"))) .getMessage()); }
@Test void parse_children() throws Exception { UastNode node = UastNode.from(new StringReader("{ children: [ { kinds: [ 'EOF' ] } ] }")); assertEquals(1, node.children.size()); assertEquals(EnumSet.of(UastNode.Kind.EOF), node.children.get(0).kinds); }