DefaultPathAttributesInjector { public Route injectMissingPathAttribute(Route route) { Set<PathAttribute> result = new TreeSet<PathAttribute>(route.getPathAttributes()); Map<Class<? extends PathAttribute>, PathAttribute> pathClazz = new HashMap<Class<? extends PathAttribute>, PathAttribute>(); for(PathAttribute pa : result) { pathClazz.put(pa.getClass(), pa); } for(Class<? extends PathAttribute> clazz : attrs.keySet()) { if(!pathClazz.containsKey(clazz)) result.add(attrs.get(clazz)); } return new Route(route, null, result, null); }  void configure(PathAttributeConfiguration configuration); Route injectMissingPathAttribute(Route route);  }
@Test public void testEmptyInjector() { TreeSet<PathAttribute> attrs = new TreeSet<PathAttribute>(); attrs.add(localPref); attrs.add(multiExit); attrs.add(origin); Iterator<PathAttribute> it = injector.injectMissingPathAttribute(new Route(AddressFamilyKey.IPV4_UNICAST_FORWARDING, null, attrs, null)).getPathAttributes().iterator(); Assert.assertTrue(it.hasNext()); Assert.assertEquals(localPref, it.next()); Assert.assertTrue(it.hasNext()); Assert.assertEquals(multiExit, it.next()); Assert.assertTrue(it.hasNext()); Assert.assertEquals(origin, it.next()); Assert.assertFalse(it.hasNext()); }