From 78c33330389407834ce915d516fdd0395d0bc6c2 Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 10 Apr 2024 11:06:28 +0100 Subject: [PATCH] add ServerController tests --- .../cc/fascinated/ServerControllerTests.java | 45 +++++++++++++ target/maven-archiver/pom.properties | 4 +- .../compile/default-compile/createdFiles.lst | 54 ++++++++++++++- .../compile/default-compile/inputFiles.lst | 66 +++++++++++++------ .../default-testCompile/createdFiles.lst | 2 + .../default-testCompile/inputFiles.lst | 1 + 6 files changed, 149 insertions(+), 23 deletions(-) create mode 100644 src/test/java/cc/fascinated/ServerControllerTests.java diff --git a/src/test/java/cc/fascinated/ServerControllerTests.java b/src/test/java/cc/fascinated/ServerControllerTests.java new file mode 100644 index 0000000..05e310f --- /dev/null +++ b/src/test/java/cc/fascinated/ServerControllerTests.java @@ -0,0 +1,45 @@ +package cc.fascinated; + +import cc.fascinated.model.player.Skin; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.MockMvc; + +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@AutoConfigureMockMvc +@SpringBootTest(classes = TestRedisConfig.class) +class ServerControllerTests { + + @Autowired + private MockMvc mockMvc; + + @Test + public void ensureServerLookupSuccess() throws Exception { + mockMvc.perform(get("/server/java/play.hypixel.net") + .accept(MediaType.APPLICATION_JSON) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.server.hostname").value("play.hypixel.net")); + } + + @Test + public void ensureServerLookupFailure() throws Exception { + mockMvc.perform(get("/server/java/invalidhostnamehahahahahayesslmaooo") + .accept(MediaType.APPLICATION_JSON) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isBadRequest()); + } + + @Test + public void ensureServerIconLookupSuccess() throws Exception { + mockMvc.perform(get("/server/icon/play.hypixel.net") + .contentType(MediaType.IMAGE_PNG)) + .andExpect(status().isOk()); + } +} diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties index af29734..7bf4386 100644 --- a/target/maven-archiver/pom.properties +++ b/target/maven-archiver/pom.properties @@ -1,3 +1,3 @@ -artifactId=Minecraft-Helper +artifactId=Minecraft-Utilities groupId=cc.fascinated -version=1.0-SNAPSHOT +version=1.0.0 diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst index 5b19640..fea4c8e 100644 --- a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -1,2 +1,54 @@ +cc\fascinated\service\pinger\impl\JavaMinecraftServerPinger.class +cc\fascinated\service\pinger\MinecraftServerPinger.class +cc\fascinated\config\OpenAPIConfiguration.class +cc\fascinated\model\server\JavaMinecraftServer$Players.class +cc\fascinated\model\player\Cape.class +cc\fascinated\service\MojangAPIService.class +cc\fascinated\controller\PlayerController.class +cc\fascinated\common\JavaMinecraftVersion.class +cc\fascinated\model\mojang\JavaServerStatusToken.class +cc\fascinated\model\player\Skin$Parts.class +cc\fascinated\log\TransactionLogger.class +cc\fascinated\common\WebRequest.class +cc\fascinated\exception\impl\ResourceNotFoundException.class +cc\fascinated\model\server\MinecraftServer$Platform.class +cc\fascinated\model\mojang\MojangUsernameToUuid.class +cc\fascinated\model\player\Skin$Model.class +cc\fascinated\model\response\ErrorResponse.class +cc\fascinated\exception\ExceptionControllerAdvice.class +cc\fascinated\controller\HomeController.class +cc\fascinated\model\server\MinecraftServer.class +cc\fascinated\exception\impl\RateLimitException.class +cc\fascinated\model\server\JavaMinecraftServer$Version.class +cc\fascinated\model\server\MinecraftServer$MOTD.class +cc\fascinated\common\packet\MinecraftJavaPacket.class +cc\fascinated\repository\MinecraftServerCacheRepository.class +cc\fascinated\common\IPUtils.class +cc\fascinated\exception\impl\BadRequestException.class +cc\fascinated\common\UUIDUtils.class +cc\fascinated\model\mojang\MojangProfile$ProfileProperty.class +cc\fascinated\common\packet\impl\java\JavaPacketHandshakingInSetProtocol.class +cc\fascinated\model\cache\CachedPlayer.class +cc\fascinated\common\packet\impl\java\JavaPacketStatusInStart.class +cc\fascinated\common\PlayerUtils.class cc\fascinated\Main.class -cc\fascinated\util\UUIDUtils.class +cc\fascinated\common\Tuple.class +cc\fascinated\controller\ServerController.class +cc\fascinated\model\server\JavaMinecraftServer$Favicon.class +cc\fascinated\common\ServerUtils.class +cc\fascinated\model\cache\CachedMinecraftServer.class +cc\fascinated\repository\PlayerNameCacheRepository.class +cc\fascinated\common\ColorUtils.class +cc\fascinated\config\RedisConfig.class +cc\fascinated\model\mojang\MojangProfile.class +cc\fascinated\model\server\JavaMinecraftServer.class +cc\fascinated\exception\impl\MojangAPIRateLimitException.class +cc\fascinated\model\player\Skin.class +cc\fascinated\model\player\Player.class +cc\fascinated\common\DNSUtils.class +cc\fascinated\service\PlayerService.class +cc\fascinated\config\Config.class +cc\fascinated\service\ServerService.class +cc\fascinated\common\EnumUtils.class +cc\fascinated\model\cache\CachedPlayerName.class +cc\fascinated\repository\PlayerCacheRepository.class diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst index bc0a2fd..3afc209 100644 --- a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -1,20 +1,46 @@ -C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\model\mojang\MojangUsernameToUuid.java -C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\service\PlayerService.java -C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\model\mojang\MojangProfile.java -C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\model\response\Response.java -C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\controller\HomeController.java -C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\model\player\Player.java -C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\log\TransactionLogger.java -C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\util\IPUtils.java -C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\config\Config.java -C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\controller\PlayerController.java -C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\exception\ExceptionControllerAdvice.java -C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\Main.java -C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\model\player\Cape.java -C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\service\MojangAPIService.java -C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\util\UUIDUtils.java -C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\model\player\Skin.java -C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\util\Tuple.java -C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\util\WebRequest.java -C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\model\response\impl\PlayerNotFoundResponse.java -C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\util\PlayerUtils.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\common\PlayerUtils.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\service\pinger\impl\JavaMinecraftServerPinger.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\model\cache\CachedPlayer.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\common\packet\MinecraftJavaPacket.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\service\MojangAPIService.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\controller\PlayerController.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\model\player\Player.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\log\TransactionLogger.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\common\ServerUtils.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\common\WebRequest.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\repository\PlayerNameCacheRepository.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\model\mojang\MojangUsernameToUuid.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\service\ServerService.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\config\RedisConfig.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\repository\PlayerCacheRepository.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\model\mojang\MojangProfile.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\repository\MinecraftServerCacheRepository.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\common\JavaMinecraftVersion.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\exception\impl\BadRequestException.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\model\server\MinecraftServer.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\common\packet\impl\java\JavaPacketStatusInStart.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\model\server\JavaMinecraftServer.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\model\player\Cape.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\common\Tuple.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\exception\impl\ResourceNotFoundException.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\common\ColorUtils.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\config\OpenAPIConfiguration.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\model\mojang\JavaServerStatusToken.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\common\packet\impl\java\JavaPacketHandshakingInSetProtocol.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\controller\HomeController.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\exception\ExceptionControllerAdvice.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\model\cache\CachedPlayerName.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\service\pinger\MinecraftServerPinger.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\common\EnumUtils.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\config\Config.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\exception\impl\MojangAPIRateLimitException.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\exception\impl\RateLimitException.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\model\response\ErrorResponse.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\controller\ServerController.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\Main.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\common\DNSUtils.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\service\PlayerService.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\common\IPUtils.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\model\cache\CachedMinecraftServer.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\model\player\Skin.java +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc.fascinated\common\UUIDUtils.java diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst index e69de29..e7cdb26 100644 --- a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst +++ b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst @@ -0,0 +1,2 @@ +cc\fascinated\PlayerControllerTests.class +cc\fascinated\TestRedisConfig.class diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst index b6f1615..d1bf3cb 100644 --- a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst +++ b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst @@ -1 +1,2 @@ +C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\test\java\cc\fascinated\TestRedisConfig.java C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\test\java\cc\fascinated\PlayerControllerTests.java