From 8bae6b092c9bd34f93de40b71777792da47fc638 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 22 Jul 2015 06:40:42 +0200 Subject: [PATCH] Add tests for fixed Sone modification detector --- .../sone/core/SoneModificationDetectorTest.java | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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)); + } + } -- 2.7.4