return (size > 2097152) || (!mimeType.startsWith("image/") && !mimeType.startsWith("text/html"))
}
- override fun loaded(uri: FreenetURI, mimeType: String, data: ByteArray) {
- MimeType(mimeType).also { mimeType ->
+ override fun loaded(uri: FreenetURI, mimeTypeText: String, data: ByteArray) {
+ MimeType(mimeTypeText).also { mimeType ->
when {
mimeType.primaryType == "image" -> {
ByteArrayInputStream(data).use {
}
override fun createJsonObject(request: FreenetRequest) =
- (webInterface.getCurrentSoneWithoutCreatingSession(request.toadletContext) as Sone?).let { currentSone ->
+ webInterface.getCurrentSoneWithoutCreatingSession(request.toadletContext).let { currentSone ->
createSuccessJsonObject().apply {
this["loggedIn"] = currentSone != null
this["options"] = currentSone?.options?.toJsonOptions() ?: jsonObject {}
("Field." + this["${prefix}Field.$it.Name"]) to this["${prefix}Field.$it.Value"]
}
- private fun SimpleFieldSet.parseFromSimpleFieldSet(prefix: String, vararg fields: String) = listOf(*fields)
- .map { it to (get(prefix + it) as String?) }
- .toMap()
+ private fun SimpleFieldSet.parseFromSimpleFieldSet(prefix: String, vararg fields: String): Map<String, String?> = fields
+ .associate { it to get(prefix + it) }
protected fun matchesPost(post: Post) = OneByOneMatcher<Map<String, String?>>().apply {
expect("ID", post.id) { it["ID"] }
assertThat(accessor.get(templateContext, sone, member), equalTo(expected))
}
+ @Suppress("UNCHECKED_CAST")
private fun <T : Any> assertAccessorReturnValueMatches(member: String, matcher: Matcher<in T>) {
assertThat(accessor.get(templateContext, sone, member) as T, matcher)
}
import javax.inject.Provider
import kotlin.reflect.KClass
-fun <T : Any> KClass<T>.isInstance(instance: T) = Module { it.bind(this.java).toInstance(instance) }
fun <T : Any> KClass<T>.isProvidedBy(instance: T) = Module { it.bind(this.java).toProvider { instance } }
fun <T : Any> KClass<T>.isProvidedBy(provider: com.google.inject.Provider<T>) = Module { it.bind(this.java).toProvider(provider) }
fun <T : Any> KClass<T>.isProvidedBy(provider: KClass<out Provider<T>>) = Module { it.bind(this.java).toProvider(provider.java) }
protected val preferences = Preferences(eventBus)
protected val elementLoader = mock<ElementLoader>()
protected open val page: JsonPage by lazy { pageSupplier(webInterface) }
- protected val json by lazy { page.createJsonObject(freenetRequest)!! }
+ protected val json by lazy { page.createJsonObject(freenetRequest) }
protected val toadletContext = mock<ToadletContext>()
protected val freenetRequest = mock<FreenetRequest>()