MongoLockService implements LockService { @Override public LockEntry getLockInformation() { final Document lockDocument = getLockCollection() .find(new Document(LockEntryDocBuilder.LOCK_ENTRY, true)) .first(); return new LockEntry( lockDocument.getBoolean(LockEntryDocBuilder.LOCKED), lockDocument.getDate(LockEntryDocBuilder.LAST_LOCK_DATE), lockDocument.getDate(LockEntryDocBuilder.LAST_RELEASE_DATE)); } MongoLockService(MongoDatabase database); @Override boolean acquireLock(); @Override boolean releaseLock(); @Override LockEntry getLockInformation(); @Override void destroyLock(); static final String MIGRAMONGO_LOCK_COLLECTION; }
@Test public void shouldGetLockInfoWhenUnlocked() throws Exception { assertThat(lockService.getLockInformation().isLocked(), is(false)); assertThat(lockService.getLockInformation().getLastLockDate(), nullValue()); assertThat(lockService.getLockInformation().getLastReleaseDate(), nullValue()); }