add username test
Some checks are pending
ci / deploy (push) Waiting to run

This commit is contained in:
Lee 2024-04-09 03:40:08 +01:00
parent 5eecd82da0
commit 37b32c6400
3 changed files with 17 additions and 8 deletions

View File

@ -26,7 +26,8 @@ public class PlayerController {
this.playerManagerService = playerManagerService;
}
@GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody
@ResponseBody
@GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getPlayer(@PathVariable String id) {
Player player = playerManagerService.getPlayer(id);
if (player == null) { // No player with that id was found
@ -36,7 +37,6 @@ public class PlayerController {
return ResponseEntity.ok()
.cacheControl(cacheControl)
.body(player);
}
@GetMapping(value = "/{part}/{id}")

View File

@ -20,7 +20,7 @@ class PlayerControllerTests {
private MockMvc mockMvc;
@Test
public void ensurePlayerLookupSuccess() throws Exception {
public void ensurePlayerLookupUuidSuccess() throws Exception {
mockMvc.perform(get("/player/eeab5f8a-18dd-4d58-af78-2b3c4543da48")
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON))
@ -28,6 +28,15 @@ class PlayerControllerTests {
.andExpect(jsonPath("$.username").value("ImFascinated"));
}
@Test
public void ensurePlayerLookupUsernameSuccess() throws Exception {
mockMvc.perform(get("/player/ImFascinated")
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$.username").value("ImFascinated"));
}
@Test
public void ensurePlayerLookupFailure() throws Exception {
mockMvc.perform(get("/player/invalidnamehahahahahayesslmaooo")
@ -37,7 +46,7 @@ class PlayerControllerTests {
}
@Test
public void ensurePlayerPartsLookupSuccess() throws Exception {
public void ensurePlayerSkinPartsLookupSuccess() throws Exception {
for (Skin.Parts part : Skin.Parts.values()) {
mockMvc.perform(get("/player/" + part.getName() + "/eeab5f8a-18dd-4d58-af78-2b3c4543da48")
.accept(MediaType.IMAGE_PNG)
@ -46,9 +55,8 @@ class PlayerControllerTests {
}
}
@Test
public void ensurePlayerPartsLookupFailure() throws Exception {
public void ensurePlayerSkinPartsLookupFailure() throws Exception {
mockMvc.perform(get("/player/invalidpart/eeab5f8a-18dd-4d58-af78-2b3c4543da48"))
.andExpect(status().isNotFound());
}

View File

@ -15,11 +15,12 @@
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="flex flex-col h-screen mt-5 items-center bg-neutral-900 text-white text-center">
<p class="font-bold">Hello!!!</p>
<p class="font-bold">Hello!</p>
<p>Wrapper for the Minecraft APIs to make them easier to use.</p>
<a class="text-blue-600" target=”_blank” href="https://git.fascinated.cc/Fascinated/minecraft-helper">Source Code</a>
<div class="flex flex-col mt-3">
<p>Player Data: <a class="text-blue-600" th:href="${player_example_url}" th:text="${player_example_url}">???</a></p>
<p>Player Data: <a class="text-blue-600" target=”_blank” th:href="${player_example_url}" th:text="${player_example_url}">???</a></p>
</div>
</body>
</html>