forked from MinecraftUtilities/Backend
add username test
This commit is contained in:
parent
5eecd82da0
commit
37b32c6400
@ -26,7 +26,8 @@ public class PlayerController {
|
|||||||
this.playerManagerService = playerManagerService;
|
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) {
|
public ResponseEntity<?> getPlayer(@PathVariable String id) {
|
||||||
Player player = playerManagerService.getPlayer(id);
|
Player player = playerManagerService.getPlayer(id);
|
||||||
if (player == null) { // No player with that id was found
|
if (player == null) { // No player with that id was found
|
||||||
@ -36,7 +37,6 @@ public class PlayerController {
|
|||||||
return ResponseEntity.ok()
|
return ResponseEntity.ok()
|
||||||
.cacheControl(cacheControl)
|
.cacheControl(cacheControl)
|
||||||
.body(player);
|
.body(player);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(value = "/{part}/{id}")
|
@GetMapping(value = "/{part}/{id}")
|
||||||
|
@ -20,7 +20,7 @@ class PlayerControllerTests {
|
|||||||
private MockMvc mockMvc;
|
private MockMvc mockMvc;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void ensurePlayerLookupSuccess() throws Exception {
|
public void ensurePlayerLookupUuidSuccess() throws Exception {
|
||||||
mockMvc.perform(get("/player/eeab5f8a-18dd-4d58-af78-2b3c4543da48")
|
mockMvc.perform(get("/player/eeab5f8a-18dd-4d58-af78-2b3c4543da48")
|
||||||
.accept(MediaType.APPLICATION_JSON)
|
.accept(MediaType.APPLICATION_JSON)
|
||||||
.contentType(MediaType.APPLICATION_JSON))
|
.contentType(MediaType.APPLICATION_JSON))
|
||||||
@ -28,6 +28,15 @@ class PlayerControllerTests {
|
|||||||
.andExpect(jsonPath("$.username").value("ImFascinated"));
|
.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
|
@Test
|
||||||
public void ensurePlayerLookupFailure() throws Exception {
|
public void ensurePlayerLookupFailure() throws Exception {
|
||||||
mockMvc.perform(get("/player/invalidnamehahahahahayesslmaooo")
|
mockMvc.perform(get("/player/invalidnamehahahahahayesslmaooo")
|
||||||
@ -37,7 +46,7 @@ class PlayerControllerTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void ensurePlayerPartsLookupSuccess() throws Exception {
|
public void ensurePlayerSkinPartsLookupSuccess() throws Exception {
|
||||||
for (Skin.Parts part : Skin.Parts.values()) {
|
for (Skin.Parts part : Skin.Parts.values()) {
|
||||||
mockMvc.perform(get("/player/" + part.getName() + "/eeab5f8a-18dd-4d58-af78-2b3c4543da48")
|
mockMvc.perform(get("/player/" + part.getName() + "/eeab5f8a-18dd-4d58-af78-2b3c4543da48")
|
||||||
.accept(MediaType.IMAGE_PNG)
|
.accept(MediaType.IMAGE_PNG)
|
||||||
@ -46,9 +55,8 @@ class PlayerControllerTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void ensurePlayerPartsLookupFailure() throws Exception {
|
public void ensurePlayerSkinPartsLookupFailure() throws Exception {
|
||||||
mockMvc.perform(get("/player/invalidpart/eeab5f8a-18dd-4d58-af78-2b3c4543da48"))
|
mockMvc.perform(get("/player/invalidpart/eeab5f8a-18dd-4d58-af78-2b3c4543da48"))
|
||||||
.andExpect(status().isNotFound());
|
.andExpect(status().isNotFound());
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,12 @@
|
|||||||
<script src="https://cdn.tailwindcss.com"></script>
|
<script src="https://cdn.tailwindcss.com"></script>
|
||||||
</head>
|
</head>
|
||||||
<body class="flex flex-col h-screen mt-5 items-center bg-neutral-900 text-white text-center">
|
<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>
|
<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">
|
<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>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
Reference in New Issue
Block a user