SiriModuleDeliveryFilterFactoryImpl { public SiriModuleDeliveryFilter create(Map<String, String> filterArgs) { String filterType = filterArgs.remove(ARG_FILTER_TYPE); if (filterType != null) { if (filterType.equals(ARG_FILTER_TYPE_ELEMENTS)) { return createPropertyFilter(filterArgs); } throw new SiriException("uknown filter type: " + filterType); } String filterClassName = filterArgs.remove(ARG_FILTER_CLASS); if (filterClassName != null) { Class<? extends SiriModuleDeliveryFilter> filterClass = resolveFilterClass(filterClassName); SiriModuleDeliveryFilter filter = (SiriModuleDeliveryFilter) createObjectForClass(filterClass); setFilterArguments(filter, filterArgs); return filter; } throw new SiriException("expected argument \"" + ARG_FILTER_TYPE + "\" or \"" + ARG_FILTER_CLASS + "\""); }  SiriModuleDeliveryFilter create(Map<String, String> filterArgs);  }
@Test public void testFullClassName() { Map<String, String> filterArgs = new HashMap<String, String>(); filterArgs.put("Filter.Class", "org.onebusaway.siri.core.filters.ModuleDeliveryFilterCollection"); SiriModuleDeliveryFilter filter = _factory.create(filterArgs); assertTrue(filter instanceof ModuleDeliveryFilterCollection); }
@Test public void testPartialClassName() { Map<String, String> filterArgs = new HashMap<String, String>(); filterArgs.put("Filter.Class", "ModuleDeliveryFilterCollection"); SiriModuleDeliveryFilter filter = _factory.create(filterArgs); assertTrue(filter instanceof ModuleDeliveryFilterCollection); }
@Test(expected = SiriException.class) public void testClassDoesNotExist() { Map<String, String> filterArgs = new HashMap<String, String>(); filterArgs.put("Filter.Class", "DoesNotExist"); _factory.create(filterArgs); }
@Test public void testSetFilterArgs() { Map<String, String> filterArgs = new HashMap<String, String>(); filterArgs.put("Filter.Class", DummyFilter.class.getName()); filterArgs.put("value", "tacos"); DummyFilter filter = (DummyFilter) _factory.create(filterArgs); assertEquals("tacos", filter.getValue()); }