Author: reschke
Date: Thu Jul  4 07:26:44 2019
New Revision: 1862536

URL: http://svn.apache.org/viewvc?rev=1862536&view=rev
Log:
OAK-8453: Refactor VersionGarbageCollector to extract Recommendations class - 
extract helper code into inner class, compute more time consts

Modified:
    
jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCTest.java

Modified: 
jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCTest.java?rev=1862536&r1=1862535&r2=1862536&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCTest.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCTest.java
 Thu Jul  4 07:26:44 2019
@@ -233,19 +233,11 @@ public class VersionGCTest {
         VersionGCOptions options = gc.getOptions();
         final long oneYearAgo = ns.getClock().getTime() - 
TimeUnit.DAYS.toMillis(365);
         final long twelveTimesTheLimit = options.collectLimit * 12;
+        final long secondsPerDay = TimeUnit.DAYS.toMillis(1);
 
-        VersionGCSupport localgcsupport = new 
VersionGCSupport(ns.getDocumentStore()) {
-            @Override
-            public long getOldestDeletedOnceTimestamp(Clock clock, long 
precisionMs) {
-                return oneYearAgo;
-            }
-            @Override
-            public long getDeletedOnceCount() {
-                return twelveTimesTheLimit;
-            }
-        };
+        VersionGCSupport localgcsupport = 
fakeVersionGCSupport(ns.getDocumentStore(), oneYearAgo, twelveTimesTheLimit);
 
-        VersionGCRecommendations rec = new VersionGCRecommendations(86400L, 
ns.getCheckpoints(), ns.getClock(), localgcsupport,
+        VersionGCRecommendations rec = new 
VersionGCRecommendations(secondsPerDay, ns.getCheckpoints(), ns.getClock(), 
localgcsupport,
                 options, new TestGCMonitor());
 
         // should select a duration of roughly one month
@@ -259,7 +251,7 @@ public class VersionGCTest {
         rec.evaluate(stats);
         assertTrue(stats.needRepeat);
 
-        rec = new VersionGCRecommendations(86400L, ns.getCheckpoints(), 
ns.getClock(), localgcsupport, options,
+        rec = new VersionGCRecommendations(secondsPerDay, ns.getCheckpoints(), 
ns.getClock(), localgcsupport, options,
                 new TestGCMonitor());
 
         // new duration should be half
@@ -403,4 +395,19 @@ public class VersionGCTest {
             return this.statusMessages;
         }
     }
+
+    private VersionGCSupport fakeVersionGCSupport(final DocumentStore ds, 
final long oldestDeleted, final long countDeleted) {
+        return new VersionGCSupport(ds) {
+
+            @Override
+            public long getOldestDeletedOnceTimestamp(Clock clock, long 
precisionMs) {
+                return oldestDeleted;
+            }
+
+            @Override
+            public long getDeletedOnceCount() {
+                return countDeleted;
+            }
+        };
+    }
 }


Reply via email to