Skip to content

Commit

Permalink
#107 Fixed minestom unittests.
Browse files Browse the repository at this point in the history
  • Loading branch information
shynixn committed Jan 3, 2024
1 parent 8784e68 commit 000ea29
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package helper

import net.kyori.adventure.text.logger.slf4j.ComponentLogger
import net.minestom.server.MinecraftServer
import net.minestom.server.extensions.Extension
import org.slf4j.Logger

class MockedMinestomServer {
fun boot(mlogger: ComponentLogger? = null): Extension {
fun boot(mlogger: Logger? = null): Extension {
val extension = MockedExtension(mlogger)
MinecraftServer.init()
Thread {
Expand All @@ -17,7 +17,7 @@ class MockedMinestomServer {
return extension
}

class MockedExtension(private val logger: ComponentLogger?) : Extension() {
class MockedExtension(private val logger: Logger?) : Extension() {
override fun initialize() {
}

Expand All @@ -30,7 +30,7 @@ class MockedMinestomServer {
*
* @return The logger for the extension
*/
override fun getLogger(): ComponentLogger {
override fun getLogger(): Logger {
if (logger != null) {
return logger
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import com.github.shynixn.mccoroutine.minestom.launch
import helper.MockedMinestomServer
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import net.kyori.adventure.text.logger.slf4j.ComponentLogger
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import org.mockito.Mockito
import org.slf4j.Logger

class MinestomExceptionTest {
/**
Expand All @@ -22,7 +22,7 @@ class MinestomExceptionTest {
fun extensionLaunch_MultipleFailingCoroutineScopes_ShouldBeCaughtInRootScopeAndKeepExtensionScopeRunning() {
// Arrange
val testServer = MockedMinestomServer()
val logger = Mockito.mock(ComponentLogger::class.java)
val logger = Mockito.mock(Logger::class.java)
var logMessageCounter = 0
Mockito.`when`(
logger.error(Mockito.anyString(), Mockito.any())
Expand Down

0 comments on commit 000ea29

Please sign in to comment.