@Test public void should_throw_error_when_mongo_exception() throws Exception { MongoCollection<Document> collection = mock(MongoCollection.class); when(collection.findOneAndUpdate(any(Bson.class), any(Bson.class), any(FindOneAndUpdateOptions.class))).thenThrow(MongoWriteException.class); OfferSequenceDatabaseService service = new OfferSequenceDatabaseService(collection); ThrowingCallable getSequence = () -> service.getNextSequence(BACKUP_LOG_SEQUENCE_ID); assertThatThrownBy(getSequence).isInstanceOf(ContentAddressableStorageDatabaseException.class); }
public long getNextSequence(String sequenceId) throws ContentAddressableStorageDatabaseException { return getNextSequence(sequenceId, 1L); }
OfferSequenceDatabaseService { public long getNextSequence(String sequenceId) throws ContentAddressableStorageDatabaseException { return getNextSequence(sequenceId, 1L); } }
OfferSequenceDatabaseService { public long getNextSequence(String sequenceId) throws ContentAddressableStorageDatabaseException { return getNextSequence(sequenceId, 1L); } OfferSequenceDatabaseService(MongoCollection<Document> mongoCollection); }
OfferSequenceDatabaseService { public long getNextSequence(String sequenceId) throws ContentAddressableStorageDatabaseException { return getNextSequence(sequenceId, 1L); } OfferSequenceDatabaseService(MongoCollection<Document> mongoCollection); long getNextSequence(String sequenceId); long getNextSequence(String sequenceId, long inc); }
OfferSequenceDatabaseService { public long getNextSequence(String sequenceId) throws ContentAddressableStorageDatabaseException { return getNextSequence(sequenceId, 1L); } OfferSequenceDatabaseService(MongoCollection<Document> mongoCollection); long getNextSequence(String sequenceId); long getNextSequence(String sequenceId, long inc); static final String BACKUP_LOG_SEQUENCE_ID; }