Add test case for locking and unlocking a Sone.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 24 Jun 2014 17:57:05 +0000 (19:57 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 24 Jun 2014 17:57:05 +0000 (19:57 +0200)
src/test/java/net/pterodactylus/sone/core/SoneModificationDetectorTest.java

index 388319b..9d1cc59 100644 (file)
@@ -47,6 +47,10 @@ public class SoneModificationDetectorTest {
                when(core.isLocked(sone)).thenReturn(true);
        }
 
+       private void unlockSone() {
+               when(core.isLocked(sone)).thenReturn(false);
+       }
+
        @Test
        public void sonesStartOutAsNotEligible() {
                assertThat(soneModificationDetector.isModified(), is(false));
@@ -98,6 +102,20 @@ public class SoneModificationDetectorTest {
        }
 
        @Test
+       public void lockingAndUnlockingASoneRestartsTheWaitPeriod() {
+               modifySone();
+               lockSone();
+               passTime(30);
+               assertThat(soneModificationDetector.isEligibleForInsert(), is(false));
+               unlockSone();
+               assertThat(soneModificationDetector.isEligibleForInsert(), is(false));
+               passTime(60);
+               assertThat(soneModificationDetector.isEligibleForInsert(), is(false));
+               passTime(90);
+               assertThat(soneModificationDetector.isEligibleForInsert(), is(true));
+       }
+
+       @Test
        public void settingFingerprintWillResetTheEligibility() {
                modifySone();
                assertThat(soneModificationDetector.isEligibleForInsert(), is(false));