I hate the fact that we started using ktfmt.

Whose decision was that anyway..?
This commit is contained in:
Alexander Söderberg 2021-07-10 11:42:40 +01:00 committed by Jason
parent 6871341291
commit e67d0d9310
2 changed files with 44 additions and 42 deletions

View file

@ -1,7 +1,7 @@
//
// MIT License
//
// Copyright (c) 2021 Alexander Söderberg & Contributors
// Copyright (c) 2021 Alexander Söderberg & Contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@ -52,14 +52,14 @@ class CommandBuildingDSLTest {
// ...
}
manager.command(copy {
manager.command(
copy {
literal("bruh_moment")
handler {
// ...
}
})
}
)
})
manager.buildAndRegister("is") {
commandDescription("Command description")
@ -91,13 +91,14 @@ class CommandBuildingDSLTest {
"is this",
"is this going",
"is this going too_far",
).sorted()
)
.sorted())
}
class TestCommandManager : CommandManager<TestCommandSender>(
CommandExecutionCoordinator.simpleCoordinator(), CommandRegistrationHandler.nullCommandRegistrationHandler()
) {
class TestCommandManager :
CommandManager<TestCommandSender>(
CommandExecutionCoordinator.simpleCoordinator(),
CommandRegistrationHandler.nullCommandRegistrationHandler()) {
override fun createDefaultCommandMeta(): SimpleCommandMeta {
return SimpleCommandMeta.empty()
}
@ -109,5 +110,4 @@ class CommandBuildingDSLTest {
open class TestCommandSender
class SpecificCommandSender : TestCommandSender()
}

View file

@ -7,14 +7,14 @@ import cloud.commandframework.execution.AsynchronousCommandExecutionCoordinator
import cloud.commandframework.internal.CommandRegistrationHandler
import cloud.commandframework.meta.CommandMeta
import cloud.commandframework.meta.SimpleCommandMeta
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.future.await
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
class KotlinAnnotatedMethodsTest {
@ -38,31 +38,33 @@ class KotlinAnnotatedMethodsTest {
fun `test suspending command methods`(): Unit = runBlocking {
AnnotationParser(commandManager, TestCommandSender::class.java) {
SimpleCommandMeta.empty()
}.also { it.installCoroutineSupport() }.parse(CommandMethods())
}
.also { it.installCoroutineSupport() }
.parse(CommandMethods())
commandManager.executeCommand(TestCommandSender(), "test").await()
}
private class TestCommandSender {}
private class TestCommandManager : CommandManager<TestCommandSender>(
AsynchronousCommandExecutionCoordinator.newBuilder<TestCommandSender>().withExecutor(executorService).build(),
CommandRegistrationHandler.nullCommandRegistrationHandler()
) {
private class TestCommandManager :
CommandManager<TestCommandSender>(
AsynchronousCommandExecutionCoordinator.newBuilder<TestCommandSender>()
.withExecutor(executorService)
.build(),
CommandRegistrationHandler.nullCommandRegistrationHandler()) {
override fun hasPermission(sender: TestCommandSender, permission: String): Boolean = true
override fun createDefaultCommandMeta(): CommandMeta = SimpleCommandMeta.empty()
}
public class CommandMethods {
@CommandMethod("test")
public suspend fun suspendingCommand(): Unit = withContext(Dispatchers.Default) {
public suspend fun suspendingCommand(): Unit =
withContext(Dispatchers.Default) {
println("called from thread: ${Thread.currentThread().name}")
}
}
}