Add test for DI constructability of SoneDownloader
[Sone.git] / src / test / java / net / pterodactylus / sone / web / AllPagesTest.kt
1 package net.pterodactylus.sone.web
2
3 import com.google.inject.Guice.createInjector
4 import net.pterodactylus.sone.core.Core
5 import net.pterodactylus.sone.core.FreenetInterface
6 import net.pterodactylus.sone.main.SonePlugin.PluginHomepage
7 import net.pterodactylus.sone.main.SonePlugin.PluginVersion
8 import net.pterodactylus.sone.main.SonePlugin.PluginYear
9 import net.pterodactylus.sone.test.getInstance
10 import net.pterodactylus.sone.test.isProvidedByMock
11 import net.pterodactylus.util.template.Template
12 import org.hamcrest.MatcherAssert.assertThat
13 import org.hamcrest.Matchers.notNullValue
14 import org.junit.Test
15
16 /**
17  * Test for [AllPages].
18  */
19 class AllPagesTest {
20
21         private val injector by lazy {
22                 baseInjector.createChildInjector(
23                                 PluginVersion::class.isProvidedByMock(),
24                                 PluginYear::class.isProvidedByMock(),
25                                 PluginHomepage::class.isProvidedByMock()
26                 )!!
27         }
28         private val allPages by lazy { injector.getInstance<AllPages>() }
29
30         @Test
31         fun `about page can be injected`() {
32                 assertThat(allPages.aboutPage, notNullValue())
33         }
34
35 }
36
37 val baseInjector by lazy {
38         createInjector(
39                         Core::class.isProvidedByMock(),
40                         FreenetInterface::class.isProvidedByMock(),
41                         Template::class.isProvidedByMock(),
42                         WebInterface::class.isProvidedByMock()
43         )!!
44 }