Search in sources :

Example 6 with EntitySchema

use of org.onebusaway.csv_entities.schema.EntitySchema in project onebusaway-gtfs-modules by OneBusAway.

the class EntitySchemaCacheTest method test.

@Test
public void test() {
    EntitySchemaCache cache = new EntitySchemaCache();
    EntitySchema schema = new EntitySchema(Route.class, "routes.txt", true);
    FieldMapping fieldMapping = new DefaultFieldMapping(Route.class, "route_short_name", "shortName", String.class, false);
    schema.addField(fieldMapping);
    cache.addEntitySchema(schema);
    assertSame(cache.getSchemaForFileName("routes.txt"), schema);
    assertSame(cache.getSchemaForEntityType(Route.class), schema);
    assertSame(cache.getFieldMappingForCsvFieldName(Route.class, "route_short_name"), fieldMapping);
    assertSame(cache.getFieldMappingForObjectFieldName(Route.class, "shortName"), fieldMapping);
}
Also used : DefaultFieldMapping(org.onebusaway.csv_entities.schema.DefaultFieldMapping) FieldMapping(org.onebusaway.csv_entities.schema.FieldMapping) EntitySchema(org.onebusaway.csv_entities.schema.EntitySchema) DefaultFieldMapping(org.onebusaway.csv_entities.schema.DefaultFieldMapping) Route(org.onebusaway.gtfs.model.Route) Test(org.junit.Test)

Aggregations

EntitySchema (org.onebusaway.csv_entities.schema.EntitySchema)6 Test (org.junit.Test)3 EntitySchemaFactory (org.onebusaway.csv_entities.schema.EntitySchemaFactory)2 FieldMapping (org.onebusaway.csv_entities.schema.FieldMapping)2 Route (org.onebusaway.gtfs.model.Route)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Converter (org.apache.commons.beanutils.Converter)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1 PropertyMethod (org.onebusaway.collections.beans.PropertyMethod)1 CsvEntityContext (org.onebusaway.csv_entities.CsvEntityContext)1 CsvEntityContextImpl (org.onebusaway.csv_entities.CsvEntityContextImpl)1 MissingRequiredFieldException (org.onebusaway.csv_entities.exceptions.MissingRequiredFieldException)1 BeanWrapper (org.onebusaway.csv_entities.schema.BeanWrapper)1 DefaultEntitySchemaFactory (org.onebusaway.csv_entities.schema.DefaultEntitySchemaFactory)1 DefaultFieldMapping (org.onebusaway.csv_entities.schema.DefaultFieldMapping)1 SingleFieldMapping (org.onebusaway.csv_entities.schema.SingleFieldMapping)1 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)1 TransformSpecificationException (org.onebusaway.gtfs_transformer.TransformSpecificationException)1