### Question:
IdParser { public static Node[] parse(String id) { if (id.length() == 0) { return EMPTY_NODES_ARRAY; } List<Node> result = Lists.newArrayList(); Iterable<String> split = SEPARATOR_CHAR_SPLITTER.split(id); for (String s : split) { if (s.charAt(0) == META_COMPONENT_SEPARATOR_CHAR) { int startImageIdx = s.indexOf(FUNCTION_IMAGE_START_TOKEN); if (startImageIdx < 0) { result.add(new Node(s)); } else { if (s.charAt(s.length() - 1) != FUNCTION_IMAGE_END_TOKEN) { throw new IllegalArgumentException(id); } if (startImageIdx + 1 > s.length() - 1) { throw new IllegalArgumentException(id); } String image = s.substring(startImageIdx + 1, s.length() - 1); String functionName = s.substring(1, startImageIdx); result.add(new Node(image, functionName)); } } else { result.add(new Node(s)); } } return result.toArray(new Node[result.size()]); } private  IdParser(); static Node[] parse(String id);  }### Answer:
@Test public void testSimpleId() throws Exception { assertArrayEquals(new Node[0], parse("")); assertArrayEquals(new Node[] { new Node("test") }, parse("test")); assertArrayEquals(new Node[] { new Node("form"), new Node("table") }, parse("form:table")); }
@Test public void testRowsFunction() throws Exception { try { parse("form:table:@rows("); fail(); } catch (IllegalArgumentException e) { } try { parse("form:table:@rows(12"); fail(); } catch (IllegalArgumentException e) { } assertArrayEquals(new Node[] { new Node("form"), new Node("table"), new Node("", "rows"), new Node("@row") }, parse("form:table:@rows():@row")); assertArrayEquals(new Node[] { new Node("form"), new Node("table"), new Node("12", "rows") }, parse("form:table:@rows(12)")); assertArrayEquals(new Node[] { new Node("form"), new Node("table"), new Node("", "rows"), new Node("subtable") }, parse("form:table:@rows():subtable")); assertArrayEquals(new Node[] { new Node("form"), new Node("table"), new Node("12", "rows"), new Node("subtable"), new Node("a", "rows"), new Node("cell") }, parse("form:table:@rows(12):subtable:@rows(a):cell")); }