diff --git a/src/main/kotlin/de/darkatra/vrising/discord/clients/botcompanion/BotCompanionClient.kt b/src/main/kotlin/de/darkatra/vrising/discord/clients/botcompanion/BotCompanionClient.kt index fc7f77e..846062e 100644 --- a/src/main/kotlin/de/darkatra/vrising/discord/clients/botcompanion/BotCompanionClient.kt +++ b/src/main/kotlin/de/darkatra/vrising/discord/clients/botcompanion/BotCompanionClient.kt @@ -55,7 +55,7 @@ class BotCompanionClient( return when (response.status) { HttpStatusCode.OK -> Result.success(objectMapper.readValue(response.bodyAsText(), jacksonTypeRef>())) - else -> Result.failure(BotCompanionClientException("Unexpected response status '${response.status.value}' during getCharacters request.")) + else -> Result.failure(BotCompanionClientException("Unexpected response status '${response.status.value}' during ${this::getCharacters.name} request.")) } } @@ -70,7 +70,7 @@ class BotCompanionClient( return when (response.status) { HttpStatusCode.OK -> Result.success(objectMapper.readValue(response.bodyAsText(), jacksonTypeRef>())) - else -> Result.failure(BotCompanionClientException("Unexpected response status '${response.status.value}' during getPlayerActivities request.")) + else -> Result.failure(BotCompanionClientException("Unexpected response status '${response.status.value}' during ${this::getPlayerActivities.name} request.")) } } @@ -85,7 +85,7 @@ class BotCompanionClient( return when (response.status) { HttpStatusCode.OK -> Result.success(objectMapper.readValue(response.bodyAsText(), jacksonTypeRef>())) - else -> Result.failure(BotCompanionClientException("Unexpected response status '${response.status.value}' during getPlayerActivities request.")) + else -> Result.failure(BotCompanionClientException("Unexpected response status '${response.status.value}' during ${this::getPvpKills.name} request.")) } } diff --git a/src/main/kotlin/de/darkatra/vrising/discord/persistence/ServerRepository.kt b/src/main/kotlin/de/darkatra/vrising/discord/persistence/ServerRepository.kt index dd5915c..1389a7e 100644 --- a/src/main/kotlin/de/darkatra/vrising/discord/persistence/ServerRepository.kt +++ b/src/main/kotlin/de/darkatra/vrising/discord/persistence/ServerRepository.kt @@ -27,14 +27,14 @@ class ServerRepository( fun updateServer(server: Server) { @Suppress("DEPRECATION") // this is the internal usage the warning is referring to - val newVersion = server.version + val serverVersion = server.version @Suppress("DEPRECATION") // this is the internal usage the warning is referring to val databaseVersion = (repository.find(Server::id eq server.id).firstOrNull() ?: throw OutdatedServerException("Server with id '${server.id}' not found.")) .version!! - if (newVersion == null || databaseVersion > newVersion) { + if (serverVersion == null || databaseVersion > serverVersion) { throw OutdatedServerException("Server with id '${server.id}' was already updated by another thread.") } diff --git a/src/test/kotlin/de/darkatra/vrising/discord/persistence/ServerRepositoryTest.kt b/src/test/kotlin/de/darkatra/vrising/discord/persistence/ServerRepositoryTest.kt index af94c35..55e83ad 100644 --- a/src/test/kotlin/de/darkatra/vrising/discord/persistence/ServerRepositoryTest.kt +++ b/src/test/kotlin/de/darkatra/vrising/discord/persistence/ServerRepositoryTest.kt @@ -28,15 +28,15 @@ class ServerRepositoryTest { ServerTestUtils.getServer() ) - val serverStatusMonitors = serverRepository.getServers() + val servers = serverRepository.getServers() - assertThat(serverStatusMonitors).hasSize(1) + assertThat(servers).hasSize(1) - val serverStatusMonitor = serverStatusMonitors.first() - assertThat(serverStatusMonitor.id).isEqualTo(ServerTestUtils.ID) - assertThat(serverStatusMonitor.discordServerId).isEqualTo(ServerTestUtils.DISCORD_SERVER_ID) - assertThat(serverStatusMonitor.hostname).isEqualTo(ServerTestUtils.HOST_NAME) - assertThat(serverStatusMonitor.queryPort).isEqualTo(ServerTestUtils.QUERY_PORT) + val server = servers.first() + assertThat(server.id).isEqualTo(ServerTestUtils.ID) + assertThat(server.discordServerId).isEqualTo(ServerTestUtils.DISCORD_SERVER_ID) + assertThat(server.hostname).isEqualTo(ServerTestUtils.HOST_NAME) + assertThat(server.queryPort).isEqualTo(ServerTestUtils.QUERY_PORT) } @Test @@ -86,13 +86,13 @@ class ServerRepositoryTest { @Test fun `should not update server status monitor with higher version`() { - val serverStatusMonitor = ServerTestUtils.getServer() - serverRepository.addServer(serverStatusMonitor) + val server = ServerTestUtils.getServer() + serverRepository.addServer(server) - val update1 = serverRepository.getServer(serverStatusMonitor.id, serverStatusMonitor.discordServerId)!!.apply { + val update1 = serverRepository.getServer(server.id, server.discordServerId)!!.apply { hostname = "test-1" } - val update2 = serverRepository.getServer(serverStatusMonitor.id, serverStatusMonitor.discordServerId)!!.apply { + val update2 = serverRepository.getServer(server.id, server.discordServerId)!!.apply { hostname = "test-2" } @@ -102,11 +102,11 @@ class ServerRepositoryTest { serverRepository.updateServer(update2) } - assertThat(e.message).isEqualTo("Server with id '${serverStatusMonitor.id}' was already updated by another thread.") + assertThat(e.message).isEqualTo("Server with id '${server.id}' was already updated by another thread.") } @Test - fun `should not insert server status monitor when using updateServerStatusMonitor`() { + fun `should not insert server status monitor when using updateServer`() { val e = assertThrows { serverRepository.updateServer(