Add tests for fixed Sone modification detector
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 22 Jul 2015 04:40:42 +0000 (06:40 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 22 Jul 2015 04:40:42 +0000 (06:40 +0200)
src/test/java/net/pterodactylus/sone/core/SoneModificationDetectorTest.java

index d70cc5c..8153e3b 100644 (file)
@@ -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));
+       }
+
 }