✨ Annotate IndexPage with MenuName
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 17 May 2019 09:10:30 +0000 (11:10 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 17 May 2019 09:10:30 +0000 (11:10 +0200)
src/main/kotlin/net/pterodactylus/sone/web/pages/IndexPage.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/IndexPageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/WebPageTest.kt

index f44b145..68e7e8f 100644 (file)
@@ -14,6 +14,7 @@ import javax.inject.Inject
  * The index page shows the main page of Sone. This page will contain the posts
  * of all friends of the current user.
  */
+@MenuName("Index")
 class IndexPage @Inject constructor(template: Template, webInterface: WebInterface, private val postVisibilityFilter: PostVisibilityFilter) :
                LoggedInPage("index.html", template, "Page.Index.Title", webInterface) {
 
index 39be2d6..07eb64a 100644 (file)
@@ -159,4 +159,9 @@ class IndexPageTest: WebPageTest({ template, webInterface -> IndexPage(template,
            assertThat(baseInjector.getInstance<IndexPage>(), notNullValue())
        }
 
+       @Test
+       fun `page is annotated with correct menuname`() {
+           assertThat(page.menuName, equalTo("Index"))
+       }
+
 }
index d48f5fd..5c842df 100644 (file)
@@ -54,6 +54,8 @@ open class WebPageTest(pageSupplier: (Template, WebInterface) -> SoneTemplatePag
        val sessionManager = mock<SessionManager>()
 
        val page by lazy { pageSupplier(template, webInterface) }
+       val SoneTemplatePage.menuName get() = javaClass.getAnnotation(MenuName::class.java)?.value
+
        val httpRequest = mock<HTTPRequest>()
        val freenetRequest = mock<FreenetRequest>()
        init {