import freenet.keys.FreenetURI;
+import com.google.inject.ImplementedBy;
+
/**
* Downloads and parses Sone and {@link Core#updateSone(Sone) updates the
* core}.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
+@ImplementedBy(SoneDownloaderImpl.class)
public interface SoneDownloader extends Service {
void addSone(Sone sone);
import java.util.logging.Level;
import java.util.logging.Logger;
+import javax.inject.Inject;
+
import net.pterodactylus.sone.core.FreenetInterface.Fetched;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.data.Sone.SoneStatus;
* @param freenetInterface
* The Freenet interface
*/
+ @Inject
public SoneDownloaderImpl(Core core, FreenetInterface freenetInterface) {
this(core, freenetInterface, new SoneParser(core));
}
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;
+import static net.pterodactylus.sone.web.AllPagesTestKt.getBaseInjector;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
import static org.mockito.ArgumentCaptor.forClass;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
return new Fetched(uri, fetchResult);
}
+ @Test
+ public void soneDownloaderCanBeCreatedByDependencyInjection() {
+ assertThat(getBaseInjector().getInstance(SoneDownloader.class), notNullValue());
+ }
+
}
package net.pterodactylus.sone.web
import com.google.inject.Guice.createInjector
+import net.pterodactylus.sone.core.Core
+import net.pterodactylus.sone.core.FreenetInterface
import net.pterodactylus.sone.main.SonePlugin.PluginHomepage
import net.pterodactylus.sone.main.SonePlugin.PluginVersion
import net.pterodactylus.sone.main.SonePlugin.PluginYear
val baseInjector by lazy {
createInjector(
+ Core::class.isProvidedByMock(),
+ FreenetInterface::class.isProvidedByMock(),
Template::class.isProvidedByMock(),
WebInterface::class.isProvidedByMock()
)!!