/**
* Unit test for [OptionsPage].
*/
-class OptionsPageTest: WebPageTest() {
-
- private val page = OptionsPage(template, webInterface)
-
- override fun getPage() = page
+class OptionsPageTest: WebPageTest2(::OptionsPage) {
@Before
fun setupPreferences() {
private fun <T> verifyThatPreferencesCanBeSet(name: String, setValue: String?, expectedValue: T, getter: () -> T) {
unsetCurrentSone()
setMethod(POST)
- addHttpRequestPart(name, setValue)
+ setValue?.also { addHttpRequestPart(name, it) }
verifyRedirect("options.html") {
assertThat(getter(), equalTo(expectedValue))
}
whenever(httpRequest.getLongParam(anyString(), anyLong())).then { getRequestParameters[it[0]]?.first()?.toLongOrNull() ?: it[1] }
whenever(httpRequest.getMultipleParam(anyString())).then { getRequestParameters[it[0]]?.toTypedArray() ?: emptyArray<String>() }
whenever(httpRequest.getMultipleIntParam(anyString())).then { getRequestParameters[it[0]]?.map { it.toIntOrNull() ?: 0 } ?: emptyArray<Int>() }
+ whenever(httpRequest.isPartSet(anyString())).then { it[0] in postRequestParameters }
whenever(httpRequest.getPartAsStringFailsafe(anyString(), anyInt())).then { postRequestParameters[it[0]]?.decode()?.take(it[1]) ?: "" }
}