### Question:
HibernateSequenceDAO extends HibernatePersistentObjectDAO<Sequence> implements SequenceDAO { @Override public synchronized long next(String sequence, long objectId, long tenantId, long increment) { synchronized (SequenceDAO.class) { Sequence seq = findByAlternateKey(sequence, objectId, tenantId); if (seq == null) { seq = new Sequence(); } seq.setName(sequence); seq.setObjectId(objectId); seq.setTenantId(tenantId); seq.setValue(seq.getValue() + increment); try { store(seq); flush(); } catch (PersistenceException e) { log.error(e.getMessage(), e); } return seq.getValue(); } } private  HibernateSequenceDAO(); @Override synchronized void reset(String sequence, long objectId, long tenantId, long value); @Override synchronized long next(String sequence, long objectId, long tenantId, long increment); @Override synchronized long next(String sequence, long objectId, long tenantId); @Override long getCurrentValue(String sequence, long objectId, long tenantId); @Override List<Sequence> findByName(String name, long tenantId); @Override Sequence findByAlternateKey(String name, long objectId, long tenantId); @Override void delete(String name, long objectId, long tenantId); @Override boolean delete(long id, int code);  }### Answer:
@Test public void testNext() { for (int i = 1; i <= 20; i++) { Assert.assertEquals(i, dao.next("test", 0L, Tenant.DEFAULT_ID)); } for (int i = 1; i <= 20; i++) { Assert.assertEquals(i, dao.next("test2", 0L, Tenant.DEFAULT_ID)); } Assert.assertEquals(25L, dao.next("test2", 0L, Tenant.DEFAULT_ID, 5L)); Assert.assertEquals(23L, dao.next("test2", 0L, Tenant.DEFAULT_ID, -2L)); }