*/
@Subscribe
public void identityUpdated(IdentityUpdatedEvent identityUpdatedEvent) {
- final Identity identity = identityUpdatedEvent.identity();
- soneDownloaders.execute(new Runnable() {
-
- @Override
- @SuppressWarnings("synthetic-access")
- public void run() {
- Sone sone = getRemoteSone(identity.getId(), false);
- if (sone.isLocal()) {
- return;
- }
- sone.setIdentity(identity);
- sone.setLatestEdition(Numbers.safeParseLong(identity.getProperty("Sone.LatestEdition"), sone.getLatestEdition()));
- soneDownloader.addSone(sone);
- soneDownloader.fetchSone(sone);
- }
- });
+ Identity identity = identityUpdatedEvent.identity();
+ final Sone sone = getRemoteSone(identity.getId(), false);
+ if (sone.isLocal()) {
+ return;
+ }
+ sone.setIdentity(identity);
+ sone.setLatestEdition(Numbers.safeParseLong(identity.getProperty("Sone.LatestEdition"), sone.getLatestEdition()));
+ soneDownloader.addSone(sone);
+ soneDownloaders.execute(soneDownloader.new FetchSone(sone));
}
/**
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import net.pterodactylus.sone.core.SoneDownloader.FetchSone;
import net.pterodactylus.sone.core.SoneDownloader.FetchSoneWithUri;
import net.pterodactylus.sone.data.Sone;
verify(soneDownloader).fetchSone(eq(sone), eq(soneUri));
}
+ @Test
+ public void fetchSoneDownloadsSone() {
+ SoneDownloader soneDownloader = mock(SoneDownloader.class);
+ Sone sone = mock(Sone.class);
+ FetchSone fetchSone = soneDownloader.new FetchSone(sone);
+ fetchSone.run();
+ verify(soneDownloader).fetchSone(eq(sone));
+ }
+
}