add ServerController tests

This commit is contained in:
Lee 2024-04-10 11:06:28 +01:00
parent 146cc30413
commit 78c3333038
6 changed files with 149 additions and 23 deletions

@ -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());
}
}

@ -1,3 +1,3 @@
artifactId=Minecraft-Helper artifactId=Minecraft-Utilities
groupId=cc.fascinated groupId=cc.fascinated
version=1.0-SNAPSHOT version=1.0.0

@ -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\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

@ -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\common\PlayerUtils.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\service\pinger\impl\JavaMinecraftServerPinger.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\cache\CachedPlayer.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\common\packet\MinecraftJavaPacket.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\service\MojangAPIService.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\controller\PlayerController.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\model\player\Player.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\log\TransactionLogger.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\common\ServerUtils.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\common\WebRequest.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\repository\PlayerNameCacheRepository.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\mojang\MojangUsernameToUuid.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\ServerService.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\config\RedisConfig.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\repository\PlayerCacheRepository.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\model\mojang\MojangProfile.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\repository\MinecraftServerCacheRepository.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\common\JavaMinecraftVersion.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\exception\impl\BadRequestException.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\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

@ -0,0 +1,2 @@
cc\fascinated\PlayerControllerTests.class
cc\fascinated\TestRedisConfig.class

@ -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 C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\test\java\cc\fascinated\PlayerControllerTests.java