Add more tests for FreenetInterface.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 17 Sep 2014 18:35:13 +0000 (20:35 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 17 Sep 2014 18:35:13 +0000 (20:35 +0200)
src/test/java/net/pterodactylus/sone/core/FreenetInterfaceTest.java

index aa261f5..60c8344 100644 (file)
@@ -223,6 +223,42 @@ public class FreenetInterfaceTest {
        }
 
        @Test
+       public void registeringAnActiveUskWillSubscribeToItCorrectly() {
+               FreenetURI freenetUri = createRandom(randomSource, "test-0").getURI().uskForSSK();
+               final USKCallback uskCallback = mock(USKCallback.class);
+               freenetInterface.registerActiveUsk(freenetUri, uskCallback);
+               verify(uskManager).subscribe(any(USK.class), eq(uskCallback), eq(true), any(RequestClient.class));
+       }
+
+       @Test
+       public void registeringAnInactiveUskWillSubscribeToItCorrectly() {
+               FreenetURI freenetUri = createRandom(randomSource, "test-0").getURI().uskForSSK();
+               final USKCallback uskCallback = mock(USKCallback.class);
+               freenetInterface.registerPassiveUsk(freenetUri, uskCallback);
+               verify(uskManager).subscribe(any(USK.class), eq(uskCallback), eq(false), any(RequestClient.class));
+       }
+
+       @Test
+       public void registeringAnActiveNonUskWillNotSubscribeToAUsk()
+       throws MalformedURLException {
+               FreenetURI freenetUri = createRandom(randomSource, "test-0").getURI();
+           freenetInterface.registerActiveUsk(freenetUri, null);
+               verify(uskManager, never()).subscribe(any(USK.class),
+                               any(USKCallback.class), anyBoolean(),
+                               eq((RequestClient) highLevelSimpleClient));
+       }
+
+       @Test
+       public void registeringAnInactiveNonUskWillNotSubscribeToAUsk()
+       throws MalformedURLException {
+               FreenetURI freenetUri = createRandom(randomSource, "test-0").getURI();
+           freenetInterface.registerPassiveUsk(freenetUri, null);
+               verify(uskManager, never()).subscribe(any(USK.class),
+                               any(USKCallback.class), anyBoolean(),
+                               eq((RequestClient) highLevelSimpleClient));
+       }
+
+       @Test
        public void unregisteringANotRegisteredUskDoesNothing() {
                FreenetURI freenetURI = createRandom(randomSource, "test-0").getURI().uskForSSK();
                freenetInterface.unregisterUsk(freenetURI);