2024-04-08 06:20:25 +00:00
|
|
|
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
|
|
|
|
class PlayerControllerTests {
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private MockMvc mockMvc;
|
|
|
|
|
|
|
|
@Test
|
2024-04-08 06:22:03 +00:00
|
|
|
public void ensurePlayerLookupSuccess() throws Exception {
|
2024-04-08 06:20:25 +00:00
|
|
|
mockMvc.perform(get("/player/eeab5f8a-18dd-4d58-af78-2b3c4543da48")
|
|
|
|
.accept(MediaType.APPLICATION_JSON)
|
|
|
|
.contentType(MediaType.APPLICATION_JSON))
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
.andExpect(jsonPath("$.username").value("ImFascinated"));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2024-04-08 06:22:03 +00:00
|
|
|
public void ensurePlayerLookupFailure() throws Exception {
|
|
|
|
mockMvc.perform(get("/player/invalidnamehahahahahayesslmaooo")
|
|
|
|
.accept(MediaType.APPLICATION_JSON)
|
|
|
|
.contentType(MediaType.APPLICATION_JSON))
|
|
|
|
.andExpect(status().isNotFound());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void ensurePlayerPartsLookupSuccess() throws Exception {
|
2024-04-08 06:20:25 +00:00
|
|
|
for (Skin.Parts part : Skin.Parts.values()) {
|
|
|
|
mockMvc.perform(get("/player/" + part.getName() + "/eeab5f8a-18dd-4d58-af78-2b3c4543da48")
|
|
|
|
.accept(MediaType.IMAGE_PNG)
|
|
|
|
.contentType(MediaType.IMAGE_PNG))
|
|
|
|
.andExpect(status().isOk());
|
|
|
|
}
|
|
|
|
}
|
2024-04-08 06:22:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void ensurePlayerPartsLookupFailure() throws Exception {
|
2024-04-08 06:40:22 +00:00
|
|
|
mockMvc.perform(get("/player/invalidpart/eeab5f8a-18dd-4d58-af78-2b3c4543da48"))
|
2024-04-08 06:22:03 +00:00
|
|
|
.andExpect(status().isNotFound());
|
|
|
|
}
|
2024-04-08 06:20:25 +00:00
|
|
|
}
|