X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FSoneDownloaderTest.java;h=127837a11d7ec6407e00b6532d38d6777b07ab89;hb=239f08e37721401290f43596e8a7e9aa83aae980;hp=24a1ac91ad4a970d64d65f0eead117f8fbed020b;hpb=40a1ac4c90c1480936c9c782727209cf23acd5e5;p=Sone.git diff --git a/src/test/java/net/pterodactylus/sone/core/SoneDownloaderTest.java b/src/test/java/net/pterodactylus/sone/core/SoneDownloaderTest.java index 24a1ac9..127837a 100644 --- a/src/test/java/net/pterodactylus/sone/core/SoneDownloaderTest.java +++ b/src/test/java/net/pterodactylus/sone/core/SoneDownloaderTest.java @@ -1,7 +1,10 @@ package net.pterodactylus.sone.core; import static com.google.common.base.Optional.of; +import static freenet.keys.InsertableClientSSK.createRandom; +import static java.lang.System.currentTimeMillis; import static java.util.UUID.randomUUID; +import static java.util.concurrent.TimeUnit.DAYS; import static net.pterodactylus.sone.data.Sone.SoneStatus.downloading; import static net.pterodactylus.sone.data.Sone.SoneStatus.idle; import static net.pterodactylus.sone.data.Sone.SoneStatus.unknown; @@ -13,7 +16,6 @@ import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; import static org.mockito.ArgumentCaptor.forClass; import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyBoolean; import static org.mockito.Matchers.anyLong; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; @@ -39,20 +41,26 @@ import net.pterodactylus.sone.data.Album; import net.pterodactylus.sone.data.Album.Modifier; import net.pterodactylus.sone.data.Client; import net.pterodactylus.sone.data.Image; -import net.pterodactylus.sone.data.ImageImpl; import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.data.PostReply; import net.pterodactylus.sone.data.Profile; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.data.Sone.SoneStatus; import net.pterodactylus.sone.database.AlbumBuilder; +import net.pterodactylus.sone.database.ImageBuilder; import net.pterodactylus.sone.database.PostBuilder; import net.pterodactylus.sone.database.PostReplyBuilder; +import net.pterodactylus.sone.database.SoneBuilder; +import net.pterodactylus.sone.database.memory.MemorySoneBuilder; import net.pterodactylus.sone.freenet.wot.Identity; import freenet.client.ClientMetadata; import freenet.client.FetchResult; +import freenet.client.async.USKCallback; +import freenet.crypt.DummyRandomSource; +import freenet.keys.ClientSSK; import freenet.keys.FreenetURI; +import freenet.keys.InsertableClientSSK; import freenet.support.api.Bucket; import com.google.common.base.Optional; @@ -75,9 +83,8 @@ public class SoneDownloaderTest { private final Core core = mock(Core.class); private final FreenetInterface freenetInterface = mock(FreenetInterface.class); private final SoneDownloaderImpl soneDownloader = new SoneDownloaderImpl(core, freenetInterface); - private final SoneUpdater soneUpdater = mock(SoneUpdater.class); - private final FreenetURI requestUri = mock(FreenetURI.class); - private final Sone sone = mock(Sone.class); + private FreenetURI requestUri = mock(FreenetURI.class); + private Sone sone = mock(Sone.class); private final PostBuilder postBuilder = mock(PostBuilder.class); private final List createdPosts = new ArrayList(); private Post post = mock(Post.class); @@ -89,23 +96,42 @@ public class SoneDownloaderTest { private final ListMultimap albumImages = ArrayListMultimap.create(); private Album album = mock(Album.class); private final Map albums = new HashMap(); + private final ImageBuilder imageBuilder = mock(ImageBuilder.class); + private Image image = mock(Image.class); + private final Map images = new HashMap(); @Before public void setupSone() { + Sone sone = SoneDownloaderTest.this.sone; Identity identity = mock(Identity.class); + InsertableClientSSK clientSSK = createRandom(new DummyRandomSource(), "WoT"); + when(identity.getRequestUri()).thenReturn(clientSSK.getURI().toString()); when(identity.getId()).thenReturn("identity"); when(sone.getId()).thenReturn("identity"); when(sone.getIdentity()).thenReturn(identity); - when(sone.getRequestUri()).thenReturn(requestUri); + requestUri = clientSSK.getURI().setKeyType("USK").setDocName("Sone"); + when(sone.getRequestUri()).thenAnswer(new Answer() { + @Override + public FreenetURI answer(InvocationOnMock invocation) + throws Throwable { + return requestUri; + } + }); + when(sone.getTime()).thenReturn(currentTimeMillis() - DAYS.toMillis(1)); + } + + private void setupSoneAsUnknown() { + when(sone.getTime()).thenReturn(0L); } @Before - public void setupRequestUri() { - when(requestUri.setKeyType(anyString())).thenReturn(requestUri); - when(requestUri.sskForUSK()).thenReturn(requestUri); - when(requestUri.setDocName(anyString())).thenReturn(requestUri); - when(requestUri.setMetaString(any(String[].class))).thenReturn(requestUri); - when(requestUri.getKeyType()).thenReturn("USK"); + public void setupSoneBuilder() { + when(core.soneBuilder()).thenAnswer(new Answer() { + @Override + public SoneBuilder answer(InvocationOnMock invocation) { + return new MemorySoneBuilder(); + } + }); } @Before @@ -174,30 +200,42 @@ public class SoneDownloaderTest { return postReplyBuilder; } }); - when(postReplyBuilder.from(anyString())).thenAnswer(new Answer() { - @Override - public PostReplyBuilder answer(InvocationOnMock invocation) throws Throwable { - Sone sone = when(mock(Sone.class).getId()).thenReturn((String) invocation.getArguments()[0]).getMock(); - when(postReply.getSone()).thenReturn(sone); - return postReplyBuilder; - } - }); - when(postReplyBuilder.to(anyString())).thenAnswer(new Answer() { - @Override - public PostReplyBuilder answer(InvocationOnMock invocation) throws Throwable { - when(postReply.getPostId()).thenReturn((String) invocation.getArguments()[0]); - Post post = when(mock(Post.class).getId()).thenReturn((String) invocation.getArguments()[0]).getMock(); - when(postReply.getPost()).thenReturn(of(post)); - return postReplyBuilder; - } - }); - when(postReplyBuilder.withTime(anyLong())).thenAnswer(new Answer() { - @Override - public PostReplyBuilder answer(InvocationOnMock invocation) throws Throwable { - when(postReply.getTime()).thenReturn((Long) invocation.getArguments()[0]); - return postReplyBuilder; - } - }); + when(postReplyBuilder.from(anyString())).thenAnswer( + new Answer() { + @Override + public PostReplyBuilder answer( + InvocationOnMock invocation) throws Throwable { + Sone sone = when(mock(Sone.class).getId()).thenReturn( + (String) invocation.getArguments()[0]) + .getMock(); + when(postReply.getSone()).thenReturn(sone); + return postReplyBuilder; + } + }); + when(postReplyBuilder.to(anyString())).thenAnswer( + new Answer() { + @Override + public PostReplyBuilder answer( + InvocationOnMock invocation) throws Throwable { + when(postReply.getPostId()).thenReturn( + (String) invocation.getArguments()[0]); + Post post = when(mock(Post.class).getId()).thenReturn( + (String) invocation.getArguments()[0]) + .getMock(); + when(postReply.getPost()).thenReturn(of(post)); + return postReplyBuilder; + } + }); + when(postReplyBuilder.withTime(anyLong())).thenAnswer( + new Answer() { + @Override + public PostReplyBuilder answer( + InvocationOnMock invocation) throws Throwable { + when(postReply.getTime()).thenReturn( + (Long) invocation.getArguments()[0]); + return postReplyBuilder; + } + }); when(postReplyBuilder.withText(anyString())).thenAnswer(new Answer() { @Override public PostReplyBuilder answer(InvocationOnMock invocation) throws Throwable { @@ -219,10 +257,7 @@ public class SoneDownloaderTest { @Before public void setupAlbum() { - setupAlbum(album); - } - - private void setupAlbum(final Album album) { + final Album album = SoneDownloaderTest.this.album; when(album.getAlbumImage()).thenReturn(mock(Image.class)); doAnswer(new Answer() { @Override @@ -315,7 +350,7 @@ public class SoneDownloaderTest { Album album = SoneDownloaderTest.this.album; albums.put(album.getId(), album); SoneDownloaderTest.this.album = mock(Album.class); - setupAlbum(SoneDownloaderTest.this.album); + setupAlbum(); return album; } }); @@ -326,23 +361,129 @@ public class SoneDownloaderTest { public void setupAlbums() { when(core.getAlbum(anyString())).thenAnswer(new Answer() { @Override - public Album answer(InvocationOnMock invocation) throws Throwable { + public Album answer(InvocationOnMock invocation) + throws Throwable { return albums.get(invocation.getArguments()[0]); } }); } @Before + public void setupImage() { + final Image image = SoneDownloaderTest.this.image; + Image.Modifier modifier = new Image.Modifier() { + private Sone sone = image.getSone(); + private long creationTime = image.getCreationTime(); + private String key = image.getKey(); + private String title = image.getTitle(); + private String description = image.getDescription(); + private int width = image.getWidth(); + private int height = image.getHeight(); + + @Override + public Image.Modifier setSone(Sone sone) { + this.sone = sone; + return this; + } + + @Override + public Image.Modifier setCreationTime(long creationTime) { + this.creationTime = creationTime; + return this; + } + + @Override + public Image.Modifier setKey(String key) { + this.key = key; + return this; + } + + @Override + public Image.Modifier setTitle(String title) { + this.title = title; + return this; + } + + @Override + public Image.Modifier setDescription(String description) { + this.description = description; + return this; + } + + @Override + public Image.Modifier setWidth(int width) { + this.width = width; + return this; + } + + @Override + public Image.Modifier setHeight(int height) { + this.height = height; + return this; + } + + @Override + public Image update() throws IllegalStateException { + when(image.getSone()).thenReturn(sone); + when(image.getCreationTime()).thenReturn(creationTime); + when(image.getKey()).thenReturn(key); + when(image.getTitle()).thenReturn(title); + when(image.getDescription()).thenReturn(description); + when(image.getWidth()).thenReturn(width); + when(image.getHeight()).thenReturn(height); + return image; + } + }; + when(image.getSone()).thenReturn(sone); + when(image.modify()).thenReturn(modifier); + } + + @Before + public void setupImageBuilder() { + when(imageBuilder.randomId()).thenAnswer(new Answer() { + @Override + public ImageBuilder answer(InvocationOnMock invocation) { + when(image.getId()).thenReturn(randomUUID().toString()); + return imageBuilder; + } + }); + when(imageBuilder.withId(anyString())).thenAnswer(new Answer() { + @Override + public ImageBuilder answer(InvocationOnMock invocation) { + when(image.getId()).thenReturn( + (String) invocation.getArguments()[0]); + return imageBuilder; + } + }); + when(imageBuilder.build()).thenAnswer(new Answer() { + @Override + public Image answer(InvocationOnMock invocation) { + Image image = SoneDownloaderTest.this.image; + images.put(image.getId(), image); + SoneDownloaderTest.this.image = mock(Image.class); + setupImage(); + return image; + } + }); + when(core.imageBuilder()).thenReturn(imageBuilder); + } + + @Before public void setupImages() { - Image image = new ImageImpl("image-id"); - when(core.getImage("image-id")).thenReturn(image); - when(core.getImage(eq("image-id"), anyBoolean())).thenReturn(image); + when(core.getImage(anyString())).thenAnswer(new Answer() { + @Override + public Image answer(InvocationOnMock invocation) + throws Throwable { + return images.get(invocation.getArguments()[0]); + } + }); } @Test public void addingASoneWillRegisterItsKey() { soneDownloader.addSone(sone); - verify(freenetInterface).registerUsk(eq(sone), any(SoneUpdater.class)); + verify(freenetInterface).registerActiveUsk(eq(sone.getRequestUri()), any( + USKCallback.class)); verify(freenetInterface, never()).unregisterUsk(sone); } @@ -350,7 +491,8 @@ public class SoneDownloaderTest { public void addingASoneTwiceWillAlsoDeregisterItsKey() { soneDownloader.addSone(sone); soneDownloader.addSone(sone); - verify(freenetInterface, times(2)).registerUsk(eq(sone), any(SoneUpdater.class)); + verify(freenetInterface, times(2)).registerActiveUsk(eq( + sone.getRequestUri()), any(USKCallback.class)); verify(freenetInterface).unregisterUsk(sone); } @@ -411,13 +553,15 @@ public class SoneDownloaderTest { @Test public void parsingASoneSucceedsWithoutPayload() throws SoneException { InputStream inputStream = getClass().getResourceAsStream("sone-parser-no-payload.xml"); - assertThat(soneDownloader.parseSone(sone, inputStream).getTime(), is(1407197508000L)); + assertThat(soneDownloader.parseSone(sone, inputStream).getTime(), is( + 1407197508000L)); } @Test public void parsingASoneSucceedsWithoutProtocolVersion() throws SoneException { InputStream inputStream = getClass().getResourceAsStream("sone-parser-missing-protocol-version.xml"); - assertThat(soneDownloader.parseSone(sone, inputStream), not(nullValue())); + assertThat(soneDownloader.parseSone(sone, inputStream), not( + nullValue())); } @Test @@ -439,30 +583,6 @@ public class SoneDownloaderTest { } @Test - public void parsingASoneSucceedsWithRequestUri() throws SoneException, MalformedURLException { - InputStream inputStream = getClass().getResourceAsStream("sone-parser-with-request-uri.xml"); - assertThat(soneDownloader.parseSone(sone, inputStream).getRequestUri().toString(), is("USK@w~RyTGmv12Lg9oO91q1Untupi7my9qczT1RheGkEkVE,E8ElVfUgukSCPHxIEJp-gHMiR80wpM7sID3Jo5O7w1s,AQACAAE/Sone/0")); - } - - @Test - public void parsingASoneFailsWithInvalidRequestUri() throws SoneException, MalformedURLException { - InputStream inputStream = getClass().getResourceAsStream("sone-parser-with-invalid-request-uri.xml"); - assertThat(soneDownloader.parseSone(sone, inputStream), nullValue()); - } - - @Test - public void soneInsertUriIsCopiedToNewSone() throws SoneException { - InputStream inputStream = getClass().getResourceAsStream("sone-parser-no-payload.xml"); - FreenetURI insertUri = mock(FreenetURI.class); - when(insertUri.setKeyType(anyString())).thenReturn(insertUri); - when(insertUri.setDocName(anyString())).thenReturn(insertUri); - when(insertUri.setMetaString(any(String[].class))).thenReturn(insertUri); - when(insertUri.setSuggestedEdition(anyLong())).thenReturn(insertUri); - when(sone.getInsertUri()).thenReturn(insertUri); - assertThat(soneDownloader.parseSone(sone, inputStream).getInsertUri(), is(insertUri)); - } - - @Test public void parsingASoneSucceedsWithProfile() throws SoneException, MalformedURLException { InputStream inputStream = getClass().getResourceAsStream("sone-parser-with-profile.xml"); final Profile profile = soneDownloader.parseSone(sone, inputStream).getProfile(); @@ -524,7 +644,8 @@ public class SoneDownloaderTest { assertThat(posts.get(0).getSone().getId(), is(sone.getId())); assertThat(posts.get(0).getId(), is("post-id")); assertThat(posts.get(0).getTime(), is(1407197508000L)); - assertThat(posts.get(0).getRecipientId(), is(of("1234567890123456789012345678901234567890123"))); + assertThat(posts.get(0).getRecipientId(), is(of( + "1234567890123456789012345678901234567890123"))); assertThat(posts.get(0).getText(), is("text")); } @@ -587,31 +708,36 @@ public class SoneDownloaderTest { @Test public void parsingASoneSucceedsWithoutLikedPostIds() throws SoneException, MalformedURLException { InputStream inputStream = getClass().getResourceAsStream("sone-parser-without-liked-post-ids.xml"); - assertThat(soneDownloader.parseSone(sone, inputStream), not(nullValue())); + assertThat(soneDownloader.parseSone(sone, inputStream), not( + nullValue())); } @Test public void parsingASoneSucceedsWithLikedPostIds() throws SoneException, MalformedURLException { InputStream inputStream = getClass().getResourceAsStream("sone-parser-with-liked-post-ids.xml"); - assertThat(soneDownloader.parseSone(sone, inputStream).getLikedPostIds(), is((Set) ImmutableSet.of("liked-post-id"))); + assertThat(soneDownloader.parseSone(sone, inputStream).getLikedPostIds(), is( + (Set) ImmutableSet.of("liked-post-id"))); } @Test public void parsingASoneSucceedsWithoutLikedPostReplyIds() throws SoneException, MalformedURLException { InputStream inputStream = getClass().getResourceAsStream("sone-parser-without-liked-post-reply-ids.xml"); - assertThat(soneDownloader.parseSone(sone, inputStream), not(nullValue())); + assertThat(soneDownloader.parseSone(sone, inputStream), not( + nullValue())); } @Test public void parsingASoneSucceedsWithLikedPostReplyIds() throws SoneException, MalformedURLException { InputStream inputStream = getClass().getResourceAsStream("sone-parser-with-liked-post-reply-ids.xml"); - assertThat(soneDownloader.parseSone(sone, inputStream).getLikedReplyIds(), is((Set) ImmutableSet.of("liked-post-reply-id"))); + assertThat(soneDownloader.parseSone(sone, inputStream).getLikedReplyIds(), is( + (Set) ImmutableSet.of("liked-post-reply-id"))); } @Test public void parsingASoneSucceedsWithoutAlbums() throws SoneException, MalformedURLException { InputStream inputStream = getClass().getResourceAsStream("sone-parser-without-albums.xml"); - assertThat(soneDownloader.parseSone(sone, inputStream), not(nullValue())); + assertThat(soneDownloader.parseSone(sone, inputStream), not( + nullValue())); } @Test @@ -653,7 +779,8 @@ public class SoneDownloaderTest { @Test public void parsingASoneSucceedsWithoutImages() throws SoneException, MalformedURLException { InputStream inputStream = getClass().getResourceAsStream("sone-parser-without-images.xml"); - assertThat(soneDownloader.parseSone(sone, inputStream), not(nullValue())); + assertThat(soneDownloader.parseSone(sone, inputStream), not( + nullValue())); } @Test @@ -731,8 +858,11 @@ public class SoneDownloaderTest { @Test public void notBeingAbleToFetchAnUnknownSoneDoesNotUpdateCore() { + FreenetURI finalRequestUri = requestUri.sskForUSK() + .setMetaString(new String[] { "sone.xml" }); + setupSoneAsUnknown(); soneDownloader.fetchSoneAction(sone).run(); - verify(freenetInterface).fetchUri(requestUri); + verify(freenetInterface).fetchUri(finalRequestUri); verifyThatSoneStatusWasChangedToDownloadingAndBackTo(unknown); verify(core, never()).updateSone(any(Sone.class)); } @@ -746,20 +876,24 @@ public class SoneDownloaderTest { @Test public void notBeingAbleToFetchAKnownSoneDoesNotUpdateCore() { - when(sone.getTime()).thenReturn(1000L); + FreenetURI finalRequestUri = requestUri.sskForUSK() + .setMetaString(new String[] { "sone.xml" }); soneDownloader.fetchSoneAction(sone).run(); - verify(freenetInterface).fetchUri(requestUri); + verify(freenetInterface).fetchUri(finalRequestUri); verifyThatSoneStatusWasChangedToDownloadingAndBackTo(idle); verify(core, never()).updateSone(any(Sone.class)); } @Test(expected = NullPointerException.class) public void exceptionWhileFetchingAnUnknownSoneDoesNotUpdateCore() { - when(freenetInterface.fetchUri(requestUri)).thenThrow(NullPointerException.class); + FreenetURI finalRequestUri = requestUri.sskForUSK() + .setMetaString(new String[] { "sone.xml" }); + setupSoneAsUnknown(); + when(freenetInterface.fetchUri(finalRequestUri)).thenThrow(NullPointerException.class); try { soneDownloader.fetchSoneAction(sone).run(); } finally { - verify(freenetInterface).fetchUri(requestUri); + verify(freenetInterface).fetchUri(finalRequestUri); verifyThatSoneStatusWasChangedToDownloadingAndBackTo(unknown); verify(core, never()).updateSone(any(Sone.class)); } @@ -767,12 +901,13 @@ public class SoneDownloaderTest { @Test(expected = NullPointerException.class) public void exceptionWhileFetchingAKnownSoneDoesNotUpdateCore() { - when(sone.getTime()).thenReturn(1000L); - when(freenetInterface.fetchUri(requestUri)).thenThrow(NullPointerException.class); + FreenetURI finalRequestUri = requestUri.sskForUSK() + .setMetaString(new String[] { "sone.xml" }); + when(freenetInterface.fetchUri(finalRequestUri)).thenThrow( NullPointerException.class); try { soneDownloader.fetchSoneAction(sone).run(); } finally { - verify(freenetInterface).fetchUri(requestUri); + verify(freenetInterface).fetchUri(finalRequestUri); verifyThatSoneStatusWasChangedToDownloadingAndBackTo(idle); verify(core, never()).updateSone(any(Sone.class)); } @@ -780,8 +915,11 @@ public class SoneDownloaderTest { @Test public void successfulFetchingOfSoneWithUskRequestUriUpdatesTheCoreWithASone() throws IOException { - final Fetched fetchResult = createFetchResult(requestUri, getClass().getResourceAsStream("sone-parser-no-payload.xml")); - when(freenetInterface.fetchUri(requestUri)).thenReturn(fetchResult); + FreenetURI finalRequestUri = requestUri.sskForUSK() + .setMetaString(new String[] { "sone.xml" }); + final Fetched fetchResult = createFetchResult(finalRequestUri, + getClass().getResourceAsStream("sone-parser-no-payload.xml")); + when(freenetInterface.fetchUri(finalRequestUri)).thenReturn(fetchResult); soneDownloader.fetchSoneAction(sone).run(); verifyThatParsedSoneHasTheSameIdAsTheOriginalSone(); } @@ -793,24 +931,6 @@ public class SoneDownloaderTest { } @Test - public void successfulFetchingOfSoneWithSskRequestUriUpdatesTheCoreWithASone() throws IOException { - when(requestUri.getKeyType()).thenReturn("SSK"); - final Fetched fetchResult = createFetchResult(requestUri, getClass().getResourceAsStream("sone-parser-no-payload.xml")); - when(freenetInterface.fetchUri(requestUri)).thenReturn(fetchResult); - soneDownloader.fetchSoneAction(sone).run(); - verifyThatParsedSoneHasTheSameIdAsTheOriginalSone(); - } - - @Test - public void successfulFetchingAnUnknownSoneWithSskRequestUriUpdatesTheCoreWithASone() throws IOException { - when(requestUri.getKeyType()).thenReturn("SSK"); - final Fetched fetchResult = createFetchResult(requestUri, getClass().getResourceAsStream("sone-parser-with-zero-time.xml")); - when(freenetInterface.fetchUri(requestUri)).thenReturn(fetchResult); - soneDownloader.fetchSoneAction(sone).run(); - verifyThatParsedSoneHasTheSameIdAsTheOriginalSone(); - } - - @Test public void fetchingSoneWithInvalidXmlWillNotUpdateTheCore() throws IOException { final Fetched fetchResult = createFetchResult(requestUri, getClass().getResourceAsStream("sone-parser-not-xml.xml")); when(freenetInterface.fetchUri(requestUri)).thenReturn(fetchResult); @@ -821,7 +941,7 @@ public class SoneDownloaderTest { @Test public void exceptionWhileFetchingSoneWillNotUpdateTheCore() throws IOException { final Fetched fetchResult = createFetchResult(requestUri, getClass().getResourceAsStream("sone-parser-no-payload.xml")); - when(sone.getId()).thenThrow(NullPointerException.class); + when(core.soneBuilder()).thenReturn(null); when(freenetInterface.fetchUri(requestUri)).thenReturn(fetchResult); soneDownloader.fetchSoneAction(sone).run(); verify(core, never()).updateSone(any(Sone.class)); @@ -833,7 +953,7 @@ public class SoneDownloaderTest { when(freenetInterface.fetchUri(requestUri)).thenReturn(fetchResult); soneDownloader.fetchSone(sone, sone.getRequestUri(), true); verify(core, never()).updateSone(any(Sone.class)); - verifyThatSoneStatusWasChangedToDownloadingAndBackTo(unknown); + verifyThatSoneStatusWasChangedToDownloadingAndBackTo(idle); } private Fetched createFetchResult(FreenetURI uri, InputStream inputStream) throws IOException {