/**
   * Test a feature collection where each feature will be in it's own bin.
   *
   * <p>Creates a feature collection with five features 1-5. Then uses the quantile function to put
   * these features in 5 bins. Each bin should have a single feature.
   *
   * @throws Exception
   */
  public void testSingleBin() throws Exception {

    // create a feature collection with five features values 1-5
    SimpleFeatureType dataType = DataUtilities.createType("classification.test1", "id:0,value:int");
    int iVal[] = new int[] {1, 2, 3, 4, 5};
    SimpleFeature[] myfeatures = new SimpleFeature[iVal.length];
    for (int i = 0; i < iVal.length; i++) {
      myfeatures[i] =
          SimpleFeatureBuilder.build(
              dataType,
              new Object[] {new Integer(i + 1), new Integer(iVal[i])},
              "classification.test1" + (i + 1));
    }
    MemoryDataStore store = new MemoryDataStore();
    store.createSchema(dataType);
    store.addFeatures(myfeatures);
    FeatureCollection<SimpleFeatureType, SimpleFeature> myFeatureCollection =
        store.getFeatureSource("test1").getFeatures();

    // run the quantile function
    org.opengis.filter.expression.Expression function =
        ff.function("Quantile", ff.property("value"), ff.literal(5));
    Classifier classifier = (Classifier) function.evaluate(myFeatureCollection);

    // verify the results
    assertNotNull(classifier);
    assertEquals(classifier.getClass(), RangedClassifier.class);
    RangedClassifier range = (RangedClassifier) classifier;
    assertEquals(5, range.getSize());

    for (int i = 0; i < 5; i++) {
      assertTrue(i + 1 == ((Number) range.getMin(i)).doubleValue());
      if (i != 4) {
        assertTrue(i + 2 == ((Number) range.getMax(i)).doubleValue());
        assertEquals((i + 1) + ".." + (i + 2), range.getTitle(i));
      } else {
        assertTrue(i + 1 == ((Number) range.getMax(i)).doubleValue());
        assertEquals((i + 1) + ".." + (i + 1), range.getTitle(i));
      }
    }
  }