diff --git a/backend/src/main/java/com/now/naaga/auth/application/AuthService.java b/backend/src/main/java/com/now/naaga/auth/application/AuthService.java index 4fd9c15f7..e32c7ccab 100644 --- a/backend/src/main/java/com/now/naaga/auth/application/AuthService.java +++ b/backend/src/main/java/com/now/naaga/auth/application/AuthService.java @@ -1,17 +1,19 @@ package com.now.naaga.auth.application; +import static com.now.naaga.auth.exception.AuthExceptionType.INVALID_TOKEN; + import com.now.naaga.auth.application.dto.AuthCommand; -import com.now.naaga.auth.infrastructure.dto.AuthInfo; import com.now.naaga.auth.application.dto.RefreshTokenCommand; import com.now.naaga.auth.domain.AuthToken; import com.now.naaga.auth.exception.AuthException; import com.now.naaga.auth.infrastructure.AuthClient; +import com.now.naaga.auth.infrastructure.dto.AuthInfo; import com.now.naaga.auth.infrastructure.dto.MemberAuth; import com.now.naaga.auth.infrastructure.jwt.AuthTokenGenerator; import com.now.naaga.auth.persistence.AuthRepository; +import com.now.naaga.member.application.MemberService; import com.now.naaga.member.application.dto.CreateMemberCommand; import com.now.naaga.member.application.dto.DeleteMemberCommand; -import com.now.naaga.member.application.MemberService; import com.now.naaga.member.domain.Member; import com.now.naaga.player.application.PlayerService; import com.now.naaga.player.application.dto.CreatePlayerCommand; @@ -19,8 +21,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import static com.now.naaga.auth.exception.AuthExceptionType.INVALID_TOKEN; - @Transactional @Service public class AuthService { diff --git a/backend/src/main/java/com/now/naaga/auth/domain/AuthToken.java b/backend/src/main/java/com/now/naaga/auth/domain/AuthToken.java index 90b4bf306..58d9c0cca 100644 --- a/backend/src/main/java/com/now/naaga/auth/domain/AuthToken.java +++ b/backend/src/main/java/com/now/naaga/auth/domain/AuthToken.java @@ -1,8 +1,12 @@ package com.now.naaga.auth.domain; import com.now.naaga.member.domain.Member; -import jakarta.persistence.*; - +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import java.util.Objects; @Entity diff --git a/backend/src/main/java/com/now/naaga/auth/infrastructure/AuthClient.java b/backend/src/main/java/com/now/naaga/auth/infrastructure/AuthClient.java index 593b2ecde..1395b99cd 100644 --- a/backend/src/main/java/com/now/naaga/auth/infrastructure/AuthClient.java +++ b/backend/src/main/java/com/now/naaga/auth/infrastructure/AuthClient.java @@ -1,8 +1,8 @@ package com.now.naaga.auth.infrastructure; -import com.now.naaga.auth.infrastructure.dto.AuthInfo; import com.now.naaga.auth.exception.AuthException; import com.now.naaga.auth.exception.AuthExceptionType; +import com.now.naaga.auth.infrastructure.dto.AuthInfo; import com.now.naaga.auth.infrastructure.dto.LogoutInfo; import com.now.naaga.auth.infrastructure.dto.UnlinkInfo; import org.springframework.beans.factory.annotation.Value; diff --git a/backend/src/main/java/com/now/naaga/auth/infrastructure/BearerAuthExtractor.java b/backend/src/main/java/com/now/naaga/auth/infrastructure/BearerAuthExtractor.java index 84cee103f..4f067c548 100644 --- a/backend/src/main/java/com/now/naaga/auth/infrastructure/BearerAuthExtractor.java +++ b/backend/src/main/java/com/now/naaga/auth/infrastructure/BearerAuthExtractor.java @@ -1,13 +1,15 @@ package com.now.naaga.auth.infrastructure; +import static com.now.naaga.auth.exception.AuthExceptionType.INVALID_HEADER; +import static com.now.naaga.auth.exception.AuthExceptionType.INVALID_TOKEN; +import static com.now.naaga.auth.exception.AuthExceptionType.NOT_EXIST_HEADER; + +import com.now.naaga.auth.exception.AuthException; import com.now.naaga.auth.infrastructure.dto.MemberAuth; import com.now.naaga.auth.infrastructure.jwt.JwtProvider; -import com.now.naaga.auth.exception.AuthException; import com.now.naaga.common.exception.InternalException; import org.springframework.stereotype.Component; -import static com.now.naaga.auth.exception.AuthExceptionType.*; - @Component public class BearerAuthExtractor implements AuthenticationExtractor { diff --git a/backend/src/main/java/com/now/naaga/auth/infrastructure/MemberAuthMapper.java b/backend/src/main/java/com/now/naaga/auth/infrastructure/MemberAuthMapper.java index 20765365d..7430af987 100644 --- a/backend/src/main/java/com/now/naaga/auth/infrastructure/MemberAuthMapper.java +++ b/backend/src/main/java/com/now/naaga/auth/infrastructure/MemberAuthMapper.java @@ -1,13 +1,13 @@ package com.now.naaga.auth.infrastructure; +import static com.now.naaga.common.exception.InternalExceptionType.FAIL_JSON_TO_OBJECT; +import static com.now.naaga.common.exception.InternalExceptionType.FAIL_OBJECT_TO_JSON; + import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.now.naaga.auth.infrastructure.dto.MemberAuth; import com.now.naaga.common.exception.InternalException; -import static com.now.naaga.common.exception.InternalExceptionType.FAIL_JSON_TO_OBJECT; -import static com.now.naaga.common.exception.InternalExceptionType.FAIL_OBJECT_TO_JSON; - public class MemberAuthMapper { private static final ObjectMapper objectMapper = new ObjectMapper(); diff --git a/backend/src/main/java/com/now/naaga/auth/infrastructure/dto/AuthInfo.java b/backend/src/main/java/com/now/naaga/auth/infrastructure/dto/AuthInfo.java index 0e4d2bd1d..ecf815eb1 100644 --- a/backend/src/main/java/com/now/naaga/auth/infrastructure/dto/AuthInfo.java +++ b/backend/src/main/java/com/now/naaga/auth/infrastructure/dto/AuthInfo.java @@ -2,7 +2,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; - import java.util.Objects; public class AuthInfo { diff --git a/backend/src/main/java/com/now/naaga/auth/infrastructure/dto/MemberAuth.java b/backend/src/main/java/com/now/naaga/auth/infrastructure/dto/MemberAuth.java index fdb4eb29c..74ccd1bf6 100644 --- a/backend/src/main/java/com/now/naaga/auth/infrastructure/dto/MemberAuth.java +++ b/backend/src/main/java/com/now/naaga/auth/infrastructure/dto/MemberAuth.java @@ -1,7 +1,6 @@ package com.now.naaga.auth.infrastructure.dto; import com.now.naaga.auth.infrastructure.AuthType; - import java.util.Objects; public class MemberAuth { diff --git a/backend/src/main/java/com/now/naaga/auth/infrastructure/jwt/AuthTokenGenerator.java b/backend/src/main/java/com/now/naaga/auth/infrastructure/jwt/AuthTokenGenerator.java index bdd8f1775..acc7c957d 100644 --- a/backend/src/main/java/com/now/naaga/auth/infrastructure/jwt/AuthTokenGenerator.java +++ b/backend/src/main/java/com/now/naaga/auth/infrastructure/jwt/AuthTokenGenerator.java @@ -1,21 +1,15 @@ package com.now.naaga.auth.infrastructure.jwt; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; +import static com.now.naaga.auth.exception.AuthExceptionType.INVALID_TOKEN_ACCESS; + import com.now.naaga.auth.domain.AuthToken; import com.now.naaga.auth.exception.AuthException; import com.now.naaga.auth.infrastructure.AuthType; import com.now.naaga.auth.infrastructure.MemberAuthMapper; import com.now.naaga.auth.infrastructure.dto.MemberAuth; -import com.now.naaga.common.exception.InternalException; -import com.now.naaga.common.exception.InternalExceptionType; import com.now.naaga.member.domain.Member; -import org.springframework.stereotype.Component; -import org.springframework.validation.ObjectError; - import java.util.Date; - -import static com.now.naaga.auth.exception.AuthExceptionType.INVALID_TOKEN_ACCESS; +import org.springframework.stereotype.Component; @Component public class AuthTokenGenerator { diff --git a/backend/src/main/java/com/now/naaga/auth/infrastructure/jwt/JwtProvider.java b/backend/src/main/java/com/now/naaga/auth/infrastructure/jwt/JwtProvider.java index b3d5c6966..175a38125 100644 --- a/backend/src/main/java/com/now/naaga/auth/infrastructure/jwt/JwtProvider.java +++ b/backend/src/main/java/com/now/naaga/auth/infrastructure/jwt/JwtProvider.java @@ -2,14 +2,16 @@ import com.now.naaga.auth.exception.AuthException; import com.now.naaga.auth.exception.AuthExceptionType; -import io.jsonwebtoken.*; +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.ExpiredJwtException; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; import io.jsonwebtoken.io.Decoders; import io.jsonwebtoken.security.Keys; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - import java.security.Key; import java.util.Date; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; @Component public class JwtProvider { diff --git a/backend/src/main/java/com/now/naaga/auth/persistence/AuthRepository.java b/backend/src/main/java/com/now/naaga/auth/persistence/AuthRepository.java index f7c5d6c1b..7be0b62f1 100644 --- a/backend/src/main/java/com/now/naaga/auth/persistence/AuthRepository.java +++ b/backend/src/main/java/com/now/naaga/auth/persistence/AuthRepository.java @@ -1,10 +1,8 @@ package com.now.naaga.auth.persistence; import com.now.naaga.auth.domain.AuthToken; -import org.springframework.data.jpa.repository.JpaRepository; - -import java.util.List; import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; public interface AuthRepository extends JpaRepository { diff --git a/backend/src/main/java/com/now/naaga/auth/presentation/AuthController.java b/backend/src/main/java/com/now/naaga/auth/presentation/AuthController.java index 59dca8d07..b13e39511 100644 --- a/backend/src/main/java/com/now/naaga/auth/presentation/AuthController.java +++ b/backend/src/main/java/com/now/naaga/auth/presentation/AuthController.java @@ -1,17 +1,21 @@ package com.now.naaga.auth.presentation; -import com.now.naaga.auth.presentation.annotation.Auth; import com.now.naaga.auth.application.AuthService; import com.now.naaga.auth.application.dto.AuthCommand; import com.now.naaga.auth.application.dto.RefreshTokenCommand; import com.now.naaga.auth.domain.AuthToken; import com.now.naaga.auth.infrastructure.dto.MemberAuth; +import com.now.naaga.auth.presentation.annotation.Auth; import com.now.naaga.auth.presentation.dto.AuthRequest; import com.now.naaga.auth.presentation.dto.AuthResponse; import com.now.naaga.auth.presentation.dto.RefreshTokenRequest; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; @RequestMapping("/auth") @RestController diff --git a/backend/src/main/java/com/now/naaga/auth/presentation/argumentresolver/MemberAuthArgumentResolver.java b/backend/src/main/java/com/now/naaga/auth/presentation/argumentresolver/MemberAuthArgumentResolver.java index f41a9abd1..068a8eca2 100644 --- a/backend/src/main/java/com/now/naaga/auth/presentation/argumentresolver/MemberAuthArgumentResolver.java +++ b/backend/src/main/java/com/now/naaga/auth/presentation/argumentresolver/MemberAuthArgumentResolver.java @@ -1,9 +1,8 @@ package com.now.naaga.auth.presentation.argumentresolver; -import com.now.naaga.auth.presentation.annotation.Auth; import com.now.naaga.auth.infrastructure.AuthenticationExtractor; import com.now.naaga.auth.infrastructure.dto.MemberAuth; -import com.now.naaga.auth.presentation.dto.MemberRequest; +import com.now.naaga.auth.presentation.annotation.Auth; import jakarta.servlet.http.HttpServletRequest; import org.springframework.core.MethodParameter; import org.springframework.http.HttpHeaders; diff --git a/backend/src/main/java/com/now/naaga/auth/presentation/argumentresolver/PlayerArgumentResolver.java b/backend/src/main/java/com/now/naaga/auth/presentation/argumentresolver/PlayerArgumentResolver.java index 110492546..4353aefcf 100644 --- a/backend/src/main/java/com/now/naaga/auth/presentation/argumentresolver/PlayerArgumentResolver.java +++ b/backend/src/main/java/com/now/naaga/auth/presentation/argumentresolver/PlayerArgumentResolver.java @@ -1,8 +1,8 @@ package com.now.naaga.auth.presentation.argumentresolver; -import com.now.naaga.auth.presentation.annotation.Auth; import com.now.naaga.auth.infrastructure.AuthenticationExtractor; import com.now.naaga.auth.infrastructure.dto.MemberAuth; +import com.now.naaga.auth.presentation.annotation.Auth; import com.now.naaga.player.application.PlayerService; import com.now.naaga.player.domain.Player; import com.now.naaga.player.presentation.dto.PlayerRequest; diff --git a/backend/src/main/java/com/now/naaga/auth/presentation/interceptor/AuthInterceptor.java b/backend/src/main/java/com/now/naaga/auth/presentation/interceptor/AuthInterceptor.java index 54cc716dd..6966a5a7c 100644 --- a/backend/src/main/java/com/now/naaga/auth/presentation/interceptor/AuthInterceptor.java +++ b/backend/src/main/java/com/now/naaga/auth/presentation/interceptor/AuthInterceptor.java @@ -2,7 +2,6 @@ import com.now.naaga.auth.infrastructure.AuthenticationExtractor; import com.now.naaga.auth.infrastructure.dto.MemberAuth; -import com.now.naaga.member.domain.Member; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import org.springframework.http.HttpHeaders; diff --git a/backend/src/main/java/com/now/naaga/auth/presentation/interceptor/ManagerAuthInterceptor.java b/backend/src/main/java/com/now/naaga/auth/presentation/interceptor/ManagerAuthInterceptor.java index 62ffb63c4..85e20f591 100644 --- a/backend/src/main/java/com/now/naaga/auth/presentation/interceptor/ManagerAuthInterceptor.java +++ b/backend/src/main/java/com/now/naaga/auth/presentation/interceptor/ManagerAuthInterceptor.java @@ -1,19 +1,20 @@ package com.now.naaga.auth.presentation.interceptor; +import static com.now.naaga.auth.exception.AuthExceptionType.INVALID_HEADER; +import static com.now.naaga.auth.exception.AuthExceptionType.INVALID_MANAGER; +import static com.now.naaga.auth.exception.AuthExceptionType.NOT_EXIST_HEADER; + import com.now.naaga.auth.exception.AuthException; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpHeaders; -import org.springframework.stereotype.Component; -import org.springframework.web.servlet.HandlerInterceptor; - import java.util.Arrays; import java.util.Base64; import java.util.List; import java.util.Objects; - -import static com.now.naaga.auth.exception.AuthExceptionType.*; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpHeaders; +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.HandlerInterceptor; @Component public class ManagerAuthInterceptor implements HandlerInterceptor { diff --git a/backend/src/main/java/com/now/naaga/common/config/BeanConfig.java b/backend/src/main/java/com/now/naaga/common/config/BeanConfig.java index d6ad7c4a4..93d23ad3f 100644 --- a/backend/src/main/java/com/now/naaga/common/config/BeanConfig.java +++ b/backend/src/main/java/com/now/naaga/common/config/BeanConfig.java @@ -5,12 +5,11 @@ import com.now.naaga.gameresult.domain.gamescore.ResultScoreCalculator; import com.now.naaga.gameresult.domain.gamescore.ResultScorePolicy; import com.now.naaga.gameresult.domain.gamescore.SuccessResultScorePolicy; +import java.util.List; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.client.RestTemplate; -import java.util.List; - @Configuration public class BeanConfig { diff --git a/backend/src/main/java/com/now/naaga/common/config/HibernateConfig.java b/backend/src/main/java/com/now/naaga/common/config/HibernateConfig.java index f84ef50e0..26af49c82 100644 --- a/backend/src/main/java/com/now/naaga/common/config/HibernateConfig.java +++ b/backend/src/main/java/com/now/naaga/common/config/HibernateConfig.java @@ -1,12 +1,12 @@ package com.now.naaga.common.config; +import static org.hibernate.cfg.AvailableSettings.STATEMENT_INSPECTOR; + import com.now.naaga.common.presentation.QueryInspector; import org.springframework.boot.autoconfigure.orm.jpa.HibernatePropertiesCustomizer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import static org.hibernate.cfg.AvailableSettings.STATEMENT_INSPECTOR; - @Configuration public class HibernateConfig { diff --git a/backend/src/main/java/com/now/naaga/common/infrastructure/MultipartFileManager.java b/backend/src/main/java/com/now/naaga/common/infrastructure/MultipartFileManager.java index 03dadefa9..0f20010ae 100644 --- a/backend/src/main/java/com/now/naaga/common/infrastructure/MultipartFileManager.java +++ b/backend/src/main/java/com/now/naaga/common/infrastructure/MultipartFileManager.java @@ -1,21 +1,19 @@ package com.now.naaga.common.infrastructure; +import static com.now.naaga.common.exception.CommonExceptionType.INVALID_REQUEST_BODY; +import static com.now.naaga.common.exception.InternalExceptionType.FAIL_MAKE_DIRECTORY; + import com.now.naaga.common.exception.CommonException; import com.now.naaga.common.exception.CommonExceptionType; +import com.now.naaga.common.exception.InternalException; import java.io.File; import java.io.IOException; import java.util.Objects; import java.util.UUID; - -import com.now.naaga.common.exception.InternalException; -import com.now.naaga.common.exception.InternalExceptionType; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import org.springframework.web.multipart.MultipartFile; -import static com.now.naaga.common.exception.CommonExceptionType.INVALID_REQUEST_BODY; -import static com.now.naaga.common.exception.InternalExceptionType.FAIL_MAKE_DIRECTORY; - @Component public class MultipartFileManager implements FileManager { diff --git a/backend/src/main/java/com/now/naaga/common/presentation/LogFilter.java b/backend/src/main/java/com/now/naaga/common/presentation/LogFilter.java index cad62bbd7..acc69107e 100644 --- a/backend/src/main/java/com/now/naaga/common/presentation/LogFilter.java +++ b/backend/src/main/java/com/now/naaga/common/presentation/LogFilter.java @@ -1,16 +1,19 @@ package com.now.naaga.common.presentation; -import jakarta.servlet.*; +import static com.now.naaga.common.presentation.MdcToken.REQUEST_ID; + +import jakarta.servlet.Filter; +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; import jakarta.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.UUID; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; -import java.io.IOException; -import java.util.UUID; - -import static com.now.naaga.common.presentation.MdcToken.*; - public class LogFilter implements Filter { private static final String LOG_FORMAT = "uri: {}, method: {}, time: {}ms, queryCount: {}"; diff --git a/backend/src/main/java/com/now/naaga/common/presentation/QueryInspector.java b/backend/src/main/java/com/now/naaga/common/presentation/QueryInspector.java index 51e67bba3..216ea91c8 100644 --- a/backend/src/main/java/com/now/naaga/common/presentation/QueryInspector.java +++ b/backend/src/main/java/com/now/naaga/common/presentation/QueryInspector.java @@ -1,13 +1,10 @@ package com.now.naaga.common.presentation; +import java.util.Objects; import org.hibernate.resource.jdbc.spi.StatementInspector; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import org.springframework.web.context.request.RequestContextHolder; -import java.util.Objects; - @Component public class QueryInspector implements StatementInspector { diff --git a/backend/src/main/java/com/now/naaga/common/presentation/interceptor/RequestMatcherInterceptor.java b/backend/src/main/java/com/now/naaga/common/presentation/interceptor/RequestMatcherInterceptor.java index f13c7f3da..ade990797 100644 --- a/backend/src/main/java/com/now/naaga/common/presentation/interceptor/RequestMatcherInterceptor.java +++ b/backend/src/main/java/com/now/naaga/common/presentation/interceptor/RequestMatcherInterceptor.java @@ -2,11 +2,10 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.springframework.http.HttpMethod; -import org.springframework.web.servlet.HandlerInterceptor; - import java.util.ArrayList; import java.util.List; +import org.springframework.http.HttpMethod; +import org.springframework.web.servlet.HandlerInterceptor; public class RequestMatcherInterceptor implements HandlerInterceptor { diff --git a/backend/src/main/java/com/now/naaga/game/application/GameService.java b/backend/src/main/java/com/now/naaga/game/application/GameService.java index 509bce1c9..d2c4bc3ad 100644 --- a/backend/src/main/java/com/now/naaga/game/application/GameService.java +++ b/backend/src/main/java/com/now/naaga/game/application/GameService.java @@ -1,6 +1,19 @@ package com.now.naaga.game.application; -import com.now.naaga.game.application.dto.*; +import static com.now.naaga.game.domain.GameStatus.IN_PROGRESS; +import static com.now.naaga.game.exception.GameExceptionType.ALREADY_IN_PROGRESS; +import static com.now.naaga.game.exception.GameExceptionType.CAN_NOT_FIND_PLACE; +import static com.now.naaga.game.exception.GameExceptionType.NOT_EXIST; +import static com.now.naaga.game.exception.GameExceptionType.NOT_EXIST_IN_PROGRESS; +import static com.now.naaga.gameresult.exception.GameResultExceptionType.GAME_RESULT_NOT_EXIST; + +import com.now.naaga.game.application.dto.CreateGameCommand; +import com.now.naaga.game.application.dto.CreateGameResultCommand; +import com.now.naaga.game.application.dto.EndGameCommand; +import com.now.naaga.game.application.dto.FindAllGamesCommand; +import com.now.naaga.game.application.dto.FindGameByIdCommand; +import com.now.naaga.game.application.dto.FindGameByStatusCommand; +import com.now.naaga.game.application.dto.FindGameInProgressCommand; import com.now.naaga.game.domain.EndType; import com.now.naaga.game.domain.Game; import com.now.naaga.game.domain.GameRecord; @@ -19,15 +32,10 @@ import com.now.naaga.player.application.PlayerService; import com.now.naaga.player.domain.Player; import com.now.naaga.player.presentation.dto.PlayerRequest; +import java.util.List; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.List; - -import static com.now.naaga.game.domain.GameStatus.IN_PROGRESS; -import static com.now.naaga.game.exception.GameExceptionType.*; -import static com.now.naaga.gameresult.exception.GameResultExceptionType.GAME_RESULT_NOT_EXIST; - @Transactional @Service public class GameService { diff --git a/backend/src/main/java/com/now/naaga/game/application/HintService.java b/backend/src/main/java/com/now/naaga/game/application/HintService.java index cedb687c9..b4e74cc6d 100644 --- a/backend/src/main/java/com/now/naaga/game/application/HintService.java +++ b/backend/src/main/java/com/now/naaga/game/application/HintService.java @@ -1,5 +1,8 @@ package com.now.naaga.game.application; +import static com.now.naaga.game.exception.GameExceptionType.HINTS_EXHAUSTED; +import static com.now.naaga.game.exception.GameExceptionType.HINT_NOT_EXIST_IN_GAME; + import com.now.naaga.game.application.dto.CreateHintCommand; import com.now.naaga.game.application.dto.FindGameByIdCommand; import com.now.naaga.game.application.dto.FindHintByIdCommand; @@ -13,9 +16,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import static com.now.naaga.game.exception.GameExceptionType.HINTS_EXHAUSTED; -import static com.now.naaga.game.exception.GameExceptionType.HINT_NOT_EXIST_IN_GAME; - @Transactional @Service public class HintService { diff --git a/backend/src/main/java/com/now/naaga/game/domain/Game.java b/backend/src/main/java/com/now/naaga/game/domain/Game.java index 2ddb4b9ae..882b74145 100644 --- a/backend/src/main/java/com/now/naaga/game/domain/Game.java +++ b/backend/src/main/java/com/now/naaga/game/domain/Game.java @@ -1,5 +1,14 @@ package com.now.naaga.game.domain; +import static com.now.naaga.game.domain.EndType.ARRIVED; +import static com.now.naaga.game.domain.EndType.GIVE_UP; +import static com.now.naaga.game.domain.GameStatus.DONE; +import static com.now.naaga.game.domain.GameStatus.IN_PROGRESS; +import static com.now.naaga.game.exception.GameExceptionType.ALREADY_DONE; +import static com.now.naaga.game.exception.GameExceptionType.INACCESSIBLE_AUTHENTICATION; +import static com.now.naaga.game.exception.GameExceptionType.NOT_ARRIVED; +import static com.now.naaga.game.exception.GameExceptionType.NOT_DONE; + import com.now.naaga.common.domain.BaseEntity; import com.now.naaga.game.exception.GameException; import com.now.naaga.game.exception.GameExceptionType; @@ -7,19 +16,24 @@ import com.now.naaga.place.domain.Place; import com.now.naaga.place.domain.Position; import com.now.naaga.player.domain.Player; -import jakarta.persistence.*; - +import jakarta.persistence.AttributeOverride; +import jakarta.persistence.AttributeOverrides; +import jakarta.persistence.Column; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToMany; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.Objects; -import static com.now.naaga.game.domain.EndType.ARRIVED; -import static com.now.naaga.game.domain.EndType.GIVE_UP; -import static com.now.naaga.game.domain.GameStatus.DONE; -import static com.now.naaga.game.domain.GameStatus.IN_PROGRESS; -import static com.now.naaga.game.exception.GameExceptionType.*; - @Entity public class Game extends BaseEntity { diff --git a/backend/src/main/java/com/now/naaga/game/domain/Statistic.java b/backend/src/main/java/com/now/naaga/game/domain/Statistic.java index 214bba3b9..f627145ff 100644 --- a/backend/src/main/java/com/now/naaga/game/domain/Statistic.java +++ b/backend/src/main/java/com/now/naaga/game/domain/Statistic.java @@ -1,11 +1,11 @@ package com.now.naaga.game.domain; -import java.time.Duration; -import java.util.List; - import static com.now.naaga.gameresult.domain.ResultType.FAIL; import static com.now.naaga.gameresult.domain.ResultType.SUCCESS; +import java.time.Duration; +import java.util.List; + public class Statistic { private int gameCount; diff --git a/backend/src/main/java/com/now/naaga/game/presentation/GameController.java b/backend/src/main/java/com/now/naaga/game/presentation/GameController.java index d7f55eb7a..9b5b4bfb7 100644 --- a/backend/src/main/java/com/now/naaga/game/presentation/GameController.java +++ b/backend/src/main/java/com/now/naaga/game/presentation/GameController.java @@ -1,24 +1,41 @@ package com.now.naaga.game.presentation; +import static com.now.naaga.common.exception.CommonExceptionType.INVALID_REQUEST_PARAMETERS; + import com.now.naaga.auth.presentation.annotation.Auth; import com.now.naaga.common.exception.CommonException; import com.now.naaga.game.application.GameService; import com.now.naaga.game.application.HintService; -import com.now.naaga.game.application.dto.*; +import com.now.naaga.game.application.dto.CreateGameCommand; +import com.now.naaga.game.application.dto.CreateHintCommand; +import com.now.naaga.game.application.dto.EndGameCommand; +import com.now.naaga.game.application.dto.FindAllGamesCommand; +import com.now.naaga.game.application.dto.FindGameByIdCommand; +import com.now.naaga.game.application.dto.FindGameByStatusCommand; +import com.now.naaga.game.application.dto.FindHintByIdCommand; import com.now.naaga.game.domain.Game; import com.now.naaga.game.domain.GameRecord; import com.now.naaga.game.domain.Hint; -import com.now.naaga.game.presentation.dto.*; +import com.now.naaga.game.presentation.dto.CoordinateRequest; +import com.now.naaga.game.presentation.dto.EndGameRequest; +import com.now.naaga.game.presentation.dto.GameResponse; +import com.now.naaga.game.presentation.dto.GameResultResponse; +import com.now.naaga.game.presentation.dto.GameStatusResponse; +import com.now.naaga.game.presentation.dto.HintResponse; import com.now.naaga.player.presentation.dto.PlayerRequest; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - import java.net.URI; import java.util.List; import java.util.stream.Collectors; - -import static com.now.naaga.common.exception.CommonExceptionType.INVALID_REQUEST_PARAMETERS; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; @RequestMapping("/games") @RestController diff --git a/backend/src/main/java/com/now/naaga/game/repository/GameRepository.java b/backend/src/main/java/com/now/naaga/game/repository/GameRepository.java index 27d8e31aa..d7f9b1a93 100644 --- a/backend/src/main/java/com/now/naaga/game/repository/GameRepository.java +++ b/backend/src/main/java/com/now/naaga/game/repository/GameRepository.java @@ -2,9 +2,8 @@ import com.now.naaga.game.domain.Game; import com.now.naaga.game.domain.GameStatus; -import org.springframework.data.jpa.repository.JpaRepository; - import java.util.List; +import org.springframework.data.jpa.repository.JpaRepository; public interface GameRepository extends JpaRepository { diff --git a/backend/src/main/java/com/now/naaga/gameresult/application/GameResultService.java b/backend/src/main/java/com/now/naaga/gameresult/application/GameResultService.java index 010b295ad..25d739646 100644 --- a/backend/src/main/java/com/now/naaga/gameresult/application/GameResultService.java +++ b/backend/src/main/java/com/now/naaga/gameresult/application/GameResultService.java @@ -1,9 +1,9 @@ package com.now.naaga.gameresult.application; +import com.now.naaga.game.application.GameFinishService; import com.now.naaga.game.application.dto.CreateGameResultCommand; import com.now.naaga.game.domain.EndType; import com.now.naaga.game.domain.Game; -import com.now.naaga.game.application.GameFinishService; import com.now.naaga.gameresult.domain.GameResult; import com.now.naaga.gameresult.domain.ResultType; import com.now.naaga.gameresult.domain.gamescore.ResultScoreCalculator; diff --git a/backend/src/main/java/com/now/naaga/gameresult/domain/GameResult.java b/backend/src/main/java/com/now/naaga/gameresult/domain/GameResult.java index 12b8a9c01..ce6acc9e2 100644 --- a/backend/src/main/java/com/now/naaga/gameresult/domain/GameResult.java +++ b/backend/src/main/java/com/now/naaga/gameresult/domain/GameResult.java @@ -3,8 +3,16 @@ import com.now.naaga.common.domain.BaseEntity; import com.now.naaga.game.domain.Game; import com.now.naaga.score.domain.Score; -import jakarta.persistence.*; - +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToOne; import java.util.Objects; @Entity diff --git a/backend/src/main/java/com/now/naaga/gameresult/domain/gamescore/FailResultScorePolicy.java b/backend/src/main/java/com/now/naaga/gameresult/domain/gamescore/FailResultScorePolicy.java index 90a0457ca..5368e1217 100644 --- a/backend/src/main/java/com/now/naaga/gameresult/domain/gamescore/FailResultScorePolicy.java +++ b/backend/src/main/java/com/now/naaga/gameresult/domain/gamescore/FailResultScorePolicy.java @@ -1,11 +1,11 @@ package com.now.naaga.gameresult.domain.gamescore; +import static com.now.naaga.gameresult.domain.ResultType.FAIL; + import com.now.naaga.game.domain.Game; import com.now.naaga.gameresult.domain.ResultType; import com.now.naaga.score.domain.Score; -import static com.now.naaga.gameresult.domain.ResultType.FAIL; - public class FailResultScorePolicy implements ResultScorePolicy { @Override diff --git a/backend/src/main/java/com/now/naaga/gameresult/domain/gamescore/ResultScoreCalculator.java b/backend/src/main/java/com/now/naaga/gameresult/domain/gamescore/ResultScoreCalculator.java index d1db814ef..c8536e948 100644 --- a/backend/src/main/java/com/now/naaga/gameresult/domain/gamescore/ResultScoreCalculator.java +++ b/backend/src/main/java/com/now/naaga/gameresult/domain/gamescore/ResultScoreCalculator.java @@ -1,14 +1,13 @@ package com.now.naaga.gameresult.domain.gamescore; +import static com.now.naaga.common.exception.InternalExceptionType.FAIL_ESTABLISH_GAME_SCORE_POLICY; + import com.now.naaga.common.exception.InternalException; import com.now.naaga.game.domain.Game; import com.now.naaga.gameresult.domain.ResultType; import com.now.naaga.score.domain.Score; - import java.util.List; -import static com.now.naaga.common.exception.InternalExceptionType.FAIL_ESTABLISH_GAME_SCORE_POLICY; - public class ResultScoreCalculator { private final List scorePolicies; diff --git a/backend/src/main/java/com/now/naaga/gameresult/domain/gamescore/SuccessResultScorePolicy.java b/backend/src/main/java/com/now/naaga/gameresult/domain/gamescore/SuccessResultScorePolicy.java index 3827c3d1e..7d5775083 100644 --- a/backend/src/main/java/com/now/naaga/gameresult/domain/gamescore/SuccessResultScorePolicy.java +++ b/backend/src/main/java/com/now/naaga/gameresult/domain/gamescore/SuccessResultScorePolicy.java @@ -1,16 +1,15 @@ package com.now.naaga.gameresult.domain.gamescore; +import static com.now.naaga.game.domain.Game.MAX_ATTEMPT_COUNT; +import static com.now.naaga.game.domain.Game.MAX_HINT_COUNT; +import static com.now.naaga.gameresult.domain.ResultType.SUCCESS; + import com.now.naaga.game.domain.Game; import com.now.naaga.gameresult.domain.ResultType; import com.now.naaga.score.domain.Score; - import java.time.Duration; import java.time.LocalDateTime; -import static com.now.naaga.game.domain.Game.MAX_ATTEMPT_COUNT; -import static com.now.naaga.game.domain.Game.MAX_HINT_COUNT; -import static com.now.naaga.gameresult.domain.ResultType.SUCCESS; - public class SuccessResultScorePolicy implements ResultScorePolicy { private static final Score BASE_SCORE = new Score(50); diff --git a/backend/src/main/java/com/now/naaga/letter/application/LetterService.java b/backend/src/main/java/com/now/naaga/letter/application/LetterService.java index bac46cbdd..2e930bbe9 100644 --- a/backend/src/main/java/com/now/naaga/letter/application/LetterService.java +++ b/backend/src/main/java/com/now/naaga/letter/application/LetterService.java @@ -1,24 +1,23 @@ package com.now.naaga.letter.application; +import static com.now.naaga.letter.exception.LetterExceptionType.NO_EXIST; + +import com.now.naaga.letter.application.dto.CreateLetterCommand; import com.now.naaga.letter.application.letterlog.ReadLetterLogService; +import com.now.naaga.letter.application.letterlog.WriteLetterLogService; import com.now.naaga.letter.application.letterlog.dto.LetterLogCreateCommand; +import com.now.naaga.letter.application.letterlog.dto.WriteLetterLogCreateCommand; import com.now.naaga.letter.domain.Letter; import com.now.naaga.letter.exception.LetterException; import com.now.naaga.letter.presentation.dto.FindNearByLetterCommand; import com.now.naaga.letter.presentation.dto.LetterReadCommand; -import com.now.naaga.letter.application.dto.CreateLetterCommand; -import com.now.naaga.letter.application.letterlog.WriteLetterLogService; -import com.now.naaga.letter.application.letterlog.dto.WriteLetterLogCreateCommand; import com.now.naaga.letter.repository.LetterRepository; import com.now.naaga.player.application.PlayerService; import com.now.naaga.player.domain.Player; +import java.util.List; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.List; - -import static com.now.naaga.letter.exception.LetterExceptionType.NO_EXIST; - @Transactional @Service public class LetterService { diff --git a/backend/src/main/java/com/now/naaga/letter/application/letterlog/ReadLetterLogService.java b/backend/src/main/java/com/now/naaga/letter/application/letterlog/ReadLetterLogService.java index d63c0448a..bd780b0d2 100644 --- a/backend/src/main/java/com/now/naaga/letter/application/letterlog/ReadLetterLogService.java +++ b/backend/src/main/java/com/now/naaga/letter/application/letterlog/ReadLetterLogService.java @@ -1,22 +1,21 @@ package com.now.naaga.letter.application.letterlog; +import static com.now.naaga.game.domain.GameStatus.IN_PROGRESS; + import com.now.naaga.game.application.GameService; +import com.now.naaga.game.application.dto.FindGameByIdCommand; import com.now.naaga.game.application.dto.FindGameByStatusCommand; import com.now.naaga.game.domain.Game; import com.now.naaga.game.exception.GameException; import com.now.naaga.game.exception.GameExceptionType; -import com.now.naaga.letter.application.letterlog.dto.LetterLogCreateCommand; -import com.now.naaga.game.application.dto.FindGameByIdCommand; import com.now.naaga.letter.application.letterlog.dto.LetterByGameCommand; +import com.now.naaga.letter.application.letterlog.dto.LetterLogCreateCommand; import com.now.naaga.letter.domain.letterlog.ReadLetterLog; import com.now.naaga.letter.repository.letterlog.ReadLetterLogRepository; +import java.util.List; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.List; - -import static com.now.naaga.game.domain.GameStatus.IN_PROGRESS; - @Transactional @Service public class ReadLetterLogService { diff --git a/backend/src/main/java/com/now/naaga/letter/application/letterlog/WriteLetterLogService.java b/backend/src/main/java/com/now/naaga/letter/application/letterlog/WriteLetterLogService.java index 86cf95331..c63a69839 100644 --- a/backend/src/main/java/com/now/naaga/letter/application/letterlog/WriteLetterLogService.java +++ b/backend/src/main/java/com/now/naaga/letter/application/letterlog/WriteLetterLogService.java @@ -11,11 +11,10 @@ import com.now.naaga.letter.domain.Letter; import com.now.naaga.letter.domain.letterlog.WriteLetterLog; import com.now.naaga.letter.repository.letterlog.WriteLetterLogRepository; +import java.util.List; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.List; - @Transactional @Service public class WriteLetterLogService { diff --git a/backend/src/main/java/com/now/naaga/letter/domain/Letter.java b/backend/src/main/java/com/now/naaga/letter/domain/Letter.java index 291e65ad3..2d644a5d8 100644 --- a/backend/src/main/java/com/now/naaga/letter/domain/Letter.java +++ b/backend/src/main/java/com/now/naaga/letter/domain/Letter.java @@ -3,8 +3,14 @@ import com.now.naaga.common.domain.BaseEntity; import com.now.naaga.place.domain.Position; import com.now.naaga.player.domain.Player; -import jakarta.persistence.*; - +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import java.time.LocalDateTime; import java.util.Objects; diff --git a/backend/src/main/java/com/now/naaga/letter/domain/letterlog/ReadLetterLog.java b/backend/src/main/java/com/now/naaga/letter/domain/letterlog/ReadLetterLog.java index cd8fa649e..cc73198cc 100644 --- a/backend/src/main/java/com/now/naaga/letter/domain/letterlog/ReadLetterLog.java +++ b/backend/src/main/java/com/now/naaga/letter/domain/letterlog/ReadLetterLog.java @@ -3,8 +3,13 @@ import com.now.naaga.common.domain.BaseEntity; import com.now.naaga.game.domain.Game; import com.now.naaga.letter.domain.Letter; -import jakarta.persistence.*; - +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import java.util.Objects; diff --git a/backend/src/main/java/com/now/naaga/letter/domain/letterlog/WriteLetterLog.java b/backend/src/main/java/com/now/naaga/letter/domain/letterlog/WriteLetterLog.java index e00763d75..b95899dfb 100644 --- a/backend/src/main/java/com/now/naaga/letter/domain/letterlog/WriteLetterLog.java +++ b/backend/src/main/java/com/now/naaga/letter/domain/letterlog/WriteLetterLog.java @@ -2,11 +2,15 @@ import com.now.naaga.common.domain.BaseEntity; import com.now.naaga.game.domain.Game; -import com.now.naaga.letter.exception.LetterException; -import com.now.naaga.letter.exception.LetterExceptionType; import com.now.naaga.letter.domain.Letter; -import jakarta.persistence.*; - +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToOne; import java.util.Objects; @Entity diff --git a/backend/src/main/java/com/now/naaga/letter/presentation/LetterController.java b/backend/src/main/java/com/now/naaga/letter/presentation/LetterController.java index ec65df097..af9b288f5 100644 --- a/backend/src/main/java/com/now/naaga/letter/presentation/LetterController.java +++ b/backend/src/main/java/com/now/naaga/letter/presentation/LetterController.java @@ -4,14 +4,23 @@ import com.now.naaga.letter.application.LetterService; import com.now.naaga.letter.application.dto.CreateLetterCommand; import com.now.naaga.letter.domain.Letter; -import com.now.naaga.letter.presentation.dto.*; +import com.now.naaga.letter.presentation.dto.FindNearByLetterCommand; +import com.now.naaga.letter.presentation.dto.LetterReadCommand; +import com.now.naaga.letter.presentation.dto.LetterRequest; +import com.now.naaga.letter.presentation.dto.LetterResponse; +import com.now.naaga.letter.presentation.dto.NearByLetterResponse; import com.now.naaga.player.presentation.dto.PlayerRequest; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - import java.net.URI; import java.util.List; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; @RequestMapping("/letters") @RestController diff --git a/backend/src/main/java/com/now/naaga/letter/presentation/LetterLogController.java b/backend/src/main/java/com/now/naaga/letter/presentation/LetterLogController.java index 6e184cfcd..dd07115b2 100644 --- a/backend/src/main/java/com/now/naaga/letter/presentation/LetterLogController.java +++ b/backend/src/main/java/com/now/naaga/letter/presentation/LetterLogController.java @@ -1,5 +1,9 @@ package com.now.naaga.letter.presentation; +import static com.now.naaga.common.exception.CommonExceptionType.INVALID_REQUEST_PARAMETERS; +import static com.now.naaga.letter.presentation.LogType.READ; +import static com.now.naaga.letter.presentation.LogType.WRITE; + import com.now.naaga.auth.presentation.annotation.Auth; import com.now.naaga.common.exception.CommonException; import com.now.naaga.letter.application.letterlog.ReadLetterLogService; @@ -9,6 +13,7 @@ import com.now.naaga.letter.domain.letterlog.WriteLetterLog; import com.now.naaga.letter.presentation.dto.LetterResponse; import com.now.naaga.player.presentation.dto.PlayerRequest; +import java.util.List; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; @@ -16,12 +21,6 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import java.util.List; - -import static com.now.naaga.common.exception.CommonExceptionType.INVALID_REQUEST_PARAMETERS; -import static com.now.naaga.letter.presentation.LogType.READ; -import static com.now.naaga.letter.presentation.LogType.WRITE; - @RequestMapping("/letterlogs") @RestController public class LetterLogController { diff --git a/backend/src/main/java/com/now/naaga/letter/presentation/dto/FindNearByLetterCommand.java b/backend/src/main/java/com/now/naaga/letter/presentation/dto/FindNearByLetterCommand.java index a62bf6c73..32d527413 100644 --- a/backend/src/main/java/com/now/naaga/letter/presentation/dto/FindNearByLetterCommand.java +++ b/backend/src/main/java/com/now/naaga/letter/presentation/dto/FindNearByLetterCommand.java @@ -1,7 +1,6 @@ package com.now.naaga.letter.presentation.dto; import com.now.naaga.place.domain.Position; - import java.math.BigDecimal; public record FindNearByLetterCommand(Position position) { diff --git a/backend/src/main/java/com/now/naaga/letter/presentation/dto/NearByLetterResponse.java b/backend/src/main/java/com/now/naaga/letter/presentation/dto/NearByLetterResponse.java index b1dabac08..fa0f1ce2c 100644 --- a/backend/src/main/java/com/now/naaga/letter/presentation/dto/NearByLetterResponse.java +++ b/backend/src/main/java/com/now/naaga/letter/presentation/dto/NearByLetterResponse.java @@ -2,7 +2,6 @@ import com.now.naaga.game.presentation.dto.CoordinateResponse; import com.now.naaga.letter.domain.Letter; - import java.util.List; public record NearByLetterResponse(Long id, diff --git a/backend/src/main/java/com/now/naaga/letter/repository/LetterRepository.java b/backend/src/main/java/com/now/naaga/letter/repository/LetterRepository.java index 2589bc7e2..24ab1c07d 100644 --- a/backend/src/main/java/com/now/naaga/letter/repository/LetterRepository.java +++ b/backend/src/main/java/com/now/naaga/letter/repository/LetterRepository.java @@ -2,12 +2,11 @@ import com.now.naaga.letter.domain.Letter; import com.now.naaga.place.domain.Position; +import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import java.util.List; - public interface LetterRepository extends JpaRepository { @Query(value = "SELECT letter FROM Letter letter " + diff --git a/backend/src/main/java/com/now/naaga/letter/repository/letterlog/ReadLetterLogRepository.java b/backend/src/main/java/com/now/naaga/letter/repository/letterlog/ReadLetterLogRepository.java index 33510773b..7a2d47c79 100644 --- a/backend/src/main/java/com/now/naaga/letter/repository/letterlog/ReadLetterLogRepository.java +++ b/backend/src/main/java/com/now/naaga/letter/repository/letterlog/ReadLetterLogRepository.java @@ -1,9 +1,8 @@ package com.now.naaga.letter.repository.letterlog; import com.now.naaga.letter.domain.letterlog.ReadLetterLog; -import org.springframework.data.jpa.repository.JpaRepository; - import java.util.List; +import org.springframework.data.jpa.repository.JpaRepository; public interface ReadLetterLogRepository extends JpaRepository { diff --git a/backend/src/main/java/com/now/naaga/letter/repository/letterlog/WriteLetterLogRepository.java b/backend/src/main/java/com/now/naaga/letter/repository/letterlog/WriteLetterLogRepository.java index bfd1acf73..1af8058e3 100644 --- a/backend/src/main/java/com/now/naaga/letter/repository/letterlog/WriteLetterLogRepository.java +++ b/backend/src/main/java/com/now/naaga/letter/repository/letterlog/WriteLetterLogRepository.java @@ -1,9 +1,8 @@ package com.now.naaga.letter.repository.letterlog; import com.now.naaga.letter.domain.letterlog.WriteLetterLog; -import org.springframework.data.jpa.repository.JpaRepository; - import java.util.List; +import org.springframework.data.jpa.repository.JpaRepository; public interface WriteLetterLogRepository extends JpaRepository { diff --git a/backend/src/main/java/com/now/naaga/like/application/PlaceLikeService.java b/backend/src/main/java/com/now/naaga/like/application/PlaceLikeService.java index 6dc18106b..1ab9531af 100644 --- a/backend/src/main/java/com/now/naaga/like/application/PlaceLikeService.java +++ b/backend/src/main/java/com/now/naaga/like/application/PlaceLikeService.java @@ -11,13 +11,13 @@ import com.now.naaga.like.exception.PlaceLikeExceptionType; import com.now.naaga.like.repository.PlaceLikeRepository; import com.now.naaga.place.application.PlaceService; +import com.now.naaga.place.application.PlaceStatisticsService; import com.now.naaga.place.application.dto.FindPlaceByIdCommand; +import com.now.naaga.place.application.dto.FindPlaceStatisticsByPlaceIdCommand; +import com.now.naaga.place.application.dto.PlusLikeCommand; +import com.now.naaga.place.application.dto.SubtractLikeCommand; import com.now.naaga.place.domain.Place; -import com.now.naaga.placestatistics.application.PlaceStatisticsService; -import com.now.naaga.placestatistics.application.dto.FindPlaceStatisticsByPlaceIdCommand; -import com.now.naaga.placestatistics.application.dto.PlusLikeCommand; -import com.now.naaga.placestatistics.application.dto.SubtractLikeCommand; -import com.now.naaga.placestatistics.domain.PlaceStatistics; +import com.now.naaga.place.domain.PlaceStatistics; import com.now.naaga.player.application.PlayerService; import com.now.naaga.player.domain.Player; import java.util.Optional; @@ -101,7 +101,7 @@ public void cancelLike(final CancelLikeCommand cancelLikeCommand) { } private void subtractPlaceLikeCount(final Long placeId, final PlaceLike placeLike) { - if(placeLike.getType() == PlaceLikeType.LIKE) { + if (placeLike.getType() == PlaceLikeType.LIKE) { final SubtractLikeCommand subtractLikeCommand = new SubtractLikeCommand(placeId); placeStatisticsService.subtractLike(subtractLikeCommand); } diff --git a/backend/src/main/java/com/now/naaga/like/exception/PlaceLikeExceptionType.java b/backend/src/main/java/com/now/naaga/like/exception/PlaceLikeExceptionType.java index 785efe3b7..88cf5b5b2 100644 --- a/backend/src/main/java/com/now/naaga/like/exception/PlaceLikeExceptionType.java +++ b/backend/src/main/java/com/now/naaga/like/exception/PlaceLikeExceptionType.java @@ -3,8 +3,6 @@ import com.now.naaga.common.exception.BaseExceptionType; import org.springframework.http.HttpStatus; -import static com.now.naaga.game.exception.GameExceptionType.INACCESSIBLE_AUTHENTICATION; - public enum PlaceLikeExceptionType implements BaseExceptionType { INACCESSIBLE_AUTHENTICATION( diff --git a/backend/src/main/java/com/now/naaga/like/repository/PlaceLikeRepository.java b/backend/src/main/java/com/now/naaga/like/repository/PlaceLikeRepository.java index 844a72aa7..b1376f9d7 100644 --- a/backend/src/main/java/com/now/naaga/like/repository/PlaceLikeRepository.java +++ b/backend/src/main/java/com/now/naaga/like/repository/PlaceLikeRepository.java @@ -1,9 +1,8 @@ package com.now.naaga.like.repository; import com.now.naaga.like.domain.PlaceLike; -import org.springframework.data.jpa.repository.JpaRepository; - import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; public interface PlaceLikeRepository extends JpaRepository { diff --git a/backend/src/main/java/com/now/naaga/member/domain/Member.java b/backend/src/main/java/com/now/naaga/member/domain/Member.java index f57ffe742..a8327b525 100644 --- a/backend/src/main/java/com/now/naaga/member/domain/Member.java +++ b/backend/src/main/java/com/now/naaga/member/domain/Member.java @@ -1,12 +1,14 @@ package com.now.naaga.member.domain; import com.now.naaga.common.domain.BaseEntity; -import jakarta.persistence.*; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import java.util.Objects; import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.Where; -import java.util.Objects; - @SQLDelete(sql = "UPDATE member SET deleted = true WHERE id = ?") @Where(clause = "deleted = false") @Entity diff --git a/backend/src/main/java/com/now/naaga/place/application/CreatePlaceStatisticsWithPlaceCreateEventHandler.java b/backend/src/main/java/com/now/naaga/place/application/CreatePlaceStatisticsWithPlaceCreateEventHandler.java new file mode 100644 index 000000000..6726da7b9 --- /dev/null +++ b/backend/src/main/java/com/now/naaga/place/application/CreatePlaceStatisticsWithPlaceCreateEventHandler.java @@ -0,0 +1,25 @@ +package com.now.naaga.place.application; + +import com.now.naaga.place.application.dto.CreatePlaceStatisticsCommand; +import com.now.naaga.place.domain.PlaceCreateEvent; +import org.springframework.context.event.EventListener; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +@Component +public class CreatePlaceStatisticsWithPlaceCreateEventHandler { + + private final PlaceStatisticsService placeStatisticsService; + + public CreatePlaceStatisticsWithPlaceCreateEventHandler(final PlaceStatisticsService placeStatisticsService) { + this.placeStatisticsService = placeStatisticsService; + } + + @Transactional + @EventListener + public void handle(final PlaceCreateEvent placeCreateEvent) { + final Long placeId = placeCreateEvent.placeId(); + final CreatePlaceStatisticsCommand command = new CreatePlaceStatisticsCommand(placeId); + placeStatisticsService.createPlaceStatistics(command); + } +} diff --git a/backend/src/main/java/com/now/naaga/place/application/PlaceService.java b/backend/src/main/java/com/now/naaga/place/application/PlaceService.java index aeacb53d5..0b3ec83de 100644 --- a/backend/src/main/java/com/now/naaga/place/application/PlaceService.java +++ b/backend/src/main/java/com/now/naaga/place/application/PlaceService.java @@ -8,15 +8,16 @@ import com.now.naaga.place.application.dto.FindPlaceByIdCommand; import com.now.naaga.place.application.dto.RecommendPlaceCommand; import com.now.naaga.place.domain.Place; +import com.now.naaga.place.domain.PlaceCreateEvent; import com.now.naaga.place.domain.PlaceRecommendService; import com.now.naaga.place.domain.Position; import com.now.naaga.place.domain.SortType; import com.now.naaga.place.exception.PlaceException; -import com.now.naaga.place.persistence.repository.PlaceRepository; +import com.now.naaga.place.repository.PlaceRepository; import com.now.naaga.player.application.PlayerService; import com.now.naaga.player.domain.Player; -import com.now.naaga.temporaryplace.application.TemporaryPlaceService; import java.util.List; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -28,18 +29,18 @@ public class PlaceService { private final PlayerService playerService; - private final TemporaryPlaceService temporaryPlaceService; - private final PlaceRecommendService placeRecommendService; + private final ApplicationEventPublisher applicationEventPublisher; + public PlaceService(final PlaceRepository placeRepository, final PlayerService playerService, - final TemporaryPlaceService temporaryPlaceService, - final PlaceRecommendService placeRecommendService) { + final PlaceRecommendService placeRecommendService, + final ApplicationEventPublisher applicationEventPublisher) { this.placeRepository = placeRepository; this.playerService = playerService; - this.temporaryPlaceService = temporaryPlaceService; this.placeRecommendService = placeRecommendService; + this.applicationEventPublisher = applicationEventPublisher; } @Transactional(readOnly = true) @@ -73,7 +74,7 @@ public Place createPlace(final CreatePlaceCommand createPlaceCommand) { registeredPlayer); placeRepository.save(place); - temporaryPlaceService.deleteById(createPlaceCommand.temporaryPlaceId()); + applicationEventPublisher.publishEvent(new PlaceCreateEvent(createPlaceCommand.temporaryPlaceId(), place.getId())); return place; } } diff --git a/backend/src/main/java/com/now/naaga/place/application/PlaceStatisticsService.java b/backend/src/main/java/com/now/naaga/place/application/PlaceStatisticsService.java new file mode 100644 index 000000000..b81e4ab49 --- /dev/null +++ b/backend/src/main/java/com/now/naaga/place/application/PlaceStatisticsService.java @@ -0,0 +1,64 @@ +package com.now.naaga.place.application; + +import static com.now.naaga.place.domain.PlaceStatistics.LIKE_COUNT_DEFAULT_VALUE; + +import com.now.naaga.place.application.dto.CreatePlaceStatisticsCommand; +import com.now.naaga.place.application.dto.FindPlaceByIdCommand; +import com.now.naaga.place.application.dto.FindPlaceStatisticsByPlaceIdCommand; +import com.now.naaga.place.application.dto.PlusLikeCommand; +import com.now.naaga.place.application.dto.SubtractLikeCommand; +import com.now.naaga.place.domain.Place; +import com.now.naaga.place.domain.PlaceStatistics; +import com.now.naaga.place.exception.PlaceException; +import com.now.naaga.place.exception.PlaceExceptionType; +import com.now.naaga.place.exception.PlaceStatisticsException; +import com.now.naaga.place.exception.PlaceStatisticsExceptionType; +import com.now.naaga.place.repository.PlaceStatisticsRepository; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Transactional +@Service +public class PlaceStatisticsService { + + private final PlaceStatisticsRepository placeStatisticsRepository; + + private final PlaceService placeService; + + public PlaceStatisticsService(final PlaceStatisticsRepository placeStatisticsRepository, + final PlaceService placeService) { + this.placeStatisticsRepository = placeStatisticsRepository; + this.placeService = placeService; + } + + public PlaceStatistics createPlaceStatistics(final CreatePlaceStatisticsCommand createPlaceStatisticsCommand) { + final Long placeId = createPlaceStatisticsCommand.placeId(); + final Place place = placeService.findPlaceById(new FindPlaceByIdCommand(placeId)); + + final PlaceStatistics placeStatistics = new PlaceStatistics(place, LIKE_COUNT_DEFAULT_VALUE); + return placeStatisticsRepository.save(placeStatistics); + } + + public void plusLike(final PlusLikeCommand plusLikeCommand) { + final Long placeId = plusLikeCommand.placeId(); + final PlaceStatistics placeStatistics = placeStatisticsRepository.findByPlaceId(placeId) + .orElseThrow(() -> new PlaceException(PlaceExceptionType.NO_EXIST)); + placeStatistics.plusLike(); + } + + public void subtractLike(final SubtractLikeCommand subtractLikeCommand) { + final Long placeId = subtractLikeCommand.placeId(); + + final PlaceStatistics placeStatistics = placeStatisticsRepository.findByPlaceId(placeId) + .orElseThrow(() -> new PlaceStatisticsException(PlaceStatisticsExceptionType.NOT_FOUND)); + + placeStatistics.subtractLike(); + } + + public PlaceStatistics findPlaceStatisticsByPlaceId(final FindPlaceStatisticsByPlaceIdCommand findPlaceStatisticsByPlaceIdCommand) { + final Long placeId = findPlaceStatisticsByPlaceIdCommand.placeId(); + + return placeStatisticsRepository.findByPlaceId(placeId) + .orElseThrow(() -> new PlaceStatisticsException(PlaceStatisticsExceptionType.NOT_FOUND)); + } +} diff --git a/backend/src/main/java/com/now/naaga/place/application/dto/CreatePlaceStatisticsCommand.java b/backend/src/main/java/com/now/naaga/place/application/dto/CreatePlaceStatisticsCommand.java new file mode 100644 index 000000000..5366c66e5 --- /dev/null +++ b/backend/src/main/java/com/now/naaga/place/application/dto/CreatePlaceStatisticsCommand.java @@ -0,0 +1,4 @@ +package com.now.naaga.place.application.dto; + +public record CreatePlaceStatisticsCommand(Long placeId) { +} diff --git a/backend/src/main/java/com/now/naaga/placestatistics/application/dto/FindPlaceStatisticsByPlaceIdCommand.java b/backend/src/main/java/com/now/naaga/place/application/dto/FindPlaceStatisticsByPlaceIdCommand.java similarity index 55% rename from backend/src/main/java/com/now/naaga/placestatistics/application/dto/FindPlaceStatisticsByPlaceIdCommand.java rename to backend/src/main/java/com/now/naaga/place/application/dto/FindPlaceStatisticsByPlaceIdCommand.java index 9a84fbd72..be6546cd8 100644 --- a/backend/src/main/java/com/now/naaga/placestatistics/application/dto/FindPlaceStatisticsByPlaceIdCommand.java +++ b/backend/src/main/java/com/now/naaga/place/application/dto/FindPlaceStatisticsByPlaceIdCommand.java @@ -1,4 +1,4 @@ -package com.now.naaga.placestatistics.application.dto; +package com.now.naaga.place.application.dto; public record FindPlaceStatisticsByPlaceIdCommand(Long placeId) { } diff --git a/backend/src/main/java/com/now/naaga/place/application/dto/PlusLikeCommand.java b/backend/src/main/java/com/now/naaga/place/application/dto/PlusLikeCommand.java new file mode 100644 index 000000000..cfd4b8bc7 --- /dev/null +++ b/backend/src/main/java/com/now/naaga/place/application/dto/PlusLikeCommand.java @@ -0,0 +1,4 @@ +package com.now.naaga.place.application.dto; + +public record PlusLikeCommand(Long placeId) { +} diff --git a/backend/src/main/java/com/now/naaga/place/application/dto/SubtractLikeCommand.java b/backend/src/main/java/com/now/naaga/place/application/dto/SubtractLikeCommand.java new file mode 100644 index 000000000..149043c94 --- /dev/null +++ b/backend/src/main/java/com/now/naaga/place/application/dto/SubtractLikeCommand.java @@ -0,0 +1,4 @@ +package com.now.naaga.place.application.dto; + +public record SubtractLikeCommand(Long placeId) { +} diff --git a/backend/src/main/java/com/now/naaga/place/domain/Place.java b/backend/src/main/java/com/now/naaga/place/domain/Place.java index 6b2682faa..2d8b9882c 100644 --- a/backend/src/main/java/com/now/naaga/place/domain/Place.java +++ b/backend/src/main/java/com/now/naaga/place/domain/Place.java @@ -6,8 +6,14 @@ import com.now.naaga.place.exception.PlaceException; import com.now.naaga.place.exception.PlaceExceptionType; import com.now.naaga.player.domain.Player; -import jakarta.persistence.*; - +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import java.util.Objects; @Entity diff --git a/backend/src/main/java/com/now/naaga/place/domain/PlaceCreateEvent.java b/backend/src/main/java/com/now/naaga/place/domain/PlaceCreateEvent.java new file mode 100644 index 000000000..93f2548a2 --- /dev/null +++ b/backend/src/main/java/com/now/naaga/place/domain/PlaceCreateEvent.java @@ -0,0 +1,5 @@ +package com.now.naaga.place.domain; + +public record PlaceCreateEvent(Long temporaryPlaceId, + Long placeId) { +} diff --git a/backend/src/main/java/com/now/naaga/place/domain/PlaceRecommendService.java b/backend/src/main/java/com/now/naaga/place/domain/PlaceRecommendService.java index 93060f064..63adfa6a8 100644 --- a/backend/src/main/java/com/now/naaga/place/domain/PlaceRecommendService.java +++ b/backend/src/main/java/com/now/naaga/place/domain/PlaceRecommendService.java @@ -1,14 +1,12 @@ package com.now.naaga.place.domain; -import com.now.naaga.place.exception.PlaceException; -import com.now.naaga.place.persistence.repository.PlaceRepository; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; +import static com.now.naaga.place.exception.PlaceExceptionType.NO_EXIST; +import com.now.naaga.place.exception.PlaceException; +import com.now.naaga.place.repository.PlaceRepository; import java.util.List; import java.util.Random; - -import static com.now.naaga.place.exception.PlaceExceptionType.NO_EXIST; +import org.springframework.stereotype.Service; @Service public class PlaceRecommendService { diff --git a/backend/src/main/java/com/now/naaga/placestatistics/domain/PlaceStatistics.java b/backend/src/main/java/com/now/naaga/place/domain/PlaceStatistics.java similarity index 86% rename from backend/src/main/java/com/now/naaga/placestatistics/domain/PlaceStatistics.java rename to backend/src/main/java/com/now/naaga/place/domain/PlaceStatistics.java index e8a33fd6e..c3adeba52 100644 --- a/backend/src/main/java/com/now/naaga/placestatistics/domain/PlaceStatistics.java +++ b/backend/src/main/java/com/now/naaga/place/domain/PlaceStatistics.java @@ -1,10 +1,13 @@ -package com.now.naaga.placestatistics.domain; +package com.now.naaga.place.domain; import com.now.naaga.common.domain.BaseEntity; -import com.now.naaga.place.domain.Place; -import jakarta.persistence.*; -import org.hibernate.annotations.DialectOverride; - +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToOne; import java.util.Objects; @Entity diff --git a/backend/src/main/java/com/now/naaga/placestatistics/exception/PlaceStatisticsException.java b/backend/src/main/java/com/now/naaga/place/exception/PlaceStatisticsException.java similarity index 91% rename from backend/src/main/java/com/now/naaga/placestatistics/exception/PlaceStatisticsException.java rename to backend/src/main/java/com/now/naaga/place/exception/PlaceStatisticsException.java index 42c1b185e..11991da1a 100644 --- a/backend/src/main/java/com/now/naaga/placestatistics/exception/PlaceStatisticsException.java +++ b/backend/src/main/java/com/now/naaga/place/exception/PlaceStatisticsException.java @@ -1,4 +1,4 @@ -package com.now.naaga.placestatistics.exception; +package com.now.naaga.place.exception; import com.now.naaga.common.exception.BaseException; import com.now.naaga.common.exception.BaseExceptionType; diff --git a/backend/src/main/java/com/now/naaga/placestatistics/exception/PlaceStatisticsExceptionType.java b/backend/src/main/java/com/now/naaga/place/exception/PlaceStatisticsExceptionType.java similarity index 95% rename from backend/src/main/java/com/now/naaga/placestatistics/exception/PlaceStatisticsExceptionType.java rename to backend/src/main/java/com/now/naaga/place/exception/PlaceStatisticsExceptionType.java index 57a009d9b..421f03a32 100644 --- a/backend/src/main/java/com/now/naaga/placestatistics/exception/PlaceStatisticsExceptionType.java +++ b/backend/src/main/java/com/now/naaga/place/exception/PlaceStatisticsExceptionType.java @@ -1,4 +1,4 @@ -package com.now.naaga.placestatistics.exception; +package com.now.naaga.place.exception; import com.now.naaga.common.exception.BaseExceptionType; import org.springframework.http.HttpStatus; diff --git a/backend/src/main/java/com/now/naaga/place/persistence/repository/PlaceRepository.java b/backend/src/main/java/com/now/naaga/place/repository/PlaceRepository.java similarity index 95% rename from backend/src/main/java/com/now/naaga/place/persistence/repository/PlaceRepository.java rename to backend/src/main/java/com/now/naaga/place/repository/PlaceRepository.java index 60198adf9..acc420dcd 100644 --- a/backend/src/main/java/com/now/naaga/place/persistence/repository/PlaceRepository.java +++ b/backend/src/main/java/com/now/naaga/place/repository/PlaceRepository.java @@ -1,4 +1,4 @@ -package com.now.naaga.place.persistence.repository; +package com.now.naaga.place.repository; import com.now.naaga.place.domain.Place; import com.now.naaga.place.domain.Position; diff --git a/backend/src/main/java/com/now/naaga/placestatistics/repository/PlaceStatisticsRepository.java b/backend/src/main/java/com/now/naaga/place/repository/PlaceStatisticsRepository.java similarity index 68% rename from backend/src/main/java/com/now/naaga/placestatistics/repository/PlaceStatisticsRepository.java rename to backend/src/main/java/com/now/naaga/place/repository/PlaceStatisticsRepository.java index 20df04940..01c07d853 100644 --- a/backend/src/main/java/com/now/naaga/placestatistics/repository/PlaceStatisticsRepository.java +++ b/backend/src/main/java/com/now/naaga/place/repository/PlaceStatisticsRepository.java @@ -1,9 +1,8 @@ -package com.now.naaga.placestatistics.repository; - -import com.now.naaga.placestatistics.domain.PlaceStatistics; -import org.springframework.data.jpa.repository.JpaRepository; +package com.now.naaga.place.repository; +import com.now.naaga.place.domain.PlaceStatistics; import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; public interface PlaceStatisticsRepository extends JpaRepository { diff --git a/backend/src/main/java/com/now/naaga/placestatistics/application/PlaceStatisticsService.java b/backend/src/main/java/com/now/naaga/placestatistics/application/PlaceStatisticsService.java deleted file mode 100644 index fecdd1d8f..000000000 --- a/backend/src/main/java/com/now/naaga/placestatistics/application/PlaceStatisticsService.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.now.naaga.placestatistics.application; - -import com.now.naaga.place.exception.PlaceException; -import com.now.naaga.place.exception.PlaceExceptionType; -import com.now.naaga.placestatistics.application.dto.FindPlaceStatisticsByPlaceIdCommand; -import com.now.naaga.placestatistics.application.dto.PlusLikeCommand; -import com.now.naaga.placestatistics.application.dto.SubtractLikeCommand; -import com.now.naaga.placestatistics.domain.PlaceStatistics; -import com.now.naaga.placestatistics.exception.PlaceStatisticsException; -import com.now.naaga.placestatistics.exception.PlaceStatisticsExceptionType; -import com.now.naaga.placestatistics.repository.PlaceStatisticsRepository; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Transactional -@Service -public class PlaceStatisticsService { - - private final PlaceStatisticsRepository placeStatisticsRepository; - - public PlaceStatisticsService(final PlaceStatisticsRepository placeStatisticsRepository) { - this.placeStatisticsRepository = placeStatisticsRepository; - } - - public void plusLike(final PlusLikeCommand plusLikeCommand) { - final Long placeId = plusLikeCommand.placeId(); - final PlaceStatistics placeStatistics = placeStatisticsRepository.findByPlaceId(placeId) - .orElseThrow(() -> new PlaceException(PlaceExceptionType.NO_EXIST)); - placeStatistics.plusLike(); - } - - public void subtractLike(final SubtractLikeCommand subtractLikeCommand) { - final Long placeId = subtractLikeCommand.placeId(); - - final PlaceStatistics placeStatistics = placeStatisticsRepository.findByPlaceId(placeId) - .orElseThrow(() -> new PlaceStatisticsException(PlaceStatisticsExceptionType.NOT_FOUND)); - - placeStatistics.subtractLike(); - } - - public PlaceStatistics findPlaceStatisticsByPlaceId(final FindPlaceStatisticsByPlaceIdCommand findPlaceStatisticsByPlaceIdCommand) { - final Long placeId = findPlaceStatisticsByPlaceIdCommand.placeId(); - - return placeStatisticsRepository.findByPlaceId(placeId) - .orElseThrow(() -> new PlaceStatisticsException(PlaceStatisticsExceptionType.NOT_FOUND)); - } -} diff --git a/backend/src/main/java/com/now/naaga/placestatistics/application/dto/PlusLikeCommand.java b/backend/src/main/java/com/now/naaga/placestatistics/application/dto/PlusLikeCommand.java deleted file mode 100644 index 176c755fb..000000000 --- a/backend/src/main/java/com/now/naaga/placestatistics/application/dto/PlusLikeCommand.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.now.naaga.placestatistics.application.dto; - -public record PlusLikeCommand(Long placeId) { -} diff --git a/backend/src/main/java/com/now/naaga/placestatistics/application/dto/SubtractLikeCommand.java b/backend/src/main/java/com/now/naaga/placestatistics/application/dto/SubtractLikeCommand.java deleted file mode 100644 index f20511111..000000000 --- a/backend/src/main/java/com/now/naaga/placestatistics/application/dto/SubtractLikeCommand.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.now.naaga.placestatistics.application.dto; - -public record SubtractLikeCommand(Long placeId) { -} diff --git a/backend/src/main/java/com/now/naaga/player/application/PlayerService.java b/backend/src/main/java/com/now/naaga/player/application/PlayerService.java index b1c96dd24..b3ea891ad 100644 --- a/backend/src/main/java/com/now/naaga/player/application/PlayerService.java +++ b/backend/src/main/java/com/now/naaga/player/application/PlayerService.java @@ -1,5 +1,7 @@ package com.now.naaga.player.application; +import static com.now.naaga.player.exception.PlayerExceptionType.PLAYER_NOT_FOUND; + import com.now.naaga.player.application.dto.AddScoreCommand; import com.now.naaga.player.application.dto.CreatePlayerCommand; import com.now.naaga.player.application.dto.DeletePlayerCommand; @@ -9,13 +11,10 @@ import com.now.naaga.player.persistence.repository.PlayerRepository; import com.now.naaga.player.presentation.dto.PlayerRequest; import com.now.naaga.score.domain.Score; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - import java.util.ArrayList; import java.util.List; - -import static com.now.naaga.player.exception.PlayerExceptionType.PLAYER_NOT_FOUND; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Transactional @Service diff --git a/backend/src/main/java/com/now/naaga/player/domain/Player.java b/backend/src/main/java/com/now/naaga/player/domain/Player.java index c892c1a62..aaea7a4c3 100644 --- a/backend/src/main/java/com/now/naaga/player/domain/Player.java +++ b/backend/src/main/java/com/now/naaga/player/domain/Player.java @@ -1,16 +1,24 @@ package com.now.naaga.player.domain; +import static java.lang.Boolean.FALSE; + import com.now.naaga.common.domain.BaseEntity; import com.now.naaga.member.domain.Member; import com.now.naaga.score.domain.Score; -import jakarta.persistence.*; +import jakarta.persistence.AttributeOverride; +import jakarta.persistence.Column; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToOne; +import java.util.Objects; import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.Where; -import java.util.Objects; - -import static java.lang.Boolean.FALSE; - @SQLDelete(sql = "UPDATE player SET deleted = true WHERE id = ?") @Where(clause = "deleted = false") @Entity diff --git a/backend/src/main/java/com/now/naaga/player/presentation/PlayerController.java b/backend/src/main/java/com/now/naaga/player/presentation/PlayerController.java index 318957cac..0638e5ac7 100644 --- a/backend/src/main/java/com/now/naaga/player/presentation/PlayerController.java +++ b/backend/src/main/java/com/now/naaga/player/presentation/PlayerController.java @@ -1,22 +1,21 @@ package com.now.naaga.player.presentation; +import static com.now.naaga.common.exception.CommonExceptionType.INVALID_REQUEST_PARAMETERS; + import com.now.naaga.auth.presentation.annotation.Auth; import com.now.naaga.common.exception.CommonException; import com.now.naaga.player.application.PlayerService; import com.now.naaga.player.domain.Rank; import com.now.naaga.player.presentation.dto.PlayerRequest; import com.now.naaga.player.presentation.dto.RankResponse; +import java.util.List; +import java.util.stream.Collectors; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import java.util.List; -import java.util.stream.Collectors; - -import static com.now.naaga.common.exception.CommonExceptionType.INVALID_REQUEST_PARAMETERS; - @RequestMapping("/ranks") @RestController public class PlayerController { diff --git a/backend/src/main/java/com/now/naaga/temporaryplace/application/DeleteTemporaryPlaceWithPlaceCreateEventHandler.java b/backend/src/main/java/com/now/naaga/temporaryplace/application/DeleteTemporaryPlaceWithPlaceCreateEventHandler.java new file mode 100644 index 000000000..f27828ea3 --- /dev/null +++ b/backend/src/main/java/com/now/naaga/temporaryplace/application/DeleteTemporaryPlaceWithPlaceCreateEventHandler.java @@ -0,0 +1,23 @@ +package com.now.naaga.temporaryplace.application; + +import com.now.naaga.place.domain.PlaceCreateEvent; +import org.springframework.context.event.EventListener; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +@Component +public class DeleteTemporaryPlaceWithPlaceCreateEventHandler { + + private final TemporaryPlaceService temporaryPlaceService; + + public DeleteTemporaryPlaceWithPlaceCreateEventHandler(final TemporaryPlaceService temporaryPlaceService) { + this.temporaryPlaceService = temporaryPlaceService; + } + + @Transactional + @EventListener + public void handle(final PlaceCreateEvent placeCreateEvent) { + final Long temporaryPlaceId = placeCreateEvent.temporaryPlaceId(); + temporaryPlaceService.deleteById(temporaryPlaceId); + } +} diff --git a/backend/src/main/java/com/now/naaga/temporaryplace/application/TemporaryPlaceService.java b/backend/src/main/java/com/now/naaga/temporaryplace/application/TemporaryPlaceService.java index 5165a2694..355782be4 100644 --- a/backend/src/main/java/com/now/naaga/temporaryplace/application/TemporaryPlaceService.java +++ b/backend/src/main/java/com/now/naaga/temporaryplace/application/TemporaryPlaceService.java @@ -7,13 +7,12 @@ import com.now.naaga.temporaryplace.application.dto.CreateTemporaryPlaceCommand; import com.now.naaga.temporaryplace.domain.TemporaryPlace; import com.now.naaga.temporaryplace.repository.TemporaryPlaceRepository; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.multipart.MultipartFile; - import java.io.File; import java.util.Comparator; import java.util.List; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; @Transactional @Service diff --git a/backend/src/main/java/com/now/naaga/temporaryplace/presentation/TemporaryPlaceController.java b/backend/src/main/java/com/now/naaga/temporaryplace/presentation/TemporaryPlaceController.java index c6832a902..a9d47954b 100644 --- a/backend/src/main/java/com/now/naaga/temporaryplace/presentation/TemporaryPlaceController.java +++ b/backend/src/main/java/com/now/naaga/temporaryplace/presentation/TemporaryPlaceController.java @@ -7,12 +7,17 @@ import com.now.naaga.temporaryplace.domain.TemporaryPlace; import com.now.naaga.temporaryplace.presentation.dto.CreateTemporaryPlaceRequest; import com.now.naaga.temporaryplace.presentation.dto.TemporaryPlaceResponse; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - import java.net.URI; import java.util.List; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; @RequestMapping("/temporary-places") @RestController diff --git a/backend/src/main/java/com/now/naaga/temporaryplace/presentation/dto/TemporaryPlaceResponse.java b/backend/src/main/java/com/now/naaga/temporaryplace/presentation/dto/TemporaryPlaceResponse.java index 2730c3832..f8da3b645 100644 --- a/backend/src/main/java/com/now/naaga/temporaryplace/presentation/dto/TemporaryPlaceResponse.java +++ b/backend/src/main/java/com/now/naaga/temporaryplace/presentation/dto/TemporaryPlaceResponse.java @@ -2,7 +2,6 @@ import com.now.naaga.game.presentation.dto.CoordinateResponse; import com.now.naaga.temporaryplace.domain.TemporaryPlace; - import java.util.List; import java.util.stream.Collectors; diff --git a/backend/src/main/java/com/now/naaga/temporaryplace/repository/TemporaryPlaceRepository.java b/backend/src/main/java/com/now/naaga/temporaryplace/repository/TemporaryPlaceRepository.java index d9a4a1faf..6c3ac7a0e 100644 --- a/backend/src/main/java/com/now/naaga/temporaryplace/repository/TemporaryPlaceRepository.java +++ b/backend/src/main/java/com/now/naaga/temporaryplace/repository/TemporaryPlaceRepository.java @@ -2,11 +2,10 @@ import com.now.naaga.temporaryplace.domain.TemporaryPlace; +import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; -import java.util.List; - public interface TemporaryPlaceRepository extends JpaRepository { @Override diff --git a/backend/src/test/java/com/now/naaga/auth/application/AuthServiceTest.java b/backend/src/test/java/com/now/naaga/auth/application/AuthServiceTest.java index 4ca8e2bff..106c8170e 100644 --- a/backend/src/test/java/com/now/naaga/auth/application/AuthServiceTest.java +++ b/backend/src/test/java/com/now/naaga/auth/application/AuthServiceTest.java @@ -1,19 +1,24 @@ package com.now.naaga.auth.application; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.SoftAssertions.assertSoftly; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.when; + import com.now.naaga.auth.application.dto.AuthCommand; -import com.now.naaga.auth.infrastructure.dto.AuthInfo; import com.now.naaga.auth.domain.AuthToken; import com.now.naaga.auth.infrastructure.AuthClient; import com.now.naaga.auth.infrastructure.AuthType; +import com.now.naaga.auth.infrastructure.dto.AuthInfo; import com.now.naaga.auth.infrastructure.dto.MemberAuth; import com.now.naaga.common.builder.PlayerBuilder; import com.now.naaga.member.domain.Member; -import com.now.naaga.member.exception.MemberException; import com.now.naaga.member.persistence.repository.MemberRepository; import com.now.naaga.player.domain.Player; -import com.now.naaga.player.exception.PlayerException; import com.now.naaga.player.persistence.repository.PlayerRepository; import com.now.naaga.score.domain.Score; +import java.util.Optional; import org.assertj.core.api.SoftAssertions; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator; @@ -22,16 +27,6 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.jdbc.Sql; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.MimeType; - -import java.util.Optional; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.SoftAssertions.assertSoftly; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.when; @SuppressWarnings("NonAsciiCharacters") @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) diff --git a/backend/src/test/java/com/now/naaga/auth/presentation/AuthControllerTest.java b/backend/src/test/java/com/now/naaga/auth/presentation/AuthControllerTest.java index 544f04d7a..eae1b861f 100644 --- a/backend/src/test/java/com/now/naaga/auth/presentation/AuthControllerTest.java +++ b/backend/src/test/java/com/now/naaga/auth/presentation/AuthControllerTest.java @@ -1,5 +1,14 @@ package com.now.naaga.auth.presentation; +import static com.now.naaga.auth.exception.AuthExceptionType.EXPIRED_TOKEN; +import static com.now.naaga.auth.exception.AuthExceptionType.INVALID_TOKEN; +import static com.now.naaga.auth.exception.AuthExceptionType.INVALID_TOKEN_ACCESS; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.SoftAssertions.assertSoftly; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.when; + import com.now.naaga.auth.domain.AuthToken; import com.now.naaga.auth.infrastructure.AuthClient; import com.now.naaga.auth.infrastructure.AuthType; @@ -17,11 +26,11 @@ import com.now.naaga.common.exception.ExceptionResponse; import com.now.naaga.member.domain.Member; import com.now.naaga.player.domain.Player; -import com.now.naaga.player.persistence.repository.PlayerRepository; import com.now.naaga.score.domain.Score; import io.restassured.RestAssured; import io.restassured.response.ExtractableResponse; import io.restassured.response.Response; +import java.util.Date; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; @@ -31,16 +40,6 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; -import java.util.Date; - -import static com.now.naaga.auth.exception.AuthExceptionType.*; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.InstanceOfAssertFactories.spliterator; -import static org.assertj.core.api.SoftAssertions.assertSoftly; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.when; - @SuppressWarnings("NonAsciiCharacters") @DisplayNameGeneration(ReplaceUnderscores.class) class AuthControllerTest extends CommonControllerTest { diff --git a/backend/src/test/java/com/now/naaga/auth/presentation/AuthInterceptorTest.java b/backend/src/test/java/com/now/naaga/auth/presentation/AuthInterceptorTest.java index 604b55c32..ae30a54fe 100644 --- a/backend/src/test/java/com/now/naaga/auth/presentation/AuthInterceptorTest.java +++ b/backend/src/test/java/com/now/naaga/auth/presentation/AuthInterceptorTest.java @@ -1,5 +1,11 @@ package com.now.naaga.auth.presentation; +import static com.now.naaga.auth.exception.AuthExceptionType.INVALID_HEADER; +import static com.now.naaga.auth.exception.AuthExceptionType.INVALID_TOKEN; +import static com.now.naaga.auth.exception.AuthExceptionType.NOT_EXIST_HEADER; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.SoftAssertions.assertSoftly; + import com.now.naaga.auth.domain.AuthToken; import com.now.naaga.auth.infrastructure.AuthType; import com.now.naaga.auth.infrastructure.jwt.AuthTokenGenerator; @@ -21,10 +27,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; -import static com.now.naaga.auth.exception.AuthExceptionType.*; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.SoftAssertions.assertSoftly; - @SuppressWarnings("NonAsciiCharacters") @DisplayNameGeneration(ReplaceUnderscores.class) public class AuthInterceptorTest extends CommonControllerTest { diff --git a/backend/src/test/java/com/now/naaga/auth/presentation/PlayerArgumentResolverTest.java b/backend/src/test/java/com/now/naaga/auth/presentation/PlayerArgumentResolverTest.java index 4db66a1a4..702334f78 100644 --- a/backend/src/test/java/com/now/naaga/auth/presentation/PlayerArgumentResolverTest.java +++ b/backend/src/test/java/com/now/naaga/auth/presentation/PlayerArgumentResolverTest.java @@ -1,5 +1,9 @@ package com.now.naaga.auth.presentation; +import static com.now.naaga.player.exception.PlayerExceptionType.PLAYER_NOT_FOUND; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.SoftAssertions.assertSoftly; + import com.now.naaga.auth.domain.AuthToken; import com.now.naaga.auth.infrastructure.AuthType; import com.now.naaga.auth.infrastructure.jwt.AuthTokenGenerator; @@ -18,10 +22,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; -import static com.now.naaga.player.exception.PlayerExceptionType.PLAYER_NOT_FOUND; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.SoftAssertions.assertSoftly; - @SuppressWarnings("NonAsciiCharacters") @DisplayNameGeneration(ReplaceUnderscores.class) public class PlayerArgumentResolverTest extends CommonControllerTest { diff --git a/backend/src/test/java/com/now/naaga/auth/presentation/interceptor/ManagerAuthInterceptorTest.java b/backend/src/test/java/com/now/naaga/auth/presentation/interceptor/ManagerAuthInterceptorTest.java index 0ba3de499..6eb262c4d 100644 --- a/backend/src/test/java/com/now/naaga/auth/presentation/interceptor/ManagerAuthInterceptorTest.java +++ b/backend/src/test/java/com/now/naaga/auth/presentation/interceptor/ManagerAuthInterceptorTest.java @@ -1,6 +1,10 @@ package com.now.naaga.auth.presentation.interceptor; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + import com.now.naaga.auth.exception.AuthException; +import java.util.Base64; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Test; @@ -13,11 +17,6 @@ import org.springframework.test.context.ActiveProfiles; import org.springframework.web.servlet.mvc.Controller; -import java.util.Base64; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - @ActiveProfiles("test") @SuppressWarnings("NonAsciiCharacters") @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) diff --git a/backend/src/test/java/com/now/naaga/common/builder/LetterBuilder.java b/backend/src/test/java/com/now/naaga/common/builder/LetterBuilder.java index bf9013ea8..de7e2b51b 100644 --- a/backend/src/test/java/com/now/naaga/common/builder/LetterBuilder.java +++ b/backend/src/test/java/com/now/naaga/common/builder/LetterBuilder.java @@ -1,17 +1,16 @@ package com.now.naaga.common.builder; +import static com.now.naaga.common.fixture.LetterFixture.MESSAGE; +import static com.now.naaga.common.fixture.PositionFixture.잠실역_교보문고_좌표; + import com.now.naaga.letter.domain.Letter; import com.now.naaga.letter.repository.LetterRepository; import com.now.naaga.place.domain.Position; import com.now.naaga.player.domain.Player; +import java.util.Optional; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.Optional; - -import static com.now.naaga.common.fixture.LetterFixture.MESSAGE; -import static com.now.naaga.common.fixture.PositionFixture.잠실역_교보문고_좌표; - @Component public class LetterBuilder { diff --git a/backend/src/test/java/com/now/naaga/common/builder/PlaceBuilder.java b/backend/src/test/java/com/now/naaga/common/builder/PlaceBuilder.java index bfca3974d..d716e2b98 100644 --- a/backend/src/test/java/com/now/naaga/common/builder/PlaceBuilder.java +++ b/backend/src/test/java/com/now/naaga/common/builder/PlaceBuilder.java @@ -7,7 +7,7 @@ import com.now.naaga.place.domain.Place; import com.now.naaga.place.domain.Position; -import com.now.naaga.place.persistence.repository.PlaceRepository; +import com.now.naaga.place.repository.PlaceRepository; import com.now.naaga.player.domain.Player; import java.util.Optional; import org.springframework.beans.factory.annotation.Autowired; diff --git a/backend/src/test/java/com/now/naaga/common/builder/PlaceStatisticsBuilder.java b/backend/src/test/java/com/now/naaga/common/builder/PlaceStatisticsBuilder.java index 6ca0293f8..e0211024b 100644 --- a/backend/src/test/java/com/now/naaga/common/builder/PlaceStatisticsBuilder.java +++ b/backend/src/test/java/com/now/naaga/common/builder/PlaceStatisticsBuilder.java @@ -1,8 +1,8 @@ package com.now.naaga.common.builder; import com.now.naaga.place.domain.Place; -import com.now.naaga.placestatistics.domain.PlaceStatistics; -import com.now.naaga.placestatistics.repository.PlaceStatisticsRepository; +import com.now.naaga.place.domain.PlaceStatistics; +import com.now.naaga.place.repository.PlaceStatisticsRepository; import java.util.Optional; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/backend/src/test/java/com/now/naaga/common/builder/ReadLetterLogBuilder.java b/backend/src/test/java/com/now/naaga/common/builder/ReadLetterLogBuilder.java index 8e2f329fb..5e9b30fcb 100644 --- a/backend/src/test/java/com/now/naaga/common/builder/ReadLetterLogBuilder.java +++ b/backend/src/test/java/com/now/naaga/common/builder/ReadLetterLogBuilder.java @@ -4,11 +4,10 @@ import com.now.naaga.letter.domain.Letter; import com.now.naaga.letter.domain.letterlog.ReadLetterLog; import com.now.naaga.letter.repository.letterlog.ReadLetterLogRepository; +import java.util.Optional; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.Optional; - @Component public class ReadLetterLogBuilder { diff --git a/backend/src/test/java/com/now/naaga/common/builder/WriteLetterLogBuilder.java b/backend/src/test/java/com/now/naaga/common/builder/WriteLetterLogBuilder.java index efea96ca4..27ed2d335 100644 --- a/backend/src/test/java/com/now/naaga/common/builder/WriteLetterLogBuilder.java +++ b/backend/src/test/java/com/now/naaga/common/builder/WriteLetterLogBuilder.java @@ -4,11 +4,10 @@ import com.now.naaga.letter.domain.Letter; import com.now.naaga.letter.domain.letterlog.WriteLetterLog; import com.now.naaga.letter.repository.letterlog.WriteLetterLogRepository; +import java.util.Optional; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.Optional; - @Component public class WriteLetterLogBuilder { diff --git a/backend/src/test/java/com/now/naaga/common/fixture/GameFixture.java b/backend/src/test/java/com/now/naaga/common/fixture/GameFixture.java index c9c7bc09d..f9f5d79ca 100644 --- a/backend/src/test/java/com/now/naaga/common/fixture/GameFixture.java +++ b/backend/src/test/java/com/now/naaga/common/fixture/GameFixture.java @@ -1,11 +1,11 @@ package com.now.naaga.common.fixture; -import com.now.naaga.game.domain.Game; - import static com.now.naaga.common.fixture.PlaceFixture.PLACE; import static com.now.naaga.common.fixture.PlayerFixture.PLAYER; import static com.now.naaga.common.fixture.PositionFixture.서울_좌표; +import com.now.naaga.game.domain.Game; + public class GameFixture { public static Game GAME() { diff --git a/backend/src/test/java/com/now/naaga/common/fixture/LetterFixture.java b/backend/src/test/java/com/now/naaga/common/fixture/LetterFixture.java index dadc3607f..aff247be8 100644 --- a/backend/src/test/java/com/now/naaga/common/fixture/LetterFixture.java +++ b/backend/src/test/java/com/now/naaga/common/fixture/LetterFixture.java @@ -1,10 +1,10 @@ package com.now.naaga.common.fixture; -import com.now.naaga.letter.domain.Letter; - import static com.now.naaga.common.fixture.PlayerFixture.PLAYER; import static com.now.naaga.common.fixture.PositionFixture.잠실_루터회관_정문_좌표; +import com.now.naaga.letter.domain.Letter; + public class LetterFixture { public static final String MESSAGE = "안녕하세요. 나아가 개발자들 입니다."; diff --git a/backend/src/test/java/com/now/naaga/common/fixture/PlaceFixture.java b/backend/src/test/java/com/now/naaga/common/fixture/PlaceFixture.java index f4d5363d0..4fb54e1bb 100644 --- a/backend/src/test/java/com/now/naaga/common/fixture/PlaceFixture.java +++ b/backend/src/test/java/com/now/naaga/common/fixture/PlaceFixture.java @@ -1,7 +1,6 @@ package com.now.naaga.common.fixture; -import static com.now.naaga.common.fixture.PlayerFixture.PLAYER; -import static com.now.naaga.common.fixture.PositionFixture.*; +import static com.now.naaga.common.fixture.PositionFixture.서울_좌표; import com.now.naaga.place.domain.Place; import com.now.naaga.place.domain.Position; diff --git a/backend/src/test/java/com/now/naaga/common/fixture/PlaceStatisticsFixture.java b/backend/src/test/java/com/now/naaga/common/fixture/PlaceStatisticsFixture.java index 996de531b..0f35c6bd2 100644 --- a/backend/src/test/java/com/now/naaga/common/fixture/PlaceStatisticsFixture.java +++ b/backend/src/test/java/com/now/naaga/common/fixture/PlaceStatisticsFixture.java @@ -1,6 +1,6 @@ package com.now.naaga.common.fixture; -import com.now.naaga.placestatistics.domain.PlaceStatistics; +import com.now.naaga.place.domain.PlaceStatistics; public class PlaceStatisticsFixture { diff --git a/backend/src/test/java/com/now/naaga/common/fixture/PlayerFixture.java b/backend/src/test/java/com/now/naaga/common/fixture/PlayerFixture.java index 067007b2b..6645b3387 100644 --- a/backend/src/test/java/com/now/naaga/common/fixture/PlayerFixture.java +++ b/backend/src/test/java/com/now/naaga/common/fixture/PlayerFixture.java @@ -1,6 +1,6 @@ package com.now.naaga.common.fixture; -import static com.now.naaga.common.fixture.MemberFixture.*; +import static com.now.naaga.common.fixture.MemberFixture.MEMBER; import com.now.naaga.player.domain.Player; import com.now.naaga.score.domain.Score; diff --git a/backend/src/test/java/com/now/naaga/common/fixture/PositionFixture.java b/backend/src/test/java/com/now/naaga/common/fixture/PositionFixture.java index e4933af73..075cb2aed 100644 --- a/backend/src/test/java/com/now/naaga/common/fixture/PositionFixture.java +++ b/backend/src/test/java/com/now/naaga/common/fixture/PositionFixture.java @@ -1,7 +1,6 @@ package com.now.naaga.common.fixture; import com.now.naaga.place.domain.Position; - import java.math.BigDecimal; public class PositionFixture { diff --git a/backend/src/test/java/com/now/naaga/common/fixture/ReadLetterLogFixture.java b/backend/src/test/java/com/now/naaga/common/fixture/ReadLetterLogFixture.java index 3397818c3..a33678b03 100644 --- a/backend/src/test/java/com/now/naaga/common/fixture/ReadLetterLogFixture.java +++ b/backend/src/test/java/com/now/naaga/common/fixture/ReadLetterLogFixture.java @@ -1,10 +1,10 @@ package com.now.naaga.common.fixture; -import com.now.naaga.letter.domain.letterlog.ReadLetterLog; - import static com.now.naaga.common.fixture.GameFixture.GAME; import static com.now.naaga.common.fixture.LetterFixture.LETTER; +import com.now.naaga.letter.domain.letterlog.ReadLetterLog; + public class ReadLetterLogFixture { public static ReadLetterLog READ_LETTER_LOG() { diff --git a/backend/src/test/java/com/now/naaga/common/fixture/TemporaryPlaceFixture.java b/backend/src/test/java/com/now/naaga/common/fixture/TemporaryPlaceFixture.java index 906f53597..d00235bc3 100644 --- a/backend/src/test/java/com/now/naaga/common/fixture/TemporaryPlaceFixture.java +++ b/backend/src/test/java/com/now/naaga/common/fixture/TemporaryPlaceFixture.java @@ -1,10 +1,10 @@ package com.now.naaga.common.fixture; -import com.now.naaga.temporaryplace.domain.TemporaryPlace; - import static com.now.naaga.common.fixture.PlayerFixture.PLAYER; import static com.now.naaga.common.fixture.PositionFixture.잠실_루터회관_정문_좌표; +import com.now.naaga.temporaryplace.domain.TemporaryPlace; + public class TemporaryPlaceFixture { public static final String NAME = "temp_place_name"; diff --git a/backend/src/test/java/com/now/naaga/common/fixture/WriteLetterLogFixture.java b/backend/src/test/java/com/now/naaga/common/fixture/WriteLetterLogFixture.java index 7afb388b3..cb1901c62 100644 --- a/backend/src/test/java/com/now/naaga/common/fixture/WriteLetterLogFixture.java +++ b/backend/src/test/java/com/now/naaga/common/fixture/WriteLetterLogFixture.java @@ -1,10 +1,10 @@ package com.now.naaga.common.fixture; -import com.now.naaga.letter.domain.letterlog.WriteLetterLog; - import static com.now.naaga.common.fixture.GameFixture.GAME; import static com.now.naaga.common.fixture.LetterFixture.LETTER; +import com.now.naaga.letter.domain.letterlog.WriteLetterLog; + public class WriteLetterLogFixture { public static WriteLetterLog WRITE_LETTER_LOG() { diff --git a/backend/src/test/java/com/now/naaga/common/presentation/interceptor/RequestMatcherInterceptorTest.java b/backend/src/test/java/com/now/naaga/common/presentation/interceptor/RequestMatcherInterceptorTest.java index 7693dd2cc..9c88dbb0e 100644 --- a/backend/src/test/java/com/now/naaga/common/presentation/interceptor/RequestMatcherInterceptorTest.java +++ b/backend/src/test/java/com/now/naaga/common/presentation/interceptor/RequestMatcherInterceptorTest.java @@ -1,5 +1,11 @@ package com.now.naaga.common.presentation.interceptor; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.springframework.http.HttpMethod.GET; +import static org.springframework.http.HttpMethod.POST; + +import java.util.stream.Stream; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.params.ParameterizedTest; @@ -10,18 +16,9 @@ import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.test.context.ActiveProfiles; -import org.springframework.util.AntPathMatcher; -import org.springframework.util.PathMatcher; import org.springframework.web.servlet.HandlerInterceptor; import org.springframework.web.servlet.mvc.Controller; -import java.util.stream.Stream; - -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.springframework.http.HttpMethod.GET; -import static org.springframework.http.HttpMethod.POST; - @ActiveProfiles("test") @SuppressWarnings("NonAsciiCharacters") @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) diff --git a/backend/src/test/java/com/now/naaga/common/presentation/interceptor/RequestPatternTest.java b/backend/src/test/java/com/now/naaga/common/presentation/interceptor/RequestPatternTest.java index ec66c21a0..5debcc19d 100644 --- a/backend/src/test/java/com/now/naaga/common/presentation/interceptor/RequestPatternTest.java +++ b/backend/src/test/java/com/now/naaga/common/presentation/interceptor/RequestPatternTest.java @@ -1,21 +1,17 @@ package com.now.naaga.common.presentation.interceptor; +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.http.HttpMethod.GET; +import static org.springframework.http.HttpMethod.POST; + +import java.util.stream.Stream; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator; -import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import org.springframework.http.HttpMethod; import org.springframework.test.context.ActiveProfiles; -import org.springframework.util.AntPathMatcher; -import org.springframework.util.PathMatcher; - -import java.util.stream.Stream; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.http.HttpMethod.GET; -import static org.springframework.http.HttpMethod.POST; @ActiveProfiles("test") @SuppressWarnings("NonAsciiCharacters") diff --git a/backend/src/test/java/com/now/naaga/game/application/GameServiceTest.java b/backend/src/test/java/com/now/naaga/game/application/GameServiceTest.java index 7112ba7f2..9281e908c 100644 --- a/backend/src/test/java/com/now/naaga/game/application/GameServiceTest.java +++ b/backend/src/test/java/com/now/naaga/game/application/GameServiceTest.java @@ -1,5 +1,23 @@ package com.now.naaga.game.application; +import static com.now.naaga.common.fixture.PositionFixture.역삼역_좌표; +import static com.now.naaga.common.fixture.PositionFixture.잠실_루터회관_정문_근처_좌표; +import static com.now.naaga.common.fixture.PositionFixture.잠실_루터회관_정문_좌표; +import static com.now.naaga.common.fixture.PositionFixture.잠실역_교보문고_좌표; +import static com.now.naaga.game.domain.EndType.ARRIVED; +import static com.now.naaga.game.domain.EndType.GIVE_UP; +import static com.now.naaga.game.domain.GameStatus.DONE; +import static com.now.naaga.game.domain.GameStatus.IN_PROGRESS; +import static com.now.naaga.game.exception.GameExceptionType.ALREADY_IN_PROGRESS; +import static com.now.naaga.game.exception.GameExceptionType.CAN_NOT_FIND_PLACE; +import static com.now.naaga.game.exception.GameExceptionType.INACCESSIBLE_AUTHENTICATION; +import static com.now.naaga.gameresult.domain.ResultType.FAIL; +import static com.now.naaga.gameresult.domain.ResultType.SUCCESS; +import static com.now.naaga.gameresult.exception.GameResultExceptionType.GAME_RESULT_NOT_EXIST; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.SoftAssertions.assertSoftly; +import static org.junit.jupiter.api.Assertions.assertThrows; + import com.now.naaga.common.builder.GameBuilder; import com.now.naaga.common.builder.GameResultBuilder; import com.now.naaga.common.builder.PlaceBuilder; @@ -10,14 +28,17 @@ import com.now.naaga.game.application.dto.FindGameByStatusCommand; import com.now.naaga.game.domain.Game; import com.now.naaga.game.domain.GameRecord; -import com.now.naaga.game.exception.GameNotFinishedException; -import com.now.naaga.gameresult.domain.GameResult; import com.now.naaga.game.domain.Statistic; import com.now.naaga.game.exception.GameException; +import com.now.naaga.game.exception.GameNotFinishedException; +import com.now.naaga.gameresult.domain.GameResult; import com.now.naaga.gameresult.exception.GameResultException; import com.now.naaga.place.domain.Place; import com.now.naaga.player.domain.Player; import com.now.naaga.player.presentation.dto.PlayerRequest; +import java.time.LocalDateTime; +import java.time.Month; +import java.util.List; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Test; @@ -25,23 +46,6 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.jdbc.Sql; -import java.time.LocalDateTime; -import java.time.Month; -import java.util.List; - -import static com.now.naaga.common.fixture.PositionFixture.*; -import static com.now.naaga.game.domain.EndType.ARRIVED; -import static com.now.naaga.game.domain.EndType.GIVE_UP; -import static com.now.naaga.game.domain.GameStatus.DONE; -import static com.now.naaga.game.domain.GameStatus.IN_PROGRESS; -import static com.now.naaga.gameresult.domain.ResultType.FAIL; -import static com.now.naaga.gameresult.domain.ResultType.SUCCESS; -import static com.now.naaga.game.exception.GameExceptionType.*; -import static com.now.naaga.gameresult.exception.GameResultExceptionType.*; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.SoftAssertions.assertSoftly; -import static org.junit.jupiter.api.Assertions.assertThrows; - @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) @Sql("/truncate.sql") @SpringBootTest diff --git a/backend/src/test/java/com/now/naaga/game/application/HintServiceTest.java b/backend/src/test/java/com/now/naaga/game/application/HintServiceTest.java index f511504c8..351844d2e 100644 --- a/backend/src/test/java/com/now/naaga/game/application/HintServiceTest.java +++ b/backend/src/test/java/com/now/naaga/game/application/HintServiceTest.java @@ -17,7 +17,6 @@ import com.now.naaga.game.domain.Game; import com.now.naaga.game.domain.Hint; import com.now.naaga.game.exception.GameException; -import com.now.naaga.member.domain.Member; import com.now.naaga.place.domain.Place; import java.time.LocalDateTime; import org.junit.jupiter.api.DisplayNameGeneration; diff --git a/backend/src/test/java/com/now/naaga/game/domain/GameTest.java b/backend/src/test/java/com/now/naaga/game/domain/GameTest.java index e89146dc5..38d15db49 100644 --- a/backend/src/test/java/com/now/naaga/game/domain/GameTest.java +++ b/backend/src/test/java/com/now/naaga/game/domain/GameTest.java @@ -1,10 +1,25 @@ package com.now.naaga.game.domain; +import static com.now.naaga.common.fixture.PlaceFixture.PLACE; +import static com.now.naaga.common.fixture.PlayerFixture.PLAYER; +import static com.now.naaga.common.fixture.PositionFixture.GS25_방이도곡점_좌표; +import static com.now.naaga.common.fixture.PositionFixture.던킨도너츠_올림픽공원점_좌표; +import static com.now.naaga.common.fixture.PositionFixture.잠실_루터회관_정문_근처_좌표; +import static com.now.naaga.common.fixture.PositionFixture.잠실_루터회관_정문_좌표; +import static com.now.naaga.game.domain.EndType.ARRIVED; +import static com.now.naaga.game.domain.EndType.GIVE_UP; +import static com.now.naaga.game.domain.Game.MAX_ATTEMPT_COUNT; +import static com.now.naaga.game.domain.GameStatus.DONE; +import static com.now.naaga.game.domain.GameStatus.IN_PROGRESS; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + import com.now.naaga.game.exception.GameException; import com.now.naaga.game.exception.GameNotFinishedException; import com.now.naaga.place.domain.Place; import com.now.naaga.place.domain.Position; import com.now.naaga.player.domain.Player; +import java.time.LocalDateTime; +import java.util.ArrayList; import org.assertj.core.api.SoftAssertions; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator; @@ -13,20 +28,6 @@ import org.junit.jupiter.params.provider.ValueSource; import org.springframework.test.context.ActiveProfiles; -import java.time.LocalDateTime; -import java.util.ArrayList; - -import static com.now.naaga.common.fixture.PlaceFixture.PLACE; -import static com.now.naaga.common.fixture.PlayerFixture.PLAYER; -import static com.now.naaga.common.fixture.PositionFixture.*; -import static com.now.naaga.game.domain.EndType.ARRIVED; -import static com.now.naaga.game.domain.EndType.GIVE_UP; -import static com.now.naaga.game.domain.Game.MAX_ATTEMPT_COUNT; -import static com.now.naaga.game.domain.Game.MAX_HINT_COUNT; -import static com.now.naaga.game.domain.GameStatus.DONE; -import static com.now.naaga.game.domain.GameStatus.IN_PROGRESS; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - @ActiveProfiles("test") @SuppressWarnings("NonAsciiCharacters") @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) diff --git a/backend/src/test/java/com/now/naaga/game/domain/ResultScorePolicyTest.java b/backend/src/test/java/com/now/naaga/game/domain/ResultScorePolicyTest.java index beacce10f..5291cad0c 100644 --- a/backend/src/test/java/com/now/naaga/game/domain/ResultScorePolicyTest.java +++ b/backend/src/test/java/com/now/naaga/game/domain/ResultScorePolicyTest.java @@ -1,23 +1,24 @@ package com.now.naaga.game.domain; +import static com.now.naaga.common.fixture.PlaceFixture.PLACE; +import static com.now.naaga.common.fixture.PlayerFixture.PLAYER; +import static com.now.naaga.common.fixture.PositionFixture.던킨도너츠_올림픽공원점_좌표; +import static com.now.naaga.common.fixture.PositionFixture.잠실_루터회관_정문_좌표; +import static com.now.naaga.common.fixture.PositionFixture.잠실역_교보문고_좌표; +import static com.now.naaga.game.domain.GameStatus.DONE; +import static org.assertj.core.api.Assertions.assertThat; + import com.now.naaga.gameresult.domain.gamescore.ResultScorePolicy; import com.now.naaga.gameresult.domain.gamescore.SuccessResultScorePolicy; import com.now.naaga.player.domain.Player; import com.now.naaga.score.domain.Score; +import java.time.LocalDateTime; +import java.util.List; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Test; import org.springframework.test.context.ActiveProfiles; -import java.time.LocalDateTime; -import java.util.List; - -import static com.now.naaga.common.fixture.PlaceFixture.PLACE; -import static com.now.naaga.common.fixture.PlayerFixture.PLAYER; -import static com.now.naaga.common.fixture.PositionFixture.*; -import static com.now.naaga.game.domain.GameStatus.DONE; -import static org.assertj.core.api.Assertions.assertThat; - @ActiveProfiles("test") @SuppressWarnings("NonAsciiCharacters") @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) diff --git a/backend/src/test/java/com/now/naaga/game/domain/StatisticTest.java b/backend/src/test/java/com/now/naaga/game/domain/StatisticTest.java index 3865c809c..1f1ab2848 100644 --- a/backend/src/test/java/com/now/naaga/game/domain/StatisticTest.java +++ b/backend/src/test/java/com/now/naaga/game/domain/StatisticTest.java @@ -1,28 +1,27 @@ package com.now.naaga.game.domain; +import static com.now.naaga.common.fixture.PlaceFixture.PLACE; +import static com.now.naaga.common.fixture.PlayerFixture.PLAYER; +import static com.now.naaga.common.fixture.PositionFixture.던킨도너츠_올림픽공원점_좌표; +import static com.now.naaga.common.fixture.PositionFixture.잠실_루터회관_정문_좌표; +import static com.now.naaga.game.domain.GameStatus.DONE; +import static com.now.naaga.gameresult.domain.ResultType.SUCCESS; +import static org.assertj.core.api.SoftAssertions.assertSoftly; + import com.now.naaga.gameresult.domain.GameResult; import com.now.naaga.place.domain.Place; import com.now.naaga.place.domain.Position; import com.now.naaga.player.domain.Player; import com.now.naaga.score.domain.Score; -import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; -import org.junit.jupiter.api.Test; -import org.springframework.test.context.ActiveProfiles; - import java.time.Duration; import java.time.LocalDateTime; import java.time.Month; import java.util.ArrayList; import java.util.List; - -import static com.now.naaga.common.fixture.PlaceFixture.PLACE; -import static com.now.naaga.common.fixture.PlayerFixture.PLAYER; -import static com.now.naaga.common.fixture.PositionFixture.던킨도너츠_올림픽공원점_좌표; -import static com.now.naaga.common.fixture.PositionFixture.잠실_루터회관_정문_좌표; -import static com.now.naaga.game.domain.GameStatus.DONE; -import static com.now.naaga.gameresult.domain.ResultType.SUCCESS; -import static org.assertj.core.api.SoftAssertions.assertSoftly; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator; +import org.junit.jupiter.api.Test; +import org.springframework.test.context.ActiveProfiles; @ActiveProfiles("test") @SuppressWarnings("NonAsciiCharacters") diff --git a/backend/src/test/java/com/now/naaga/game/presentation/GameControllerTest.java b/backend/src/test/java/com/now/naaga/game/presentation/GameControllerTest.java index 69744849a..5a1dcd656 100644 --- a/backend/src/test/java/com/now/naaga/game/presentation/GameControllerTest.java +++ b/backend/src/test/java/com/now/naaga/game/presentation/GameControllerTest.java @@ -1,13 +1,46 @@ package com.now.naaga.game.presentation; +import static com.now.naaga.auth.exception.AuthExceptionType.NOT_EXIST_HEADER; +import static com.now.naaga.common.fixture.PositionFixture.서울_좌표; +import static com.now.naaga.common.fixture.PositionFixture.역삼역_좌표; +import static com.now.naaga.common.fixture.PositionFixture.잠실_루터회관_정문_근처_좌표; +import static com.now.naaga.common.fixture.PositionFixture.잠실_루터회관_정문_좌표; +import static com.now.naaga.common.fixture.PositionFixture.잠실역_교보문고_좌표; +import static com.now.naaga.common.fixture.PositionFixture.제주_좌표; +import static com.now.naaga.game.domain.Game.MAX_ATTEMPT_COUNT; +import static com.now.naaga.game.domain.GameStatus.DONE; +import static com.now.naaga.game.domain.GameStatus.IN_PROGRESS; +import static com.now.naaga.game.exception.GameExceptionType.ALREADY_DONE; +import static com.now.naaga.game.exception.GameExceptionType.ALREADY_IN_PROGRESS; +import static com.now.naaga.game.exception.GameExceptionType.CAN_NOT_FIND_PLACE; +import static com.now.naaga.game.exception.GameExceptionType.HINT_NOT_EXIST_IN_GAME; +import static com.now.naaga.game.exception.GameExceptionType.INACCESSIBLE_AUTHENTICATION; +import static com.now.naaga.game.exception.GameExceptionType.NOT_ARRIVED; +import static com.now.naaga.game.exception.GameExceptionType.NOT_EXIST; +import static com.now.naaga.gameresult.domain.ResultType.FAIL; +import static com.now.naaga.gameresult.domain.ResultType.SUCCESS; +import static org.assertj.core.api.SoftAssertions.assertSoftly; + import com.now.naaga.auth.domain.AuthToken; import com.now.naaga.auth.infrastructure.AuthType; import com.now.naaga.auth.infrastructure.jwt.AuthTokenGenerator; import com.now.naaga.common.CommonControllerTest; -import com.now.naaga.common.builder.*; +import com.now.naaga.common.builder.GameBuilder; +import com.now.naaga.common.builder.GameResultBuilder; +import com.now.naaga.common.builder.MemberBuilder; +import com.now.naaga.common.builder.PlaceBuilder; +import com.now.naaga.common.builder.PlayerBuilder; import com.now.naaga.common.exception.ExceptionResponse; -import com.now.naaga.game.domain.*; -import com.now.naaga.game.presentation.dto.*; +import com.now.naaga.game.domain.Direction; +import com.now.naaga.game.domain.Game; +import com.now.naaga.game.domain.GameRecord; +import com.now.naaga.game.domain.Hint; +import com.now.naaga.game.presentation.dto.CoordinateRequest; +import com.now.naaga.game.presentation.dto.EndGameRequest; +import com.now.naaga.game.presentation.dto.GameResponse; +import com.now.naaga.game.presentation.dto.GameResultResponse; +import com.now.naaga.game.presentation.dto.GameStatusResponse; +import com.now.naaga.game.presentation.dto.HintResponse; import com.now.naaga.game.repository.GameRepository; import com.now.naaga.game.repository.HintRepository; import com.now.naaga.gameresult.domain.GameResult; @@ -23,6 +56,9 @@ import io.restassured.http.ContentType; import io.restassured.response.ExtractableResponse; import io.restassured.response.Response; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; @@ -31,20 +67,6 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; - -import static com.now.naaga.auth.exception.AuthExceptionType.NOT_EXIST_HEADER; -import static com.now.naaga.common.fixture.PositionFixture.*; -import static com.now.naaga.game.domain.Game.MAX_ATTEMPT_COUNT; -import static com.now.naaga.game.domain.GameStatus.DONE; -import static com.now.naaga.game.domain.GameStatus.IN_PROGRESS; -import static com.now.naaga.gameresult.domain.ResultType.FAIL; -import static com.now.naaga.gameresult.domain.ResultType.SUCCESS; -import static com.now.naaga.game.exception.GameExceptionType.*; -import static org.assertj.core.api.SoftAssertions.assertSoftly; - @SuppressWarnings("NonAsciiCharacters") @DisplayNameGeneration(ReplaceUnderscores.class) class GameControllerTest extends CommonControllerTest { diff --git a/backend/src/test/java/com/now/naaga/game/presentation/StatisticControllerTest.java b/backend/src/test/java/com/now/naaga/game/presentation/StatisticControllerTest.java index 16d798e76..53808d3ea 100644 --- a/backend/src/test/java/com/now/naaga/game/presentation/StatisticControllerTest.java +++ b/backend/src/test/java/com/now/naaga/game/presentation/StatisticControllerTest.java @@ -1,5 +1,9 @@ package com.now.naaga.game.presentation; +import static com.now.naaga.common.fixture.PositionFixture.잠실_루터회관_정문_좌표; +import static com.now.naaga.common.fixture.PositionFixture.잠실역_교보문고_좌표; +import static org.assertj.core.api.SoftAssertions.assertSoftly; + import com.now.naaga.auth.domain.AuthToken; import com.now.naaga.auth.infrastructure.AuthType; import com.now.naaga.auth.infrastructure.jwt.AuthTokenGenerator; @@ -27,10 +31,6 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; -import static com.now.naaga.common.fixture.PositionFixture.잠실_루터회관_정문_좌표; -import static com.now.naaga.common.fixture.PositionFixture.잠실역_교보문고_좌표; -import static org.assertj.core.api.SoftAssertions.assertSoftly; - @SuppressWarnings("NonAsciiCharacters") @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) public class StatisticControllerTest extends CommonControllerTest { diff --git a/backend/src/test/java/com/now/naaga/gameresult/application/GameResultServiceTest.java b/backend/src/test/java/com/now/naaga/gameresult/application/GameResultServiceTest.java index 5842116a9..cc7aeb026 100644 --- a/backend/src/test/java/com/now/naaga/gameresult/application/GameResultServiceTest.java +++ b/backend/src/test/java/com/now/naaga/gameresult/application/GameResultServiceTest.java @@ -1,5 +1,11 @@ package com.now.naaga.gameresult.application; +import static com.now.naaga.game.domain.EndType.ARRIVED; +import static com.now.naaga.game.domain.GameStatus.DONE; +import static com.now.naaga.game.domain.GameStatus.IN_PROGRESS; +import static com.now.naaga.gameresult.domain.ResultType.SUCCESS; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + import com.now.naaga.common.builder.GameBuilder; import com.now.naaga.common.builder.GameResultBuilder; import com.now.naaga.common.builder.PlaceBuilder; @@ -8,11 +14,11 @@ import com.now.naaga.game.domain.Game; import com.now.naaga.game.exception.GameException; import com.now.naaga.gameresult.domain.GameResult; -import com.now.naaga.gameresult.exception.GameResultException; import com.now.naaga.gameresult.repository.GameResultRepository; import com.now.naaga.place.domain.Position; import com.now.naaga.player.domain.Player; import com.now.naaga.score.domain.Score; +import java.time.LocalDateTime; import org.assertj.core.api.SoftAssertions; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator; @@ -23,14 +29,6 @@ import org.springframework.test.context.jdbc.Sql; import org.springframework.transaction.annotation.Transactional; -import java.time.LocalDateTime; - -import static com.now.naaga.game.domain.EndType.ARRIVED; -import static com.now.naaga.game.domain.GameStatus.DONE; -import static com.now.naaga.game.domain.GameStatus.IN_PROGRESS; -import static com.now.naaga.gameresult.domain.ResultType.SUCCESS; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) @Sql("/truncate.sql") @ActiveProfiles("test") diff --git a/backend/src/test/java/com/now/naaga/gameresult/repository/GameResultRepositoryTest.java b/backend/src/test/java/com/now/naaga/gameresult/repository/GameResultRepositoryTest.java index a0297933a..c4b42d429 100644 --- a/backend/src/test/java/com/now/naaga/gameresult/repository/GameResultRepositoryTest.java +++ b/backend/src/test/java/com/now/naaga/gameresult/repository/GameResultRepositoryTest.java @@ -1,5 +1,11 @@ package com.now.naaga.gameresult.repository; +import static com.now.naaga.common.fixture.PositionFixture.잠실_루터회관_정문_좌표; +import static com.now.naaga.common.fixture.PositionFixture.잠실역_교보문고_좌표; +import static com.now.naaga.game.domain.GameStatus.DONE; +import static com.now.naaga.gameresult.domain.ResultType.SUCCESS; +import static org.assertj.core.api.Assertions.assertThat; + import com.now.naaga.common.builder.GameBuilder; import com.now.naaga.common.builder.GameResultBuilder; import com.now.naaga.common.builder.PlaceBuilder; @@ -8,6 +14,7 @@ import com.now.naaga.gameresult.domain.GameResult; import com.now.naaga.place.domain.Place; import com.now.naaga.player.domain.Player; +import java.util.List; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Test; @@ -15,14 +22,6 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.jdbc.Sql; -import java.util.List; - -import static com.now.naaga.common.fixture.PositionFixture.잠실_루터회관_정문_좌표; -import static com.now.naaga.common.fixture.PositionFixture.잠실역_교보문고_좌표; -import static com.now.naaga.game.domain.GameStatus.DONE; -import static com.now.naaga.gameresult.domain.ResultType.SUCCESS; -import static org.assertj.core.api.Assertions.assertThat; - @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) @Sql("/truncate.sql") @SpringBootTest diff --git a/backend/src/test/java/com/now/naaga/letter/application/LetterServiceTest.java b/backend/src/test/java/com/now/naaga/letter/application/LetterServiceTest.java index f0db17471..27bf88d7f 100644 --- a/backend/src/test/java/com/now/naaga/letter/application/LetterServiceTest.java +++ b/backend/src/test/java/com/now/naaga/letter/application/LetterServiceTest.java @@ -1,5 +1,14 @@ package com.now.naaga.letter.application; +import static com.now.naaga.common.fixture.PositionFixture.잠실_루터회관_정문_좌표; +import static com.now.naaga.common.fixture.PositionFixture.잠실역_교보문고_110미터_앞_좌표; +import static com.now.naaga.common.fixture.PositionFixture.잠실역_교보문고_좌표; +import static com.now.naaga.letter.exception.LetterExceptionType.NO_EXIST; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.assertj.core.api.SoftAssertions.assertSoftly; +import static org.junit.jupiter.api.Assertions.assertThrows; + import com.now.naaga.common.builder.GameBuilder; import com.now.naaga.common.builder.LetterBuilder; import com.now.naaga.common.builder.PlaceBuilder; @@ -17,6 +26,7 @@ import com.now.naaga.place.domain.Place; import com.now.naaga.place.domain.Position; import com.now.naaga.player.domain.Player; +import java.util.List; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator; @@ -27,15 +37,6 @@ import org.springframework.test.context.jdbc.Sql; import org.springframework.transaction.annotation.Transactional; -import java.util.List; - -import static com.now.naaga.common.fixture.PositionFixture.*; -import static com.now.naaga.letter.exception.LetterExceptionType.NO_EXIST; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.assertj.core.api.SoftAssertions.assertSoftly; -import static org.junit.jupiter.api.Assertions.assertThrows; - @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) @ActiveProfiles("test") @Sql("/truncate.sql") diff --git a/backend/src/test/java/com/now/naaga/letter/application/letterlog/ReadLetterLogServiceTest.java b/backend/src/test/java/com/now/naaga/letter/application/letterlog/ReadLetterLogServiceTest.java index 3c4639c67..4ddc644ef 100644 --- a/backend/src/test/java/com/now/naaga/letter/application/letterlog/ReadLetterLogServiceTest.java +++ b/backend/src/test/java/com/now/naaga/letter/application/letterlog/ReadLetterLogServiceTest.java @@ -1,5 +1,12 @@ package com.now.naaga.letter.application.letterlog; +import static com.now.naaga.common.fixture.PositionFixture.잠실_루터회관_정문_좌표; +import static com.now.naaga.common.fixture.PositionFixture.잠실역_교보문고_좌표; +import static com.now.naaga.game.exception.GameExceptionType.NOT_EXIST_IN_PROGRESS; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.SoftAssertions.assertSoftly; +import static org.junit.jupiter.api.Assertions.assertThrows; + import com.now.naaga.common.builder.GameBuilder; import com.now.naaga.common.builder.LetterBuilder; import com.now.naaga.common.builder.PlaceBuilder; @@ -13,6 +20,7 @@ import com.now.naaga.letter.repository.letterlog.ReadLetterLogRepository; import com.now.naaga.place.domain.Place; import com.now.naaga.player.domain.Player; +import java.util.List; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Test; @@ -20,15 +28,6 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.jdbc.Sql; -import java.util.List; - -import static com.now.naaga.common.fixture.PositionFixture.잠실_루터회관_정문_좌표; -import static com.now.naaga.common.fixture.PositionFixture.잠실역_교보문고_좌표; -import static com.now.naaga.game.exception.GameExceptionType.NOT_EXIST_IN_PROGRESS; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.SoftAssertions.assertSoftly; -import static org.junit.jupiter.api.Assertions.assertThrows; - @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) @Sql("/truncate.sql") @SpringBootTest diff --git a/backend/src/test/java/com/now/naaga/letter/presentation/LetterControllerTest.java b/backend/src/test/java/com/now/naaga/letter/presentation/LetterControllerTest.java index 3caa55b06..10326043a 100644 --- a/backend/src/test/java/com/now/naaga/letter/presentation/LetterControllerTest.java +++ b/backend/src/test/java/com/now/naaga/letter/presentation/LetterControllerTest.java @@ -1,5 +1,13 @@ package com.now.naaga.letter.presentation; +import static com.now.naaga.common.fixture.PositionFixture.잠실_루터회관_정문_좌표; +import static com.now.naaga.common.fixture.PositionFixture.잠실역_교보문고_110미터_앞_좌표; +import static com.now.naaga.common.fixture.PositionFixture.잠실역_교보문고_좌표; +import static com.now.naaga.game.domain.GameStatus.DONE; +import static com.now.naaga.game.exception.GameExceptionType.NOT_EXIST_IN_PROGRESS; +import static com.now.naaga.player.exception.PlayerExceptionType.PLAYER_NOT_FOUND; +import static org.assertj.core.api.SoftAssertions.assertSoftly; + import com.now.naaga.auth.domain.AuthToken; import com.now.naaga.auth.infrastructure.AuthType; import com.now.naaga.auth.infrastructure.jwt.AuthTokenGenerator; @@ -28,6 +36,8 @@ import io.restassured.parsing.Parser; import io.restassured.response.ExtractableResponse; import io.restassured.response.Response; +import java.time.LocalDateTime; +import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator; @@ -35,16 +45,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; -import org.springframework.test.context.ActiveProfiles; - -import java.time.LocalDateTime; -import java.util.List; - -import static com.now.naaga.common.fixture.PositionFixture.*; -import static com.now.naaga.game.domain.GameStatus.DONE; -import static com.now.naaga.game.exception.GameExceptionType.NOT_EXIST_IN_PROGRESS; -import static com.now.naaga.player.exception.PlayerExceptionType.PLAYER_NOT_FOUND; -import static org.assertj.core.api.SoftAssertions.assertSoftly; @SuppressWarnings("NonAsciiCharacters") @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) diff --git a/backend/src/test/java/com/now/naaga/letter/presentation/LetterLogControllerTest.java b/backend/src/test/java/com/now/naaga/letter/presentation/LetterLogControllerTest.java index 37a98b142..350dfa22e 100644 --- a/backend/src/test/java/com/now/naaga/letter/presentation/LetterLogControllerTest.java +++ b/backend/src/test/java/com/now/naaga/letter/presentation/LetterLogControllerTest.java @@ -1,10 +1,21 @@ package com.now.naaga.letter.presentation; +import static com.now.naaga.common.exception.CommonExceptionType.INVALID_REQUEST_PARAMETERS; +import static com.now.naaga.common.fixture.PositionFixture.GS25_방이도곡점_좌표; +import static com.now.naaga.common.fixture.PositionFixture.역삼역_좌표; +import static com.now.naaga.common.fixture.PositionFixture.잠실_루터회관_정문_좌표; +import static org.assertj.core.api.SoftAssertions.assertSoftly; + import com.now.naaga.auth.domain.AuthToken; import com.now.naaga.auth.infrastructure.AuthType; import com.now.naaga.auth.infrastructure.jwt.AuthTokenGenerator; import com.now.naaga.common.CommonControllerTest; -import com.now.naaga.common.builder.*; +import com.now.naaga.common.builder.GameBuilder; +import com.now.naaga.common.builder.LetterBuilder; +import com.now.naaga.common.builder.PlaceBuilder; +import com.now.naaga.common.builder.PlayerBuilder; +import com.now.naaga.common.builder.ReadLetterLogBuilder; +import com.now.naaga.common.builder.WriteLetterLogBuilder; import com.now.naaga.common.exception.ExceptionResponse; import com.now.naaga.game.domain.Game; import com.now.naaga.letter.domain.Letter; @@ -18,6 +29,8 @@ import io.restassured.common.mapper.TypeRef; import io.restassured.response.ExtractableResponse; import io.restassured.response.Response; +import java.time.LocalDateTime; +import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator; @@ -25,13 +38,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; -import java.time.LocalDateTime; -import java.util.List; - -import static com.now.naaga.common.exception.CommonExceptionType.INVALID_REQUEST_PARAMETERS; -import static com.now.naaga.common.fixture.PositionFixture.*; -import static org.assertj.core.api.SoftAssertions.assertSoftly; - @SuppressWarnings("NonAsciiCharacters") @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) class LetterLogControllerTest extends CommonControllerTest { diff --git a/backend/src/test/java/com/now/naaga/like/application/PlaceLikeServiceTest.java b/backend/src/test/java/com/now/naaga/like/application/PlaceLikeServiceTest.java index b9080a24c..f7266a748 100644 --- a/backend/src/test/java/com/now/naaga/like/application/PlaceLikeServiceTest.java +++ b/backend/src/test/java/com/now/naaga/like/application/PlaceLikeServiceTest.java @@ -21,8 +21,8 @@ import com.now.naaga.like.exception.PlaceLikeExceptionType; import com.now.naaga.like.repository.PlaceLikeRepository; import com.now.naaga.place.domain.Place; -import com.now.naaga.placestatistics.domain.PlaceStatistics; -import com.now.naaga.placestatistics.repository.PlaceStatisticsRepository; +import com.now.naaga.place.domain.PlaceStatistics; +import com.now.naaga.place.repository.PlaceStatisticsRepository; import com.now.naaga.player.domain.Player; import java.util.Optional; import org.assertj.core.api.SoftAssertions; diff --git a/backend/src/test/java/com/now/naaga/like/domain/PlaceLikeTest.java b/backend/src/test/java/com/now/naaga/like/domain/PlaceLikeTest.java index bdd541813..d92a62d89 100644 --- a/backend/src/test/java/com/now/naaga/like/domain/PlaceLikeTest.java +++ b/backend/src/test/java/com/now/naaga/like/domain/PlaceLikeTest.java @@ -1,5 +1,9 @@ package com.now.naaga.like.domain; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.SoftAssertions.assertSoftly; +import static org.junit.jupiter.api.Assertions.assertThrows; + import com.now.naaga.common.exception.BaseExceptionType; import com.now.naaga.common.fixture.PlaceLikeFixture; import com.now.naaga.like.exception.PlaceLikeException; @@ -12,10 +16,6 @@ import org.junit.jupiter.api.Test; import org.springframework.test.context.ActiveProfiles; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.SoftAssertions.assertSoftly; -import static org.junit.jupiter.api.Assertions.assertThrows; - @ActiveProfiles("test") @SuppressWarnings("NonAsciiCharacters") @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) diff --git a/backend/src/test/java/com/now/naaga/like/presentation/PlaceLikeControllerTest.java b/backend/src/test/java/com/now/naaga/like/presentation/PlaceLikeControllerTest.java index 4bb4bb627..88fd6c672 100644 --- a/backend/src/test/java/com/now/naaga/like/presentation/PlaceLikeControllerTest.java +++ b/backend/src/test/java/com/now/naaga/like/presentation/PlaceLikeControllerTest.java @@ -25,8 +25,8 @@ import com.now.naaga.like.presentation.dto.PlaceLikeResponse; import com.now.naaga.member.domain.Member; import com.now.naaga.place.domain.Place; -import com.now.naaga.placestatistics.domain.PlaceStatistics; -import com.now.naaga.placestatistics.exception.PlaceStatisticsExceptionType; +import com.now.naaga.place.domain.PlaceStatistics; +import com.now.naaga.place.exception.PlaceStatisticsExceptionType; import com.now.naaga.player.domain.Player; import io.restassured.RestAssured; import io.restassured.http.ContentType; @@ -40,6 +40,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; + @SuppressWarnings("NonAsciiCharacters") @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) class PlaceLikeControllerTest extends CommonControllerTest { @@ -269,8 +270,8 @@ void setup() { //given final Long expected = 123L; final PlaceStatistics placeStatistics = placeStatisticsBuilder.init() - .likeCount(expected) - .build(); + .likeCount(expected) + .build(); final Long placeId = placeStatistics.getPlace().getId(); //when diff --git a/backend/src/test/java/com/now/naaga/place/application/PlaceServiceTest.java b/backend/src/test/java/com/now/naaga/place/application/PlaceServiceTest.java index 0e31d4f98..567119b22 100644 --- a/backend/src/test/java/com/now/naaga/place/application/PlaceServiceTest.java +++ b/backend/src/test/java/com/now/naaga/place/application/PlaceServiceTest.java @@ -2,20 +2,18 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.SoftAssertions.assertSoftly; -import static org.junit.jupiter.api.Assertions.assertThrows; -import com.now.naaga.common.builder.PlaceBuilder; import com.now.naaga.common.builder.PlayerBuilder; import com.now.naaga.common.builder.TemporaryPlaceBuilder; -import com.now.naaga.common.exception.BaseExceptionType; import com.now.naaga.place.application.dto.CreatePlaceCommand; import com.now.naaga.place.domain.Place; +import com.now.naaga.place.domain.PlaceStatistics; import com.now.naaga.place.domain.Position; -import com.now.naaga.place.exception.PlaceException; -import com.now.naaga.place.exception.PlaceExceptionType; +import com.now.naaga.place.repository.PlaceStatisticsRepository; import com.now.naaga.player.domain.Player; import com.now.naaga.temporaryplace.domain.TemporaryPlace; import com.now.naaga.temporaryplace.repository.TemporaryPlaceRepository; +import java.util.Optional; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.Test; @@ -36,13 +34,13 @@ class PlaceServiceTest { private TemporaryPlaceRepository temporaryPlaceRepository; @Autowired - private PlaceService placeService; + private PlaceStatisticsRepository placeStatisticsRepository; @Autowired - private TemporaryPlaceBuilder temporaryPlaceBuilder; + private PlaceService placeService; @Autowired - private PlaceBuilder placeBuilder; + private TemporaryPlaceBuilder temporaryPlaceBuilder; @Autowired private PlayerBuilder playerBuilder; @@ -86,4 +84,30 @@ class PlaceServiceTest { assertThat(found).isNull(); }); } + + @Test + void 장소_등록_시_장소_통계도_함께_등록된다() { + // given + final Player player = playerBuilder.init() + .build(); + + final TemporaryPlace temporaryPlace = temporaryPlaceBuilder.init() + .build(); + + final Long temporaryPlaceId = temporaryPlace.getId(); + + final CreatePlaceCommand createPlaceCommand = new CreatePlaceCommand("루터회관", + "이곳은 루터회관이다 알겠냐", + Position.of(1.23, 4.56), + "image/url", + player.getId(), + temporaryPlaceId); + + // when + final Place place = placeService.createPlace(createPlaceCommand); + + // then + final Optional placeStatistics = placeStatisticsRepository.findByPlaceId(place.getId()); + assertThat(placeStatistics).isNotEmpty(); + } } diff --git a/backend/src/test/java/com/now/naaga/placestatistics/application/PlaceStatisticsServiceTest.java b/backend/src/test/java/com/now/naaga/place/application/PlaceStatisticsServiceTest.java similarity index 68% rename from backend/src/test/java/com/now/naaga/placestatistics/application/PlaceStatisticsServiceTest.java rename to backend/src/test/java/com/now/naaga/place/application/PlaceStatisticsServiceTest.java index 9843b8a3f..c9e8b5692 100644 --- a/backend/src/test/java/com/now/naaga/placestatistics/application/PlaceStatisticsServiceTest.java +++ b/backend/src/test/java/com/now/naaga/place/application/PlaceStatisticsServiceTest.java @@ -1,23 +1,25 @@ -package com.now.naaga.placestatistics.application; +package com.now.naaga.place.application; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertAll; import static org.junit.jupiter.api.Assertions.assertThrows; +import com.now.naaga.common.builder.PlaceBuilder; import com.now.naaga.common.builder.PlaceStatisticsBuilder; import com.now.naaga.common.exception.BaseExceptionType; +import com.now.naaga.place.application.dto.CreatePlaceStatisticsCommand; +import com.now.naaga.place.application.dto.FindPlaceStatisticsByPlaceIdCommand; +import com.now.naaga.place.application.dto.PlusLikeCommand; +import com.now.naaga.place.application.dto.SubtractLikeCommand; import com.now.naaga.place.domain.Place; +import com.now.naaga.place.domain.PlaceStatistics; import com.now.naaga.place.exception.PlaceException; import com.now.naaga.place.exception.PlaceExceptionType; -import com.now.naaga.placestatistics.application.dto.FindPlaceStatisticsByPlaceIdCommand; -import com.now.naaga.placestatistics.application.dto.PlusLikeCommand; -import com.now.naaga.placestatistics.application.dto.SubtractLikeCommand; -import com.now.naaga.placestatistics.domain.PlaceStatistics; -import com.now.naaga.placestatistics.exception.PlaceStatisticsException; -import com.now.naaga.placestatistics.exception.PlaceStatisticsExceptionType; -import com.now.naaga.placestatistics.repository.PlaceStatisticsRepository; +import com.now.naaga.place.exception.PlaceStatisticsException; +import com.now.naaga.place.exception.PlaceStatisticsExceptionType; +import com.now.naaga.place.repository.PlaceStatisticsRepository; import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; +import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -26,25 +28,40 @@ import org.springframework.transaction.annotation.Transactional; @SuppressWarnings("NonAsciiCharacters") -@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) +@DisplayNameGeneration(ReplaceUnderscores.class) @Sql("/truncate.sql") @ActiveProfiles("test") @SpringBootTest class PlaceStatisticsServiceTest { - PlaceStatisticsService placeStatisticsService; + @Autowired + private PlaceStatisticsRepository placeStatisticsRepository; - PlaceStatisticsBuilder placeStatisticsBuilder; + @Autowired + private PlaceStatisticsService placeStatisticsService; - PlaceStatisticsRepository placeStatisticsRepository; + @Autowired + private PlaceStatisticsBuilder placeStatisticsBuilder; @Autowired - public PlaceStatisticsServiceTest(final PlaceStatisticsService placeStatisticsService, - final PlaceStatisticsBuilder placeStatisticsBuilder, - final PlaceStatisticsRepository placeStatisticsRepository) { - this.placeStatisticsService = placeStatisticsService; - this.placeStatisticsBuilder = placeStatisticsBuilder; - this.placeStatisticsRepository = placeStatisticsRepository; + private PlaceBuilder placeBuilder; + + @Transactional + @Test + void 장소통계를_생성한다() { + // given + final Place place = placeBuilder.init() + .build(); + + // when + final CreatePlaceStatisticsCommand command = new CreatePlaceStatisticsCommand(place.getId()); + final PlaceStatistics actual = placeStatisticsService.createPlaceStatistics(command); + + // then + final PlaceStatistics expected = new PlaceStatistics(place, PlaceStatistics.LIKE_COUNT_DEFAULT_VALUE); + assertThat(actual).usingRecursiveComparison() + .ignoringExpectedNullFields() + .isEqualTo(expected); } @Test @@ -83,8 +100,8 @@ public PlaceStatisticsServiceTest(final PlaceStatisticsService placeStatisticsSe //given final long beforeLikeCount = 10L; final PlaceStatistics placeStatistics = placeStatisticsBuilder.init() - .likeCount(beforeLikeCount) - .build(); + .likeCount(beforeLikeCount) + .build(); final Place place = placeStatistics.getPlace(); //when @@ -101,8 +118,8 @@ public PlaceStatisticsServiceTest(final PlaceStatisticsService placeStatisticsSe void 장소통계를_장소아이디로_조회한다() { // given final PlaceStatistics expected = placeStatisticsBuilder.init() - .likeCount(123L) - .build(); + .likeCount(123L) + .build(); // when final Long placeId = expected.getPlace().getId(); diff --git a/backend/src/test/java/com/now/naaga/placestatistics/domain/PlaceStatisticsTest.java b/backend/src/test/java/com/now/naaga/place/domain/PlaceStatisticsTest.java similarity index 93% rename from backend/src/test/java/com/now/naaga/placestatistics/domain/PlaceStatisticsTest.java rename to backend/src/test/java/com/now/naaga/place/domain/PlaceStatisticsTest.java index 80be10257..59dd74f95 100644 --- a/backend/src/test/java/com/now/naaga/placestatistics/domain/PlaceStatisticsTest.java +++ b/backend/src/test/java/com/now/naaga/place/domain/PlaceStatisticsTest.java @@ -1,14 +1,13 @@ -package com.now.naaga.placestatistics.domain; +package com.now.naaga.place.domain; + +import static org.assertj.core.api.Assertions.assertThat; import com.now.naaga.common.fixture.PlaceFixture; -import com.now.naaga.place.domain.Place; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Test; import org.springframework.test.context.ActiveProfiles; -import static org.assertj.core.api.Assertions.assertThat; - @SuppressWarnings("NonAsciiCharacters") @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) @ActiveProfiles("test") diff --git a/backend/src/test/java/com/now/naaga/place/service/PlaceServiceTest.java b/backend/src/test/java/com/now/naaga/place/service/PlaceServiceTest.java index 75fa82586..c2e3f225d 100644 --- a/backend/src/test/java/com/now/naaga/place/service/PlaceServiceTest.java +++ b/backend/src/test/java/com/now/naaga/place/service/PlaceServiceTest.java @@ -1,5 +1,9 @@ package com.now.naaga.place.service; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.SoftAssertions.assertSoftly; +import static org.junit.jupiter.api.Assertions.assertThrows; + import com.now.naaga.common.builder.PlaceBuilder; import com.now.naaga.common.exception.BaseExceptionType; import com.now.naaga.common.fixture.PositionFixture; @@ -9,8 +13,6 @@ import com.now.naaga.place.domain.Position; import com.now.naaga.place.exception.PlaceException; import com.now.naaga.place.exception.PlaceExceptionType; -import io.restassured.internal.common.assertion.Assertion; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -19,11 +21,6 @@ import org.springframework.test.context.jdbc.Sql; import org.springframework.transaction.annotation.Transactional; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.assertj.core.api.SoftAssertions.assertSoftly; -import static org.junit.jupiter.api.Assertions.assertThrows; - @ActiveProfiles("test") @Sql("/truncate.sql") @SpringBootTest diff --git a/backend/src/test/java/com/now/naaga/player/application/PlayerServiceTest.java b/backend/src/test/java/com/now/naaga/player/application/PlayerServiceTest.java index 593aa8b2b..c5a24b2e8 100644 --- a/backend/src/test/java/com/now/naaga/player/application/PlayerServiceTest.java +++ b/backend/src/test/java/com/now/naaga/player/application/PlayerServiceTest.java @@ -14,8 +14,6 @@ import com.now.naaga.score.domain.Score; import java.util.ArrayList; import java.util.List; - -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator; diff --git a/backend/src/test/java/com/now/naaga/player/persistence/repository/PlayerRepositoryTest.java b/backend/src/test/java/com/now/naaga/player/persistence/repository/PlayerRepositoryTest.java index 6f554ce97..e977ebffa 100644 --- a/backend/src/test/java/com/now/naaga/player/persistence/repository/PlayerRepositoryTest.java +++ b/backend/src/test/java/com/now/naaga/player/persistence/repository/PlayerRepositoryTest.java @@ -5,13 +5,11 @@ import com.now.naaga.common.builder.PlayerBuilder; import com.now.naaga.player.domain.Player; import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.jdbc.Sql; -import org.springframework.transaction.annotation.Transactional; @SuppressWarnings("NonAsciiCharacters") @DisplayNameGeneration(ReplaceUnderscores.class) diff --git a/backend/src/test/java/com/now/naaga/player/presentation/PlayerControllerTest.java b/backend/src/test/java/com/now/naaga/player/presentation/PlayerControllerTest.java index 26a0ea32e..327c177a5 100644 --- a/backend/src/test/java/com/now/naaga/player/presentation/PlayerControllerTest.java +++ b/backend/src/test/java/com/now/naaga/player/presentation/PlayerControllerTest.java @@ -1,5 +1,9 @@ package com.now.naaga.player.presentation; +import static com.now.naaga.common.exception.CommonExceptionType.INVALID_REQUEST_PARAMETERS; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.SoftAssertions.assertSoftly; + import com.now.naaga.auth.domain.AuthToken; import com.now.naaga.auth.infrastructure.AuthType; import com.now.naaga.auth.infrastructure.jwt.AuthTokenGenerator; @@ -13,6 +17,8 @@ import io.restassured.common.mapper.TypeRef; import io.restassured.response.ExtractableResponse; import io.restassured.response.Response; +import java.time.LocalDateTime; +import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; @@ -21,13 +27,6 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; -import java.time.LocalDateTime; -import java.util.List; - -import static com.now.naaga.common.exception.CommonExceptionType.INVALID_REQUEST_PARAMETERS; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.SoftAssertions.assertSoftly; - @SuppressWarnings("NonAsciiCharacters") @DisplayNameGeneration(ReplaceUnderscores.class) public class PlayerControllerTest extends CommonControllerTest { diff --git a/backend/src/test/java/com/now/naaga/temporaryplace/presentation/TemporaryPlaceControllerTest.java b/backend/src/test/java/com/now/naaga/temporaryplace/presentation/TemporaryPlaceControllerTest.java index cfb51f20b..33182956a 100644 --- a/backend/src/test/java/com/now/naaga/temporaryplace/presentation/TemporaryPlaceControllerTest.java +++ b/backend/src/test/java/com/now/naaga/temporaryplace/presentation/TemporaryPlaceControllerTest.java @@ -1,5 +1,12 @@ package com.now.naaga.temporaryplace.presentation; +import static com.now.naaga.common.fixture.TemporaryPlaceFixture.TEMPORARY_PLACE; +import static io.restassured.RestAssured.given; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.SoftAssertions.assertSoftly; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doReturn; + import com.fasterxml.jackson.core.JsonProcessingException; import com.now.naaga.auth.domain.AuthToken; import com.now.naaga.auth.infrastructure.AuthType; @@ -17,6 +24,12 @@ import io.restassured.common.mapper.TypeRef; import io.restassured.response.ExtractableResponse; import io.restassured.response.Response; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.math.RoundingMode; +import java.nio.charset.StandardCharsets; +import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; @@ -28,20 +41,6 @@ import org.springframework.test.context.ActiveProfiles; import org.springframework.web.multipart.MultipartFile; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.math.RoundingMode; -import java.nio.charset.StandardCharsets; -import java.util.List; - -import static com.now.naaga.common.fixture.TemporaryPlaceFixture.TEMPORARY_PLACE; -import static io.restassured.RestAssured.given; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.SoftAssertions.assertSoftly; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doReturn; - @SuppressWarnings("NonAsciiCharacters") @DisplayNameGeneration(ReplaceUnderscores.class) @ActiveProfiles("test")