package net.pterodactylus.sone.web
-import com.google.inject.Guice
+import com.google.inject.Guice.createInjector
import net.pterodactylus.sone.main.SonePlugin.PluginHomepage
import net.pterodactylus.sone.main.SonePlugin.PluginVersion
import net.pterodactylus.sone.main.SonePlugin.PluginYear
class AllPagesTest {
private val injector by lazy {
- Guice.createInjector(
- Template::class.isProvidedByMock(),
- WebInterface::class.isProvidedByMock(),
+ baseInjector.createChildInjector(
PluginVersion::class.isProvidedByMock(),
PluginYear::class.isProvidedByMock(),
PluginHomepage::class.isProvidedByMock()
}
}
+
+val baseInjector by lazy {
+ createInjector(
+ Template::class.isProvidedByMock(),
+ WebInterface::class.isProvidedByMock()
+ )!!
+}
package net.pterodactylus.sone.web.pages
-import com.google.inject.Guice
import net.pterodactylus.sone.main.SonePlugin.PluginHomepage
import net.pterodactylus.sone.main.SonePlugin.PluginVersion
import net.pterodactylus.sone.main.SonePlugin.PluginYear
import net.pterodactylus.sone.test.getInstance
import net.pterodactylus.sone.test.isProvidedByMock
-import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.util.template.Template
+import net.pterodactylus.sone.web.baseInjector
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.equalTo
import org.hamcrest.Matchers.notNullValue
@Test
fun `about page can be created by dependency injection`() {
- val injector = Guice.createInjector(
- Template::class.isProvidedByMock(),
- WebInterface::class.isProvidedByMock(),
+ val injector = baseInjector.createChildInjector(
PluginVersion::class.isProvidedByMock(),
PluginYear::class.isProvidedByMock(),
PluginHomepage::class.isProvidedByMock()