+ public void callbackPrioritiesAreInteractive() {
+ freenetInterface.registerUsk(sone, null);
+ assertThat(callbackCaptor.getValue().getPollingPriorityNormal(), is(INTERACTIVE_PRIORITY_CLASS));
+ assertThat(callbackCaptor.getValue().getPollingPriorityProgress(), is(INTERACTIVE_PRIORITY_CLASS));
+ }
+
+ @Test
+ public void callbackForRegisteredSoneWithHigherEditionTriggersDownload() throws InterruptedException {
+ freenetInterface.registerUsk(sone, soneDownloader);
+ final CountDownLatch downloadTriggered = new CountDownLatch(1);
+ doAnswer(new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation) throws Throwable {
+ downloadTriggered.countDown();
+ return null;
+ }
+ }).when(soneDownloader).fetchSone(sone);
+ callbackCaptor.getValue().onFoundEdition(1, null, null, null, false, (short) 0, null, false, false);
+ assertThat(downloadTriggered.await(1, SECONDS), is(true));
+ }
+
+ @Test
+ public void callbackForRegisteredSoneWithTheSameEditionDoesNotTriggerDownload() throws InterruptedException {
+ freenetInterface.registerUsk(sone, soneDownloader);
+ final CountDownLatch downloadTriggered = new CountDownLatch(1);
+ doAnswer(new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation) throws Throwable {
+ downloadTriggered.countDown();
+ return null;
+ }
+ }).when(soneDownloader).fetchSone(sone);
+ callbackCaptor.getValue().onFoundEdition(0, null, null, null, false, (short) 0, null, false, false);
+ assertThat(downloadTriggered.await(1, SECONDS), is(false));
+ }
+
+ @Test