diff --git a/cloud-kotlin-extensions/src/test/kotlin/cloud/commandframework/kotlin/CommandBuildingDSLTest.kt b/cloud-kotlin-extensions/src/test/kotlin/cloud/commandframework/kotlin/CommandBuildingDSLTest.kt index c3290f5b..1ad747ab 100644 --- a/cloud-kotlin-extensions/src/test/kotlin/cloud/commandframework/kotlin/CommandBuildingDSLTest.kt +++ b/cloud-kotlin-extensions/src/test/kotlin/cloud/commandframework/kotlin/CommandBuildingDSLTest.kt @@ -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 @@ -40,26 +40,26 @@ class CommandBuildingDSLTest { val manager = TestCommandManager() manager.command( - manager.commandBuilder("kotlin", aliases = arrayOf("alias")) { - permission = "permission" - senderType() + manager.commandBuilder("kotlin", aliases = arrayOf("alias")) { + permission = "permission" + senderType() - literal("dsl") - argument(argumentDescription("An amazing command argument")) { - StringArgument.of("moment") - } - handler { - // ... - } + literal("dsl") + argument(argumentDescription("An amazing command argument")) { + StringArgument.of("moment") + } + handler { + // ... + } - manager.command(copy { + manager.command( + copy { literal("bruh_moment") handler { // ... } }) - } - ) + }) manager.buildAndRegister("is") { commandDescription("Command description") @@ -83,21 +83,22 @@ class CommandBuildingDSLTest { manager.executeCommand(SpecificCommandSender(), "kotlin dsl time bruh_moment") Assertions.assertEquals( - manager.commandHelpHandler.allCommands.map { it.syntaxString }.sorted(), - setOf( - "kotlin dsl ", - "kotlin dsl bruh_moment", - "is", - "is this", - "is this going", - "is this going too_far", - ).sorted() - ) + manager.commandHelpHandler.allCommands.map { it.syntaxString }.sorted(), + setOf( + "kotlin dsl ", + "kotlin dsl bruh_moment", + "is", + "is this", + "is this going", + "is this going too_far", + ) + .sorted()) } - class TestCommandManager : CommandManager( - CommandExecutionCoordinator.simpleCoordinator(), CommandRegistrationHandler.nullCommandRegistrationHandler() - ) { + class TestCommandManager : + CommandManager( + CommandExecutionCoordinator.simpleCoordinator(), + CommandRegistrationHandler.nullCommandRegistrationHandler()) { override fun createDefaultCommandMeta(): SimpleCommandMeta { return SimpleCommandMeta.empty() } @@ -109,5 +110,4 @@ class CommandBuildingDSLTest { open class TestCommandSender class SpecificCommandSender : TestCommandSender() - } diff --git a/cloud-kotlin-extensions/src/test/kotlin/cloud/commandframework/kotlin/coroutines/KotlinAnnotatedMethodsTest.kt b/cloud-kotlin-extensions/src/test/kotlin/cloud/commandframework/kotlin/coroutines/KotlinAnnotatedMethodsTest.kt index 2baa8476..2af059aa 100644 --- a/cloud-kotlin-extensions/src/test/kotlin/cloud/commandframework/kotlin/coroutines/KotlinAnnotatedMethodsTest.kt +++ b/cloud-kotlin-extensions/src/test/kotlin/cloud/commandframework/kotlin/coroutines/KotlinAnnotatedMethodsTest.kt @@ -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 { @@ -37,32 +37,34 @@ class KotlinAnnotatedMethodsTest { @Test fun `test suspending command methods`(): Unit = runBlocking { AnnotationParser(commandManager, TestCommandSender::class.java) { - SimpleCommandMeta.empty() - }.also { it.installCoroutineSupport() }.parse(CommandMethods()) + SimpleCommandMeta.empty() + } + .also { it.installCoroutineSupport() } + .parse(CommandMethods()) commandManager.executeCommand(TestCommandSender(), "test").await() } private class TestCommandSender {} - private class TestCommandManager : CommandManager( - AsynchronousCommandExecutionCoordinator.newBuilder().withExecutor(executorService).build(), - CommandRegistrationHandler.nullCommandRegistrationHandler() - ) { + private class TestCommandManager : + CommandManager( + AsynchronousCommandExecutionCoordinator.newBuilder() + .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) { - println("called from thread: ${Thread.currentThread().name}") - } - + public suspend fun suspendingCommand(): Unit = + withContext(Dispatchers.Default) { + println("called from thread: ${Thread.currentThread().name}") + } } - }