@Test public void getSequence_shouldFindSequenceWithOneInNextIdForNonExistingSequence() { DBCursor cursor = collection.find(new BasicDBObject("name", "order")); assertThat(cursor.size(), is(0)); Sequence sequence = sequenceDao.getSequence(new Sequence("order", -1)); assertThat(sequence.getNextId(), is(1)); }
public Sequence getSequence(final Sequence seq) { checkNotNull(seq, "Argument[seq] must not be null"); DBObject sequenceObj = collection.findOne(new BasicDBObject("_id", seq.getName())); Sequence sequence = Sequence.fromDBObject((BasicDBObject) sequenceObj); if (sequence == null) { sequence = new Sequence(seq.getName(), 1); } logger.info("Found sequence: {}", sequence); return sequence; }
SequenceDao extends AbstractBaseDao<Sequence, String> implements SequenceMapper { public Sequence getSequence(final Sequence seq) { checkNotNull(seq, "Argument[seq] must not be null"); DBObject sequenceObj = collection.findOne(new BasicDBObject("_id", seq.getName())); Sequence sequence = Sequence.fromDBObject((BasicDBObject) sequenceObj); if (sequence == null) { sequence = new Sequence(seq.getName(), 1); } logger.info("Found sequence: {}", sequence); return sequence; } }
SequenceDao extends AbstractBaseDao<Sequence, String> implements SequenceMapper { public Sequence getSequence(final Sequence seq) { checkNotNull(seq, "Argument[seq] must not be null"); DBObject sequenceObj = collection.findOne(new BasicDBObject("_id", seq.getName())); Sequence sequence = Sequence.fromDBObject((BasicDBObject) sequenceObj); if (sequence == null) { sequence = new Sequence(seq.getName(), 1); } logger.info("Found sequence: {}", sequence); return sequence; } SequenceDao(final String collectionName); }
SequenceDao extends AbstractBaseDao<Sequence, String> implements SequenceMapper { public Sequence getSequence(final Sequence seq) { checkNotNull(seq, "Argument[seq] must not be null"); DBObject sequenceObj = collection.findOne(new BasicDBObject("_id", seq.getName())); Sequence sequence = Sequence.fromDBObject((BasicDBObject) sequenceObj); if (sequence == null) { sequence = new Sequence(seq.getName(), 1); } logger.info("Found sequence: {}", sequence); return sequence; } SequenceDao(final String collectionName); Sequence getSequence(final Sequence seq); void updateSequence(final Sequence seq); }
SequenceDao extends AbstractBaseDao<Sequence, String> implements SequenceMapper { public Sequence getSequence(final Sequence seq) { checkNotNull(seq, "Argument[seq] must not be null"); DBObject sequenceObj = collection.findOne(new BasicDBObject("_id", seq.getName())); Sequence sequence = Sequence.fromDBObject((BasicDBObject) sequenceObj); if (sequence == null) { sequence = new Sequence(seq.getName(), 1); } logger.info("Found sequence: {}", sequence); return sequence; } SequenceDao(final String collectionName); Sequence getSequence(final Sequence seq); void updateSequence(final Sequence seq);  }