### Question:
JOOX { public static Match $() { return $(builder().newDocument()); } static  Match(); static  Match(Object object); static  Match(String name); static  Match(String name, String content); static  Match(String name, Element... content); static  Match(String name, Match... content); static  Match(Document document); static  Match(Element element); static  Match(Node node); static  Match(NodeList list); static  Match(Context context); static  Match(Match match); static  Match(URL url); static  Match(URI uri); static  Match(File file); static  Match(InputStream stream); static  Match(Reader reader); static  Match(InputSource source); static FastFilter none(); static FastFilter all(); static FastFilter even(); static FastFilter odd(); static FastFilter leaf(); static FastFilter at(final int... indexes); static Filter selector(final String selector); static FastFilter tag(final String tagName); static FastFilter tag(final String tagName, final boolean ignoreNamespace); static FastFilter namespacePrefix(final String namespacePrefix); static FastFilter namespaceURI(final String namespaceURI); static FastFilter matchText(final String regex); static FastFilter matchAttr(final String name, final String valueRegex); static FastFilter matchTag(final String regex); static FastFilter matchTag(final String regex, final boolean ignoreNamespace); static FastFilter attr(final String name); static FastFilter attr(final String name, final String... values); static Filter and(final Filter... filters); static Filter or(final Filter... filters); static Filter not(final Filter filter); static FastFilter ids(String... ids); static Content content(final String value); static Content content(final Object value); static Mapper<String> ids(); static Mapper<String> attrs(final String attributeName); static Mapper<String> paths(); static Each chain(final Each... each); static Each chain(final Iterable<? extends Each> each); static Iterable<Element> iterable(NodeList elements); static Iterator<Element> iterator(NodeList elements); static List<Element> list(NodeList elements); static DocumentBuilder builder(); @SuppressWarnings("unchecked") static T convert(String value, Class<T> type); static List<T> convert(List<String> values, Class<T> type);  }### Answer:
@Test public void testEachCallback() { final Queue<Integer> queue = new LinkedList<Integer>(); queue.addAll(Arrays.asList(0)); $.each(new Each() { @Override public void each(Context context) { assertEquals(context.element(), context.match()); assertEquals(context.elementIndex(), context.matchIndex()); assertEquals(context.elementSize(), context.matchSize()); assertEquals((int) queue.poll(), context.matchIndex()); assertEquals(1, context.matchSize()); assertEquals("document", context.element().getTagName()); } }); assertTrue(queue.isEmpty()); queue.addAll(Arrays.asList(0, 1, 2)); $.children().each(new Each() { @Override public void each(Context context) { assertEquals(context.element(), context.match()); assertEquals(context.elementIndex(), context.matchIndex()); assertEquals(context.elementSize(), context.matchSize()); assertEquals((int) queue.poll(), context.matchIndex()); assertEquals(3, context.matchSize()); assertEquals("library", context.element().getTagName()); } }); assertTrue(queue.isEmpty()); }