From 0ca31381ec49b83b8ef5b5cf4def21fecf0e95be 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:33:35 +0200 Subject: [PATCH] Add test for restarting the wait period after changing the Sone. --- .../sone/core/SoneModificationDetectorTest.java | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) 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)); -- 2.7.4