fix tests

This commit is contained in:
Lee 2024-04-18 13:55:02 +01:00
parent ce3067ee0e
commit 597c3850e3
5 changed files with 35 additions and 3 deletions

@ -170,6 +170,11 @@
<version>1.4.3</version> <version>1.4.3</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

@ -0,0 +1,21 @@
package xyz.mcutils.backend.config;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import lombok.NonNull;
import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest;
import org.springframework.boot.test.context.TestConfiguration;
import redis.embedded.RedisServer;
import java.io.IOException;
/**
* Test configuration for
* a mock Redis server.
*
* @author Braydon
*/
@TestConfiguration @DataMongoTest
public class TestMongoConfig {
}

@ -3,16 +3,18 @@ package xyz.mcutils.backend.tests;
import cc.fascinated.config.TestRedisConfig; import cc.fascinated.config.TestRedisConfig;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
import xyz.mcutils.backend.config.TestMongoConfig;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@AutoConfigureMockMvc @AutoConfigureMockMvc
@SpringBootTest(classes = TestRedisConfig.class) @SpringBootTest(classes = {TestRedisConfig.class, TestMongoConfig.class})
class MojangControllerTests { class MojangControllerTests {
@Autowired @Autowired

@ -3,10 +3,12 @@ package xyz.mcutils.backend.tests;
import cc.fascinated.config.TestRedisConfig; import cc.fascinated.config.TestRedisConfig;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
import xyz.mcutils.backend.config.TestMongoConfig;
import xyz.mcutils.backend.model.skin.ISkinPart; import xyz.mcutils.backend.model.skin.ISkinPart;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
@ -14,7 +16,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@AutoConfigureMockMvc @AutoConfigureMockMvc
@SpringBootTest(classes = TestRedisConfig.class) @SpringBootTest(classes = {TestRedisConfig.class, TestMongoConfig.class})
class PlayerControllerTests { class PlayerControllerTests {
private final String testPlayerUuid = "eeab5f8a-18dd-4d58-af78-2b3c4543da48"; private final String testPlayerUuid = "eeab5f8a-18dd-4d58-af78-2b3c4543da48";

@ -3,17 +3,19 @@ package xyz.mcutils.backend.tests;
import cc.fascinated.config.TestRedisConfig; import cc.fascinated.config.TestRedisConfig;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
import xyz.mcutils.backend.config.TestMongoConfig;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; 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.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@AutoConfigureMockMvc @AutoConfigureMockMvc
@SpringBootTest(classes = TestRedisConfig.class) @SpringBootTest(classes = {TestRedisConfig.class, TestMongoConfig.class})
class ServerControllerTests { class ServerControllerTests {
private final String testServer = "play.hypixel.net"; private final String testServer = "play.hypixel.net";