package net.pterodactylus.sone.main
-import com.google.inject.Binder
-import com.google.inject.Module
-import com.google.inject.Provides
-import freenet.client.HighLevelSimpleClient
+import com.google.inject.*
+import freenet.client.*
import freenet.clients.http.*
-import freenet.node.Node
-import freenet.pluginmanager.PluginRespirator
+import freenet.node.*
+import freenet.pluginmanager.*
import javax.inject.Provider
import javax.inject.Singleton
/**
* Guice [Module] that supplies some objects that are in fact supplied by the Freenet node.
*/
-class FreenetModule(private val pluginRespirator: PluginRespirator): Module {
+class FreenetModule(private val pluginRespirator: PluginRespirator) : Module {
override fun configure(binder: Binder): Unit = binder.run {
bind(PluginRespirator::class.java).toProvider(Provider<PluginRespirator> { pluginRespirator })
bind(PageMaker::class.java).toProvider(Provider<PageMaker> { pluginRespirator.pageMaker })
}
- @Provides @Singleton
+ @Provides
+ @Singleton
fun getSessionManager() = pluginRespirator.getSessionManager("Sone")!!
}
package net.pterodactylus.sone.main
-import com.google.inject.Guice
-import freenet.client.HighLevelSimpleClient
+import com.google.inject.*
+import freenet.client.*
import freenet.clients.http.*
-import freenet.node.Node
-import freenet.pluginmanager.PluginRespirator
-import net.pterodactylus.sone.test.deepMock
-import net.pterodactylus.sone.test.getInstance
-import net.pterodactylus.sone.test.mock
-import net.pterodactylus.sone.test.whenever
-import org.hamcrest.MatcherAssert.assertThat
-import org.hamcrest.Matchers.sameInstance
-import org.junit.Test
-import org.mockito.Mockito.verify
+import freenet.node.*
+import freenet.pluginmanager.*
+import net.pterodactylus.sone.test.*
+import org.hamcrest.MatcherAssert.*
+import org.hamcrest.Matchers.*
+import org.junit.*
+import org.mockito.Mockito.*
/**
* Unit test for [FreenetModule].
private val module = FreenetModule(pluginRespirator)
private val injector = Guice.createInjector(module)
- private inline fun <reified T: Any> verifySingletonInstance() {
+ private inline fun <reified T : Any> verifySingletonInstance() {
val firstInstance = injector.getInstance<T>()
val secondInstance = injector.getInstance<T>()
assertThat(firstInstance, sameInstance(secondInstance))
@Test
fun `toadlet container is returned correctly`() {
- assertThat(injector.getInstance(), sameInstance(toadletContainer))
+ assertThat(injector.getInstance(), sameInstance(toadletContainer))
}
@Test