From 03c679d25c218d09b151aeb81b408edbf6d89fde Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 18 Apr 2024 23:49:09 +0100 Subject: [PATCH] pls work part 2 --- .../xyz/mcutils/backend/config/MongoConfig.java | 15 ++++----------- .../mcutils/backend/service/MetricService.java | 1 - .../mcutils/backend/service/MojangService.java | 1 - .../mcutils/backend/service/PlayerService.java | 1 - .../mcutils/backend/service/ServerService.java | 1 - .../backend/test/tests/PlayerControllerTests.java | 2 -- .../backend/test/tests/ServerControllerTests.java | 2 -- 7 files changed, 4 insertions(+), 19 deletions(-) diff --git a/src/main/java/xyz/mcutils/backend/config/MongoConfig.java b/src/main/java/xyz/mcutils/backend/config/MongoConfig.java index c1e0d31..26e5ff2 100644 --- a/src/main/java/xyz/mcutils/backend/config/MongoConfig.java +++ b/src/main/java/xyz/mcutils/backend/config/MongoConfig.java @@ -1,22 +1,15 @@ package xyz.mcutils.backend.config; -import org.springframework.context.annotation.Bean; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; -import org.springframework.data.mongodb.MongoDatabaseFactory; -import org.springframework.data.mongodb.core.convert.DbRefResolver; -import org.springframework.data.mongodb.core.convert.DefaultDbRefResolver; import org.springframework.data.mongodb.core.convert.MappingMongoConverter; -import org.springframework.data.mongodb.core.mapping.MongoMappingContext; import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; @Configuration @EnableMongoRepositories(basePackages = "xyz.mcutils.backend.repository.mongo") public class MongoConfig { - @Bean - public MappingMongoConverter mongoConverter(MongoDatabaseFactory databaseFactory, MongoMappingContext mongoMappingContext) { - DbRefResolver dbRefResolver = new DefaultDbRefResolver(databaseFactory); - MappingMongoConverter mongoConverter = new MappingMongoConverter(dbRefResolver, mongoMappingContext); - mongoConverter.setMapKeyDotReplacement("-DOT"); - return mongoConverter; + @Autowired + void setMapKeyDotReplacement(MappingMongoConverter mappingMongoConverter) { + mappingMongoConverter.setMapKeyDotReplacement("-DOT"); } } diff --git a/src/main/java/xyz/mcutils/backend/service/MetricService.java b/src/main/java/xyz/mcutils/backend/service/MetricService.java index 923ae16..ab0fef3 100644 --- a/src/main/java/xyz/mcutils/backend/service/MetricService.java +++ b/src/main/java/xyz/mcutils/backend/service/MetricService.java @@ -8,7 +8,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import xyz.mcutils.backend.common.EnvironmentUtils; import xyz.mcutils.backend.common.Timer; -import xyz.mcutils.backend.config.Config; import xyz.mcutils.backend.repository.mongo.MetricsRepository; import xyz.mcutils.backend.service.metric.Metric; import xyz.mcutils.backend.service.metric.metrics.*; diff --git a/src/main/java/xyz/mcutils/backend/service/MojangService.java b/src/main/java/xyz/mcutils/backend/service/MojangService.java index cf7d931..6dba114 100644 --- a/src/main/java/xyz/mcutils/backend/service/MojangService.java +++ b/src/main/java/xyz/mcutils/backend/service/MojangService.java @@ -18,7 +18,6 @@ import xyz.mcutils.backend.common.Endpoint; import xyz.mcutils.backend.common.EnvironmentUtils; import xyz.mcutils.backend.common.ExpiringSet; import xyz.mcutils.backend.common.WebRequest; -import xyz.mcutils.backend.config.Config; import xyz.mcutils.backend.model.cache.CachedEndpointStatus; import xyz.mcutils.backend.model.mojang.EndpointStatus; import xyz.mcutils.backend.model.token.MojangProfileToken; diff --git a/src/main/java/xyz/mcutils/backend/service/PlayerService.java b/src/main/java/xyz/mcutils/backend/service/PlayerService.java index a6a8fca..b96f6a0 100644 --- a/src/main/java/xyz/mcutils/backend/service/PlayerService.java +++ b/src/main/java/xyz/mcutils/backend/service/PlayerService.java @@ -4,7 +4,6 @@ import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import xyz.mcutils.backend.common.*; -import xyz.mcutils.backend.config.Config; import xyz.mcutils.backend.exception.impl.BadRequestException; import xyz.mcutils.backend.exception.impl.MojangAPIRateLimitException; import xyz.mcutils.backend.exception.impl.RateLimitException; diff --git a/src/main/java/xyz/mcutils/backend/service/ServerService.java b/src/main/java/xyz/mcutils/backend/service/ServerService.java index 4dbe593..67ff7e7 100644 --- a/src/main/java/xyz/mcutils/backend/service/ServerService.java +++ b/src/main/java/xyz/mcutils/backend/service/ServerService.java @@ -6,7 +6,6 @@ import org.springframework.stereotype.Service; import xyz.mcutils.backend.common.DNSUtils; import xyz.mcutils.backend.common.EnumUtils; import xyz.mcutils.backend.common.EnvironmentUtils; -import xyz.mcutils.backend.config.Config; import xyz.mcutils.backend.exception.impl.BadRequestException; import xyz.mcutils.backend.exception.impl.ResourceNotFoundException; import xyz.mcutils.backend.model.cache.CachedMinecraftServer; diff --git a/src/test/java/xyz/mcutils/backend/test/tests/PlayerControllerTests.java b/src/test/java/xyz/mcutils/backend/test/tests/PlayerControllerTests.java index 67c1fb3..9915a7f 100644 --- a/src/test/java/xyz/mcutils/backend/test/tests/PlayerControllerTests.java +++ b/src/test/java/xyz/mcutils/backend/test/tests/PlayerControllerTests.java @@ -3,8 +3,6 @@ package xyz.mcutils.backend.test.tests; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.data.mongo.AutoConfigureDataMongo; -import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; diff --git a/src/test/java/xyz/mcutils/backend/test/tests/ServerControllerTests.java b/src/test/java/xyz/mcutils/backend/test/tests/ServerControllerTests.java index 909c839..6cb0376 100644 --- a/src/test/java/xyz/mcutils/backend/test/tests/ServerControllerTests.java +++ b/src/test/java/xyz/mcutils/backend/test/tests/ServerControllerTests.java @@ -3,8 +3,6 @@ package xyz.mcutils.backend.test.tests; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.data.mongo.AutoConfigureDataMongo; -import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType;