JdbcMessageRepository extends AbstractMessageRepository implements MessageRepository { private void update(Connection connection, Plaintext message) throws SQLException, IOException { try (PreparedStatement ps = connection.prepareStatement( "UPDATE Message SET iv=?, type=?, sender=?, recipient=?, data=?, ack_data=?, sent=?, received=?, " + "status=?, initial_hash=?, ttl=?, retries=?, next_try=? " + "WHERE id=?")) { ps.setBytes(1, message.getInventoryVector() == null ? null : message.getInventoryVector().getHash()); ps.setString(2, message.getType().name()); ps.setString(3, message.getFrom().getAddress()); ps.setString(4, message.getTo() == null ? null : message.getTo().getAddress()); writeBlob(ps, 5, message); ps.setBytes(6, message.getAckData()); ps.setLong(7, message.getSent()); ps.setLong(8, message.getReceived()); ps.setString(9, message.getStatus() == null ? null : message.getStatus().name()); ps.setBytes(10, message.getInitialHash()); ps.setLong(11, message.getTTL()); ps.setInt(12, message.getRetries()); ps.setObject(13, message.getNextTry()); ps.setLong(14, (Long) message.getId()); ps.executeUpdate(); } } JdbcMessageRepository(JdbcConfig config); @Override int countUnread(Label label); @Override void save(Plaintext message); @Override void remove(Plaintext message);  }
@Test public void testUpdate() throws Exception { List<Plaintext> messages = repo.findMessages(Plaintext.Status.DRAFT, contactA); Plaintext message = messages.get(0); message.setInventoryVector(new InventoryVector(cryptography().randomBytes(32))); repo.save(message); messages = repo.findMessages(Plaintext.Status.DRAFT, contactA); assertEquals(1, messages.size()); assertNotNull(messages.get(0).getInventoryVector()); }