### Question:
ByteArrayExtractors { public static ByteArrayExtractor getExtractor(String fieldValueExpression, ValueSource valueSource) { byte[] columnFamily = Bytes.toBytes(getFamily(fieldValueExpression)); String qualifierString = getQualifier(fieldValueExpression); boolean wildcard = isWildcard(qualifierString); if (wildcard) { qualifierString = qualifierString.substring(0, qualifierString.length() - 1); } byte[] qualifier = Bytes.toBytes(qualifierString); if (valueSource == ValueSource.VALUE) { if (wildcard) { return new PrefixMatchingCellExtractor(columnFamily, qualifier); } else { return new SingleCellExtractor(columnFamily, qualifier); } } else { if (wildcard) { return new PrefixMatchingQualifierExtractor(columnFamily, qualifier); } else { throw new IllegalArgumentException("Can't create a non-prefix-based qualifier extrator"); } } }  static ByteArrayExtractor getExtractor(String fieldValueExpression, ValueSource valueSource);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void testGetExtractor_QualifierBasedWithoutWildcard() { ByteArrayExtractors.getExtractor("colfam:qualifier", ValueSource.QUALIFIER); }
@Test public void testGetExtractor_Value_WithWildcard() { ByteArrayExtractor extractor = ByteArrayExtractors.getExtractor("colfam:quali*", ValueSource.VALUE); assertTrue(extractor instanceof PrefixMatchingCellExtractor); assertArrayEquals(Bytes.toBytes("quali"), ((PrefixMatchingCellExtractor)extractor).getPrefix()); }
@Test public void testGetExtractor_Qualifier_WithWildcard() { ByteArrayExtractor extractor = ByteArrayExtractors.getExtractor("colfam:quali*", ValueSource.QUALIFIER); assertTrue(extractor instanceof PrefixMatchingQualifierExtractor); assertArrayEquals(Bytes.toBytes("quali"), ((PrefixMatchingQualifierExtractor)extractor).getPrefix()); }
@Test public void testGetExtractor_CellValue_NoWildcard() { ByteArrayExtractor extractor = ByteArrayExtractors.getExtractor("colfam:qualifier", ValueSource.VALUE); assertTrue(extractor instanceof SingleCellExtractor); }