From: David ‘Bombe’ Roden Date: Wed, 22 Jul 2015 04:40:42 +0000 (+0200) Subject: Add tests for fixed Sone modification detector X-Git-Tag: 0.9.3^2~6 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=8bae6b092c9bd34f93de40b71777792da47fc638;p=Sone.git Add tests for fixed Sone modification detector --- diff --git a/src/test/java/net/pterodactylus/sone/core/SoneModificationDetectorTest.java b/src/test/java/net/pterodactylus/sone/core/SoneModificationDetectorTest.java index d70cc5c..8153e3b 100644 --- a/src/test/java/net/pterodactylus/sone/core/SoneModificationDetectorTest.java +++ b/src/test/java/net/pterodactylus/sone/core/SoneModificationDetectorTest.java @@ -152,4 +152,34 @@ public class SoneModificationDetectorTest { assertThat(soneModificationDetector.isEligibleForInsert(), is(false)); } + @Test + public void soneWithoutOriginalFingerprintIsNotEligibleAfter59Seconds() { + SoneModificationDetector soneModificationDetector = createDetectorWithoutOriginalFingerprint(); + assertThat(soneModificationDetector.isEligibleForInsert(), is(false)); + passTime(59); + assertThat(soneModificationDetector.isEligibleForInsert(), is(false)); + } + + private SoneModificationDetector createDetectorWithoutOriginalFingerprint() { + return new SoneModificationDetector(ticker, new LockableFingerprintProvider() { + @Override + public boolean isLocked() { + return false; + } + + @Override + public String getFingerprint() { + return "changed"; + } + }, insertionDelay); + } + + @Test + public void soneWithoutOriginalFingerprintIsEligibleAfter60Seconds() { + SoneModificationDetector soneModificationDetector = createDetectorWithoutOriginalFingerprint(); + assertThat(soneModificationDetector.isEligibleForInsert(), is(false)); + passTime(60); + assertThat(soneModificationDetector.isEligibleForInsert(), is(true)); + } + }