@Test public void buildScanFromOffsetPredicateEq() {
    long constantOffset = 30;
    Map
        actual =
        KafkaScanTrimmer.buildScanFromOffsetPredicate(fullHouse,
            PredicateLeaf.Operator.EQUALS,
            constantOffset,
            false,
            false);
    Map
        expected =
        Maps.transformValues(fullHouse,
            entry -> new KafkaInputSplit(Objects.requireNonNull(entry).getTopic(),
                entry.getPartition(),
                constantOffset,
                constantOffset + 1,
                entry.getPath()));

    Assert.assertEquals(expected, actual);

    // seek to end if offset is out of reach
    actual =
        KafkaScanTrimmer.buildScanFromOffsetPredicate(fullHouse, PredicateLeaf.Operator.EQUALS, 3000000L, false, false);
    expected =
        Maps.transformValues(fullHouse,
            entry -> new KafkaInputSplit(Objects.requireNonNull(entry).getTopic(),
                entry.getPartition(),
                entry.getEndOffset(),
                entry.getEndOffset(),
                entry.getPath()));
    Assert.assertEquals(expected, actual);

    // seek to end if offset is out of reach
    actual = KafkaScanTrimmer.buildScanFromOffsetPredicate(fullHouse, PredicateLeaf.Operator.EQUALS, 0L, false, false);

    expected =
        Maps.transformValues(fullHouse,
            entry -> new KafkaInputSplit(Objects.requireNonNull(entry).getTopic(),
                entry.getPartition(),
                entry.getStartOffset() > 0 ? entry.getEndOffset() : 0,
                entry.getStartOffset() > 0 ? entry.getEndOffset() : 1,
                entry.getPath()));
    Assert.assertEquals(expected, actual);

  }
Test Class for Kafka Trimmer Class.
kafka-handler/src/test/org/apache/hadoop/hive/kafka/KafkaScanTrimmerTest.java