JdbcInventory extends JdbcHelper implements Inventory { @Override public void storeObject(ObjectMessage object) { if (getCache(object.getStream()).containsKey(object.getInventoryVector())) return; try ( Connection connection = config.getConnection(); PreparedStatement ps = connection.prepareStatement("INSERT INTO Inventory " + "(hash, stream, expires, data, type, version) VALUES (?, ?, ?, ?, ?, ?)") ) { InventoryVector iv = object.getInventoryVector(); LOG.trace("Storing object " + iv); ps.setBytes(1, iv.getHash()); ps.setLong(2, object.getStream()); ps.setLong(3, object.getExpiresTime()); writeBlob(ps, 4, object); ps.setLong(5, object.getType()); ps.setLong(6, object.getVersion()); ps.executeUpdate(); getCache(object.getStream()).put(iv, object.getExpiresTime()); } catch (SQLException e) { LOG.debug("Error storing object of type " + object.getPayload().getClass().getSimpleName(), e); } catch (Exception e) { LOG.error(e.getMessage(), e); } } JdbcInventory(JdbcConfig config); @Override List<InventoryVector> getInventory(long... streams); @Override List<InventoryVector> getMissing(List<InventoryVector> offer, long... streams); @Override ObjectMessage getObject(InventoryVector vector); @Override List<ObjectMessage> getObjects(long stream, long version, ObjectType... types); @Override void storeObject(ObjectMessage object); @Override boolean contains(ObjectMessage object); @Override void cleanup();  }
@Test public void testStoreObject() throws Exception { ObjectMessage object = getObjectMessage(5, 0, getGetPubkey()); inventory.storeObject(object); assertNotNull(inventory.getObject(object.getInventoryVector())); }