### Question:
AbstractPrefixMatchingExtractor implements ByteArrayExtractor { @Override public Collection<byte[]> extract(Result result) { List<byte[]> values = Lists.newArrayList(); NavigableMap<byte[], byte[]> qualifiersToValues = result.getFamilyMap(columnFamily); if (qualifiersToValues != null) { for (byte[] qualifier : qualifiersToValues.navigableKeySet().tailSet(prefix)) { if (Bytes.startsWith(qualifier, prefix)) { values.add(extractInternal(qualifier, qualifiersToValues.get(qualifier))); } else { break; } } } return values; } AbstractPrefixMatchingExtractor(byte[] columnFamily, byte[] prefix); @Override Collection<byte[]> extract(Result result); @Override boolean isApplicable(KeyValue keyValue); @Override byte[] getColumnFamily(); @Override byte[] getColumnQualifier(); @Override boolean containsTarget(Result result);  }### Answer:
@Test public void testExtract_NoKeyValues() { Result result = new Result(); Collection<byte[]> extracted = extractor.extract(result); assertTrue(extracted.isEmpty()); }
@Test public void testExtract_IncludeAll() { Result result = Result.create(new Cell[]{ new KeyValue(ROW, COLFAM, Bytes.toBytes("ABB"), Bytes.toBytes("value ABB")), new KeyValue(ROW, COLFAM, Bytes.toBytes("ABC"), Bytes.toBytes("value ABC")) }); assertExtractEquals(Lists.newArrayList("ABB:value ABB", "ABC:value ABC"), extractor.extract(result)); }
@Test public void testExtract_IncludeBottomHalf() { Result result = Result.create(new Cell[]{ new KeyValue(ROW, COLFAM, Bytes.toBytes("AB"), Bytes.toBytes("value AB")), new KeyValue(ROW, COLFAM, Bytes.toBytes("ABB"), Bytes.toBytes("value ABB")), new KeyValue(ROW, COLFAM, Bytes.toBytes("AC"), Bytes.toBytes("value AC")) }); assertExtractEquals(Lists.newArrayList("AB:value AB", "ABB:value ABB"), extractor.extract(result)); }
@Test public void testExtract_IncludeTopHalf() { Result result = Result.create(new KeyValue[]{ new KeyValue(ROW, COLFAM, Bytes.toBytes("A"), Bytes.toBytes("value A")), new KeyValue(ROW, COLFAM, Bytes.toBytes("AB"), Bytes.toBytes("value AB")), new KeyValue(ROW, COLFAM, Bytes.toBytes("ABB"), Bytes.toBytes("value ABB")) }); assertExtractEquals(Lists.newArrayList("AB:value AB", "ABB:value ABB"), extractor.extract(result)); }
@Test public void testExtract_IncludeMiddle() { Result result = Result.create(new KeyValue[]{ new KeyValue(ROW, COLFAM, Bytes.toBytes("AAC"), Bytes.toBytes("value AAC")), new KeyValue(ROW, COLFAM, Bytes.toBytes("ABC"), Bytes.toBytes("value ABC")), new KeyValue(ROW, COLFAM, Bytes.toBytes("ACC"), Bytes.toBytes("value ACC")) }); assertExtractEquals(Lists.newArrayList("ABC:value ABC"), extractor.extract(result)); }