@Test
    void testHitTrimming() {
        Result result = new Result(new Query("dummy"));

        //case 1: keep some hits in the middle
        resultInit(result);
        result.hits().trim(3, 3);
        assertEquals(3, result.getHitCount());
        Iterator<Hit> hits = result.hits().deepIterator();
        assertEquals(new Hit("test:hit3", 70), hits.next());
        assertEquals(new Hit("test:hit8", 55), hits.next());
        assertEquals(new Hit("test:hit5", 50), hits.next());
        assertEquals(false, hits.hasNext());

        //case 2: keep some hits at the end
        result = new Result(new Query("dummy"));
        resultInit(result);
        result.hits().trim(5, 4);
        hits = result.hits().deepIterator();
        assertEquals(new Hit("test:hit5", 50), hits.next());
        assertEquals(new Hit("test:hit4", 40), hits.next());
        assertEquals(new Hit("test:hit6", 20), hits.next());
        assertEquals(new Hit("test:hit7", 20), hits.next());
        assertEquals(false, hits.hasNext());


        //case 3: keep some hits at the beginning
        result = new Result(new Query("dummy"));
        resultInit(result);
        result.hits().trim(0, 4);
        hits = result.hits().deepIterator();
        assertEquals(new Hit("test:hit2", 90), hits.next());
        assertEquals(new Hit("test:hit1", 80), hits.next());
        assertEquals(new Hit("test:hit9", 75), hits.next());
        assertEquals(new Hit("test:hit3", 70), hits.next());
        assertEquals(false, hits.hasNext());

        //case 4: keep no hits
        result = new Result(new Query("dummy"));
        resultInit(result);
        result.hits().trim(10, 4);
        hits = result.hits().deepIterator();
        assertEquals(false, hits.hasNext());
    }
Tests the result class

@author bratseth
container-search/src/test/java/com/yahoo/prelude/test/ResultTestCase.java