use of org.onebusaway.gtfs_merge.GtfsMergeContext in project onebusaway-gtfs-modules by OneBusAway.
the class AgencyMergeStrategyTest method testIdentityMatch.
@Test
public void testIdentityMatch() {
GtfsRelationalDaoImpl sourceA = new GtfsRelationalDaoImpl();
Agency agencyA = new Agency();
agencyA.setId("1");
agencyA.setName("Metro");
agencyA.setUrl("http://metro.gov/");
sourceA.saveEntity(agencyA);
GtfsRelationalDaoImpl sourceB = new GtfsRelationalDaoImpl();
Agency agencyB = new Agency();
agencyB.setId("1");
agencyB.setName("Metro");
agencyB.setUrl("http://metro.gov/");
sourceB.saveEntity(agencyB);
Agency agencyC = new Agency();
agencyC.setId("2");
agencyC.setName("Metra");
agencyC.setUrl("http://metra.gov/");
sourceB.saveEntity(agencyC);
GtfsMergeContext contextA = context(sourceA, _target, "a-");
_strategy.merge(contextA);
GtfsMergeContext contextB = context(sourceB, _target, "b-");
_strategy.merge(contextB);
assertEquals(EDuplicateDetectionStrategy.IDENTITY, contextB.getResolvedDuplicateDetectionStrategy());
Collection<Agency> agencies = _target.getAllAgencies();
assertEquals(2, agencies.size());
assertSame(agencyA, _target.getAgencyForId("1"));
assertSame(agencyC, _target.getAgencyForId("2"));
}
use of org.onebusaway.gtfs_merge.GtfsMergeContext in project onebusaway-gtfs-modules by OneBusAway.
the class AgencyMergeStrategyTest method testFuzzyMatchAgencyName.
@Test
public void testFuzzyMatchAgencyName() {
GtfsRelationalDaoImpl sourceA = new GtfsRelationalDaoImpl();
Agency agencyA = new Agency();
agencyA.setId("1");
agencyA.setName("Metro");
agencyA.setUrl("http://metro.gov/");
sourceA.saveEntity(agencyA);
GtfsRelationalDaoImpl sourceB = new GtfsRelationalDaoImpl();
Agency agencyB = new Agency();
agencyB.setId("1");
agencyB.setName("Metra");
agencyB.setUrl("http://metra.gov/");
sourceB.saveEntity(agencyB);
Agency agencyC = new Agency();
agencyC.setId("2");
agencyC.setName("Metro");
agencyC.setUrl("http://metro.gov/");
sourceB.saveEntity(agencyC);
GtfsMergeContext contextA = context(sourceA, _target, "a-");
_strategy.merge(contextA);
GtfsMergeContext contextB = context(sourceB, _target, "b-");
_strategy.merge(contextB);
assertEquals(EDuplicateDetectionStrategy.FUZZY, contextB.getResolvedDuplicateDetectionStrategy());
Collection<Agency> agencies = _target.getAllAgencies();
assertEquals(2, agencies.size());
assertSame(agencyA, _target.getAgencyForId("1"));
assertSame(agencyB, _target.getAgencyForId("b-1"));
}
Aggregations