Add test for restarting the wait period after changing the Sone.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 24 Jun 2014 17:33:35 +0000 (19:33 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 24 Jun 2014 17:33:35 +0000 (19:33 +0200)
src/test/java/net/pterodactylus/sone/core/SoneModificationDetectorTest.java

index fec97b1..388319b 100644 (file)
@@ -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));