Add more tests of sone inserter.
[Sone.git] / src / main / java / net / pterodactylus / sone / core / SoneInserter.java
index 46a3fe7..1e93aa6 100644 (file)
@@ -116,12 +116,17 @@ public class SoneInserter extends AbstractService {
         *            The Sone to insert
         */
        public SoneInserter(Core core, EventBus eventBus, FreenetInterface freenetInterface, Sone sone) {
+               this(core, eventBus, freenetInterface, sone, new SoneModificationDetector(core, sone, insertionDelay));
+       }
+
+       @VisibleForTesting
+       SoneInserter(Core core, EventBus eventBus, FreenetInterface freenetInterface, Sone sone, SoneModificationDetector soneModificationDetector) {
                super("Sone Inserter for “" + sone.getName() + "”", false);
                this.core = core;
                this.eventBus = eventBus;
                this.freenetInterface = freenetInterface;
                this.sone = sone;
-               this.soneModificationDetector = new SoneModificationDetector(core, sone, insertionDelay);
+               this.soneModificationDetector = soneModificationDetector;
        }
 
        //
@@ -136,7 +141,7 @@ public class SoneInserter extends AbstractService {
         * @return This Sone inserter
         */
        public SoneInserter setSone(Sone sone) {
-               checkArgument((this.sone == null) || sone.equals(this.sone), "Sone to insert can not be set to a different Sone");
+               checkArgument(sone.equals(this.sone), "Sone to insert can not be set to a different Sone");
                this.sone = sone;
                return this;
        }
@@ -265,7 +270,8 @@ public class SoneInserter extends AbstractService {
         *
         * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
         */
-       private class InsertInformation {
+       @VisibleForTesting
+       class InsertInformation {
 
                private final String fingerprint;
 
@@ -297,7 +303,8 @@ public class SoneInserter extends AbstractService {
                // ACCESSORS
                //
 
-               private String getFingerprint() {
+               @VisibleForTesting
+               String getFingerprint() {
                        return fingerprint;
                }