@Test(expected = IllegalArgumentException.class) public void testAddBindingsNextBindingWithNullOrigin() { final String prefix = "1.1.1.1/32"; final int sgt = 20; final SxpBindingFields localBinding = getBinding(prefix, sgt); final SxpBindingFields bindingWithNullOrigin = getBinding(prefix, sgt, null, new String[0]); assertEquals(1, database.addBindings(Collections.singletonList(localBinding)).size()); database.addBindings(Collections.singletonList(bindingWithNullOrigin)); }
@Override public synchronized <T extends SxpBindingFields> List<MasterDatabaseBinding> addBindings(List<T> bindings) { List<MasterDatabaseBinding> added = new ArrayList<>(); if (bindings == null) { return added; } Map<IpPrefix, MasterDatabaseBinding> prefixMap = MasterDatabase .filterIncomingBindings(bindings, bindingMap::get, p -> bindingMap.remove(p) != null); if (!prefixMap.isEmpty()) { bindingMap.putAll(prefixMap); added.addAll(prefixMap.values()); } dbListener.onBindingsAdded(added); return added; }
MasterDatabaseImpl extends MasterDatabase { @Override public synchronized <T extends SxpBindingFields> List<MasterDatabaseBinding> addBindings(List<T> bindings) { List<MasterDatabaseBinding> added = new ArrayList<>(); if (bindings == null) { return added; } Map<IpPrefix, MasterDatabaseBinding> prefixMap = MasterDatabase .filterIncomingBindings(bindings, bindingMap::get, p -> bindingMap.remove(p) != null); if (!prefixMap.isEmpty()) { bindingMap.putAll(prefixMap); added.addAll(prefixMap.values()); } dbListener.onBindingsAdded(added); return added; } }
MasterDatabaseImpl extends MasterDatabase { @Override public synchronized <T extends SxpBindingFields> List<MasterDatabaseBinding> addBindings(List<T> bindings) { List<MasterDatabaseBinding> added = new ArrayList<>(); if (bindings == null) { return added; } Map<IpPrefix, MasterDatabaseBinding> prefixMap = MasterDatabase .filterIncomingBindings(bindings, bindingMap::get, p -> bindingMap.remove(p) != null); if (!prefixMap.isEmpty()) { bindingMap.putAll(prefixMap); added.addAll(prefixMap.values()); } dbListener.onBindingsAdded(added); return added; }  }
MasterDatabaseImpl extends MasterDatabase { @Override public synchronized <T extends SxpBindingFields> List<MasterDatabaseBinding> addBindings(List<T> bindings) { List<MasterDatabaseBinding> added = new ArrayList<>(); if (bindings == null) { return added; } Map<IpPrefix, MasterDatabaseBinding> prefixMap = MasterDatabase .filterIncomingBindings(bindings, bindingMap::get, p -> bindingMap.remove(p) != null); if (!prefixMap.isEmpty()) { bindingMap.putAll(prefixMap); added.addAll(prefixMap.values()); } dbListener.onBindingsAdded(added); return added; }  @Override void initDBPropagatingListener(BindingDispatcher dispatcher, SxpDomain domain); @Override synchronized List<MasterDatabaseBinding> addBindings(List<T> bindings); @Override synchronized List<MasterDatabaseBinding> getBindings(); @Override synchronized List<MasterDatabaseBinding> getBindings(OriginType origin); @Override synchronized List<MasterDatabaseBinding> deleteBindings(List<T> bindings); @Override void close(); }
MasterDatabaseImpl extends MasterDatabase { @Override public synchronized <T extends SxpBindingFields> List<MasterDatabaseBinding> addBindings(List<T> bindings) { List<MasterDatabaseBinding> added = new ArrayList<>(); if (bindings == null) { return added; } Map<IpPrefix, MasterDatabaseBinding> prefixMap = MasterDatabase .filterIncomingBindings(bindings, bindingMap::get, p -> bindingMap.remove(p) != null); if (!prefixMap.isEmpty()) { bindingMap.putAll(prefixMap); added.addAll(prefixMap.values()); } dbListener.onBindingsAdded(added); return added; }  @Override void initDBPropagatingListener(BindingDispatcher dispatcher, SxpDomain domain); @Override synchronized List<MasterDatabaseBinding> addBindings(List<T> bindings); @Override synchronized List<MasterDatabaseBinding> getBindings(); @Override synchronized List<MasterDatabaseBinding> getBindings(OriginType origin); @Override synchronized List<MasterDatabaseBinding> deleteBindings(List<T> bindings); @Override void close();  }