private void assertFields(Map<String, Object> expected, Hit hit) {
        // field traverser
        Map<String, Object> traversed = new HashMap<>();
        hit.forEachField((name, value) -> {
            if (traversed.containsKey(name))
                fail("Multiple callbacks for " + name);
            traversed.put(name, value);
        });
        assertEqualMaps(expected, traversed);
        // raw utf8 field traverser
        Map<String, Object> traversedUtf8 = new HashMap<>();
        hit.forEachFieldAsRaw(new Utf8FieldTraverser(traversedUtf8));
        assertEquals(expected, traversedUtf8);
        // fieldKeys
        int fieldNameIteratorFieldCount = 0;
        for (Iterator<String> i = hit.fieldKeys().iterator(); i.hasNext(); ) {
            fieldNameIteratorFieldCount++;
            String name = i.next();
            assertTrue(expected.containsKey(name), "Expected field " + name);
        }
        assertEquals(expected.size(), fieldNameIteratorFieldCount);
        // fieldKeys
        assertEquals(expected.keySet(), hit.fieldKeys());
        // fields
        assertEqualMaps(expected, hit.fields());
        // fieldIterator
        int fieldIteratorFieldCount = 0;
        for (Iterator<Map.Entry<String, Object>> i = hit.fieldIterator(); i.hasNext(); ) {
            fieldIteratorFieldCount++;
            Map.Entry<String, Object> field = i.next();
            assertEquals(field.getValue(), expected.get(field.getKey()));
        }
        assertEquals(expected.size(), fieldIteratorFieldCount);
        // getField
        for (Map.Entry<String, Object> field : expected.entrySet())
            assertEquals(field.getValue(), hit.getField(field.getKey()));
    }
Asserts that the expected fields are what is returned from every access method of Hit
container-search/src/test/java/com/yahoo/prelude/fastsearch/SlimeSummaryTestCase.java