From: David ‘Bombe’ Roden Date: Tue, 24 Jun 2014 17:33:35 +0000 (+0200) Subject: Add test for restarting the wait period after changing the Sone. X-Git-Tag: 0.9-rc1^2~3^2~236 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=0ca31381ec49b83b8ef5b5cf4def21fecf0e95be;p=Sone.git Add test for restarting the wait period after changing the Sone. --- diff --git a/src/test/java/net/pterodactylus/sone/core/SoneModificationDetectorTest.java b/src/test/java/net/pterodactylus/sone/core/SoneModificationDetectorTest.java index fec97b1..388319b 100644 --- a/src/test/java/net/pterodactylus/sone/core/SoneModificationDetectorTest.java +++ b/src/test/java/net/pterodactylus/sone/core/SoneModificationDetectorTest.java @@ -32,7 +32,11 @@ public class SoneModificationDetectorTest { } private void modifySone() { - when(sone.getFingerprint()).thenReturn("modified"); + modifySone(""); + } + + private void modifySone(String uniqueValue) { + when(sone.getFingerprint()).thenReturn("modified" + uniqueValue); } private void passTime(int seconds) { @@ -60,8 +64,24 @@ public class SoneModificationDetectorTest { } @Test - public void modifiedSoneIsNotEligibleAfter30Seconds() { + public void modifiedAndRemodifiedSoneIsEligibleAfter90Seconds() { + modifySone(); + assertThat(soneModificationDetector.isModified(), is(true)); + assertThat(soneModificationDetector.isEligibleForInsert(), is(false)); + passTime(30); + modifySone("2"); + assertThat(soneModificationDetector.isModified(), is(true)); assertThat(soneModificationDetector.isEligibleForInsert(), is(false)); + passTime(61); + assertThat(soneModificationDetector.isModified(), is(true)); + assertThat(soneModificationDetector.isEligibleForInsert(), is(false)); + passTime(91); + assertThat(soneModificationDetector.isModified(), is(true)); + assertThat(soneModificationDetector.isEligibleForInsert(), is(true)); + } + + @Test + public void modifiedSoneIsNotEligibleAfter30Seconds() { modifySone(); passTime(30); assertThat(soneModificationDetector.isEligibleForInsert(), is(false));