### Question:
RangeFieldPartitioner extends FieldPartitioner<String, String> { @Override public String apply(String value) { for (String upper : upperBounds) { if (value.compareTo(upper) <= 0) { return upper; } } throw new IllegalArgumentException(value + " is outside bounds"); } RangeFieldPartitioner(String sourceName, String... upperBounds);  RangeFieldPartitioner(String sourceName, @Nullable String name,
                               String... upperBounds); @Override String apply(String value); @Override Predicate<String> project(Predicate<String> predicate); @Override Predicate<String> projectStrict(Predicate<String> predicate); List<String> getUpperBounds(); @Override @edu.umd.cs.findbugs.annotations.SuppressWarnings( value="NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION", justification="Default annotation is not correct for equals") boolean equals(@Nullable Object o); @Override int compare(String o1, String o2); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void test() { RangeFieldPartitioner partitioner = new RangeFieldPartitioner("username", new String[] { "barry", "susan", "zippy" }); Assert.assertEquals(3, partitioner.getCardinality()); Assert.assertEquals("barry", partitioner.apply("adam")); Assert.assertEquals("barry", partitioner.apply("barry")); Assert.assertEquals("susan", partitioner.apply("charlie")); Assert.assertEquals("zippy", partitioner.apply("yvette")); Exception ex = null; try { partitioner.apply("zzzzz out of range"); } catch (Exception e) { ex = e; } Assert.assertNotNull(ex); Assert.assertTrue(ex instanceof IllegalArgumentException); }