package com.slprojects.democultureconceptsinfo; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.test.web.servlet.MockMvc; import java.util.UUID; 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; @WebMvcTest(PlayerController.class) public class PlayerControllerTest { @Autowired private MockMvc mockMvc; @Test public void testGetAllPlayers() throws Exception { mockMvc.perform(get("/players")) .andExpect(status().isOk()) .andExpect(jsonPath("$").isArray()) .andExpect(jsonPath("$[0].username").value("JohnDoe")); } @Test public void testGetPlayer() throws Exception { UUID uuid = PlayerService.firstFakePlayer.getUuid(); mockMvc.perform(get("/player").param("uuid", uuid.toString())) .andExpect(status().isOk()) .andExpect(jsonPath("$.username").value("JohnDoe")); } }