From e46a5f6ff2861bd37d515bfb1f8e7241c6ae8618 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 24 Jun 2014 19:57:05 +0200 Subject: [PATCH] Add test case for locking and unlocking a Sone. --- .../sone/core/SoneModificationDetectorTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/test/java/net/pterodactylus/sone/core/SoneModificationDetectorTest.java b/src/test/java/net/pterodactylus/sone/core/SoneModificationDetectorTest.java index 388319b..9d1cc59 100644 --- a/src/test/java/net/pterodactylus/sone/core/SoneModificationDetectorTest.java +++ b/src/test/java/net/pterodactylus/sone/core/SoneModificationDetectorTest.java @@ -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)); -- 2.7.4