Skip to content

Commit

Permalink
Merge pull request #1346 from scireum/feature/smo/migrate-system-cont…
Browse files Browse the repository at this point in the history
…roller-test

JUNIT: migrate system controller test
  • Loading branch information
MOOOOOSER authored Dec 12, 2023
2 parents 420615c + 1c20307 commit c8495b3
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 51 deletions.
51 changes: 0 additions & 51 deletions src/test/java/sirius/web/health/SystemControllerSpec.groovy

This file was deleted.

55 changes: 55 additions & 0 deletions src/test/kotlin/sirius/web/health/SystemControllerTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Made with all the love in the world
* by scireum in Remshalden, Germany
*
* Copyright by scireum GmbH
* http://www.scireum.de - info@scireum.de
*/

package sirius.web.health

import io.netty.handler.codec.http.HttpResponseStatus
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import sirius.kernel.BaseSpecification
import sirius.kernel.SiriusExtension
import sirius.kernel.commons.Value
import sirius.kernel.di.Injector
import sirius.web.http.TestRequest
import sirius.web.http.TestResponse
import sirius.web.security.UserContext
import sirius.web.security.UserInfo
import java.util.*
import kotlin.test.assertEquals

@ExtendWith(SiriusExtension::class)
class SystemControllerTest {

@Test
fun ` system ok returns 200 OK`() {
val result = TestRequest.GET("/system/ok").execute()
assertEquals(HttpResponseStatus.OK, result.getStatus())
}

@Test
fun ` system state renders its template`() {
UserContext.get().setCurrentUser(
UserInfo.Builder.createUser("test")
.withPermissions(Collections.singleton(SystemController.PERMISSION_SYSTEM_STATE)).build()
)
val result = TestRequest.GET("/system/state").execute()
assertEquals(HttpResponseStatus.OK, result.getStatus())
assertEquals(TestResponse.ResponseType.TEMPLATE, result.getType())
assertEquals("/templates/system/state.html.pasta", result.getTemplateName())
assertEquals( Injector.context().getPart(Cluster::class.java), Value.indexOf(0, result.getTemplateParameters()).get())
}

@Test
fun ` system info renders its template`() {
val result = TestRequest.GET("/system/info").execute()
assertEquals(HttpResponseStatus.OK, result.getStatus())
assertEquals(TestResponse.ResponseType.TEMPLATE, result.getType())
assertEquals("/templates/system/info.html.pasta", result.getTemplateName())
}

}

0 comments on commit c8495b3

Please sign in to comment.