rename the package

This commit is contained in:
Lee
2024-04-13 20:53:31 +01:00
parent a15326a847
commit 88c940431b
72 changed files with 203 additions and 203 deletions

View File

@ -0,0 +1,28 @@
package xyz.mcutils.backend.tests;
import cc.fascinated.config.TestRedisConfig;
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.status;
@AutoConfigureMockMvc
@SpringBootTest(classes = TestRedisConfig.class)
class MojangControllerTests {
@Autowired
private MockMvc mockMvc;
@Test
public void ensureEndpointStatusLookupSuccess() throws Exception {
mockMvc.perform(get("/mojang/status")
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk());
}
}

View File

@ -0,0 +1,89 @@
package xyz.mcutils.backend.tests;
import cc.fascinated.config.TestRedisConfig;
import cc.fascinated.model.skin.ISkinPart;
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 PlayerControllerTests {
private final String testPlayerUuid = "eeab5f8a-18dd-4d58-af78-2b3c4543da48";
private final String testPlayer = "ImFascinated";
private final String testInvalidPlayer = "invalidplayeromgyeswow";
@Autowired
private MockMvc mockMvc;
@Test
public void ensurePlayerLookupUuidSuccess() throws Exception {
mockMvc.perform(get("/player/" + testPlayerUuid)
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$.player.username").value(testPlayer));
}
@Test
public void ensurePlayerLookupUsernameSuccess() throws Exception {
mockMvc.perform(get("/player/" + testPlayer)
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$.player.username").value(testPlayer));
}
@Test
public void ensurePlayerUsernameToUuidLookupSuccess() throws Exception {
mockMvc.perform(get("/player/uuid/" + testPlayer)
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$.username").value(testPlayer))
.andExpect(jsonPath("$.uniqueId").value(testPlayerUuid));
}
@Test
public void ensurePlayerUsernameToUuidLookupFailure() throws Exception {
mockMvc.perform(get("/player/uuid/" + testInvalidPlayer)
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isNotFound());
}
@Test
public void ensurePlayerLookupFailure() throws Exception {
mockMvc.perform(get("/player/" + testInvalidPlayer)
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isNotFound());
}
@Test
public void ensurePlayerSkinPartsLookupSuccess() throws Exception {
for (Enum<?>[] type : ISkinPart.TYPES) {
for (Enum<?> part : type) {
mockMvc.perform(get("/player/" + part.name().toLowerCase() + "/" + testPlayer)
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk());
}
}
}
@Test
public void ensurePlayerSkinPartsLookupFailure() throws Exception {
mockMvc.perform(get("/player/invalidpart/" + testPlayer))
.andExpect(status().isBadRequest());
}
}

View File

@ -0,0 +1,57 @@
package xyz.mcutils.backend.tests;
import cc.fascinated.config.TestRedisConfig;
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 {
private final String testServer = "play.hypixel.net";
private final String testInvalidServer = "invalidhostnamehahahahahayesslmaooo";
@Autowired
private MockMvc mockMvc;
@Test
public void ensureServerLookupSuccess() throws Exception {
mockMvc.perform(get("/server/java/" + testServer)
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$.server.hostname").value(testServer));
}
@Test
public void ensureServerLookupFailure() throws Exception {
mockMvc.perform(get("/server/java/" + testInvalidServer)
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isBadRequest());
}
@Test
public void ensureServerIconLookupSuccess() throws Exception {
mockMvc.perform(get("/server/icon/" + testServer)
.contentType(MediaType.IMAGE_PNG))
.andExpect(status().isOk());
}
@Test
public void ensureBlockedServerLookupSuccess() throws Exception {
mockMvc.perform(get("/server/blocked/" + testServer)
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$.blocked").value(false));
}
}