package org.opentripplanner.analyst.batch;

import junit.framework.TestCase;
import org.opentripplanner.analyst.PointSet;

import java.io.IOException;

public class PointSetTest extends TestCase {

    public void testPointSets() throws IOException {
        PointSet schools = PointSet.fromCsv("src/test/resources/pointset/schools.csv");
        assertNotNull(schools);
        assertEquals(schools.capacity, 9);
    }

    /** Factory method should return null but not throw an exception on malformed CSV. */
    public void testBogusCSV() throws IOException {
        PointSet points = PointSet.fromCsv("src/test/resources/pointset/bogus.csv");
        assertNull(points);
    }

    public void testLoadGeoJson() {
        PointSet points = PointSet.fromGeoJson("src/test/resources/pointset/population.geo.json");
        assertNotNull(points);
        assertEquals(points.capacity, 2);
    }

    /* TODO Round trip serialization and deserialization to GeoJSON. */

}

@@ -74,51 +74,160 @@
 se;%0A
-import org.opentripplanner.analyst.PointSet
+%0Aimport org.opentripplanner.analyst.PointFeature;%0Aimport org.opentripplanner.analyst.PointSet;%0Aimport org.opentripplanner.analyst.PointSet.AttributeData
 ;%0A%0Ai
@@ -252,16 +252,39 @@
 ception;
+%0Aimport java.util.List;
 %0A%0Apublic
@@ -1013,32 +1013,1067 @@
 acity, 2);%0A    %7D
+%0A    %0A    public void testGetFeature() %7B%0A        PointSet points = PointSet.fromGeoJson(%22src/test/resources/pointset/population.geo.json%22);%0A        PointFeature pt = points.getFeature(0);%0A        %0A        assertNotNull(pt);%0A        assertEquals( pt.getId(), %22XYZ0001%22);%0A        List%3CAttributeData%3E attrs = pt.getAttributes();%0A        assertEquals( attrs.size(), 6 );%0A        assertEquals( attrs.get(0).toString(), %22age.senior:5%22 );%0A    %7D%0A    %0A    public void testSlice() %7B%0A    %09PointSet points = PointSet.fromGeoJson(%22src/test/resources/pointset/population.geo.json%22);%0A    %09%0A    %09PointSet all = points.slice(0, points.featureCount());%0A    %09assertEquals( all.featureCount(), points.featureCount() );%0A    %09%0A    %09PointSet firstHalf = points.slice(0, 1);%0A    %09assertEquals( firstHalf.featureCount(), 1 );%0A    %09assertEquals( firstHalf.getFeature(0).getId(), %22XYZ0001%22 );%0A    %09%0A    %09PointSet lastHalf = points.slice(1, 2);%0A    %09assertEquals( lastHalf.featureCount(), 1 );%0A    %09assertEquals( lastHalf.getFeature(0).getId(), %22XYZ0002%22 );%0A    %7D
 %0A%0A    /* TODO Ro

test coverage for new pointset features