diff --git a/backend/src/main/java/com/twtw/backend/aspect/DistributedLockAspect.java b/backend/src/main/java/com/twtw/backend/aspect/DistributedLockAspect.java index d848aab5..1600ef83 100644 --- a/backend/src/main/java/com/twtw/backend/aspect/DistributedLockAspect.java +++ b/backend/src/main/java/com/twtw/backend/aspect/DistributedLockAspect.java @@ -2,8 +2,10 @@ import com.twtw.backend.global.lock.DistributedLock; import com.twtw.backend.utils.SpringELParser; + import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; + import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; @@ -36,9 +38,9 @@ public Object lock(final ProceedingJoinPoint joinPoint) throws Throwable { String key = REDISSON_LOCK_PREFIX + springELParser.getDynamicValue( - signature.getParameterNames(), - joinPoint.getArgs(), - distributedLock.name()); + signature.getParameterNames(), + joinPoint.getArgs(), + distributedLock.name()); RLock rLock = redissonClient.getLock(key); try { diff --git a/backend/src/main/java/com/twtw/backend/config/firebase/FcmConfig.java b/backend/src/main/java/com/twtw/backend/config/firebase/FcmConfig.java index 282a6f85..fae04fdb 100644 --- a/backend/src/main/java/com/twtw/backend/config/firebase/FcmConfig.java +++ b/backend/src/main/java/com/twtw/backend/config/firebase/FcmConfig.java @@ -6,8 +6,10 @@ import com.google.firebase.FirebaseOptions; import com.google.firebase.messaging.FirebaseMessaging; import com.twtw.backend.global.properties.FirebaseProperties; + import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; + import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -20,9 +22,12 @@ public class FcmConfig { @Bean public FirebaseApp firebaseApp() { - final FirebaseOptions options = new FirebaseOptions.Builder() - .setCredentials(GoogleCredentials.create(new AccessToken(firebaseProperties.getKey(), null))) - .build(); + final FirebaseOptions options = + new FirebaseOptions.Builder() + .setCredentials( + GoogleCredentials.create( + new AccessToken(firebaseProperties.getKey(), null))) + .build(); if (FirebaseApp.getApps().isEmpty()) { return FirebaseApp.initializeApp(options); diff --git a/backend/src/main/java/com/twtw/backend/config/rabbitmq/RabbitMQConfig.java b/backend/src/main/java/com/twtw/backend/config/rabbitmq/RabbitMQConfig.java index 0cfc5360..4704bd5e 100644 --- a/backend/src/main/java/com/twtw/backend/config/rabbitmq/RabbitMQConfig.java +++ b/backend/src/main/java/com/twtw/backend/config/rabbitmq/RabbitMQConfig.java @@ -3,7 +3,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.twtw.backend.global.constant.RabbitMQConstant; import com.twtw.backend.global.properties.RabbitMQProperties; + import lombok.RequiredArgsConstructor; + import org.springframework.amqp.core.Binding; import org.springframework.amqp.core.BindingBuilder; import org.springframework.amqp.core.Queue; diff --git a/backend/src/main/java/com/twtw/backend/config/redis/RedisConfig.java b/backend/src/main/java/com/twtw/backend/config/redis/RedisConfig.java index b2ac8cd5..6383d6d6 100644 --- a/backend/src/main/java/com/twtw/backend/config/redis/RedisConfig.java +++ b/backend/src/main/java/com/twtw/backend/config/redis/RedisConfig.java @@ -1,7 +1,9 @@ package com.twtw.backend.config.redis; import com.twtw.backend.global.properties.RedisProperties; + import lombok.RequiredArgsConstructor; + import org.redisson.Redisson; import org.redisson.api.RedissonClient; import org.redisson.config.Config; diff --git a/backend/src/main/java/com/twtw/backend/config/socket/StompConfig.java b/backend/src/main/java/com/twtw/backend/config/socket/StompConfig.java index 02cf6eb7..b8c03e7c 100644 --- a/backend/src/main/java/com/twtw/backend/config/socket/StompConfig.java +++ b/backend/src/main/java/com/twtw/backend/config/socket/StompConfig.java @@ -1,7 +1,9 @@ package com.twtw.backend.config.socket; import com.twtw.backend.global.properties.RabbitMQProperties; + import lombok.RequiredArgsConstructor; + import org.springframework.context.annotation.Configuration; import org.springframework.messaging.simp.config.MessageBrokerRegistry; import org.springframework.util.AntPathMatcher; diff --git a/backend/src/main/java/com/twtw/backend/config/web/WebConfig.java b/backend/src/main/java/com/twtw/backend/config/web/WebConfig.java index 8540816b..5991c74a 100644 --- a/backend/src/main/java/com/twtw/backend/config/web/WebConfig.java +++ b/backend/src/main/java/com/twtw/backend/config/web/WebConfig.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; + import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; diff --git a/backend/src/main/java/com/twtw/backend/domain/friend/repository/FriendQueryRepositoryImpl.java b/backend/src/main/java/com/twtw/backend/domain/friend/repository/FriendQueryRepositoryImpl.java index bf032f27..dbd96856 100644 --- a/backend/src/main/java/com/twtw/backend/domain/friend/repository/FriendQueryRepositoryImpl.java +++ b/backend/src/main/java/com/twtw/backend/domain/friend/repository/FriendQueryRepositoryImpl.java @@ -1,19 +1,22 @@ package com.twtw.backend.domain.friend.repository; +import static com.twtw.backend.domain.friend.entity.QFriend.friend; + import com.querydsl.jpa.impl.JPAQueryFactory; import com.twtw.backend.domain.friend.entity.Friend; import com.twtw.backend.domain.friend.entity.FriendStatus; import com.twtw.backend.domain.member.entity.Member; + import jakarta.persistence.LockModeType; + import lombok.RequiredArgsConstructor; + import org.springframework.stereotype.Repository; import java.util.List; import java.util.Optional; import java.util.UUID; -import static com.twtw.backend.domain.friend.entity.QFriend.friend; - @Repository @RequiredArgsConstructor public class FriendQueryRepositoryImpl implements FriendQueryRepository { @@ -85,21 +88,23 @@ public List findByMemberAndMemberNickname(final Member member, final Str @Override public boolean existsByTwoMemberId(final UUID loginMemberId, final UUID memberId) { return Optional.ofNullable( - jpaQueryFactory - .selectFrom(friend) - .setLockMode(LockModeType.PESSIMISTIC_READ) - .setHint("javax.persistence.lock.timeout", 3) - .where( - (friend.toMember - .id - .eq(loginMemberId) - .and(friend.fromMember.id.eq(memberId)) - .or( - friend.fromMember - .id - .eq(loginMemberId) - .and(friend.toMember.id.eq(memberId))))) - .fetchFirst()) + jpaQueryFactory + .selectFrom(friend) + .setLockMode(LockModeType.PESSIMISTIC_READ) + .setHint("javax.persistence.lock.timeout", 3) + .where( + (friend.toMember + .id + .eq(loginMemberId) + .and(friend.fromMember.id.eq(memberId)) + .or( + friend.fromMember + .id + .eq(loginMemberId) + .and( + friend.toMember.id.eq( + memberId))))) + .fetchFirst()) .isPresent(); } } diff --git a/backend/src/main/java/com/twtw/backend/domain/friend/service/FriendService.java b/backend/src/main/java/com/twtw/backend/domain/friend/service/FriendService.java index c777623a..d363dcbb 100644 --- a/backend/src/main/java/com/twtw/backend/domain/friend/service/FriendService.java +++ b/backend/src/main/java/com/twtw/backend/domain/friend/service/FriendService.java @@ -16,7 +16,9 @@ import com.twtw.backend.global.constant.NotificationTitle; import com.twtw.backend.global.exception.EntityNotFoundException; import com.twtw.backend.global.lock.DistributedLock; + import lombok.RequiredArgsConstructor; + import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; @@ -116,7 +118,8 @@ private List getFriendResponses() { @CacheEvict( value = "getFriendsByStatusWithCache", - key = "'getFriendsWithCache'.concat(#root.target.getMemberIdValue()).concat(#friendStatus.name())", + key = + "'getFriendsWithCache'.concat(#root.target.getMemberIdValue()).concat(#friendStatus.name())", cacheManager = "cacheManager") @Transactional(readOnly = true) public List getFriendsByStatus(final FriendStatus friendStatus) { @@ -125,7 +128,8 @@ public List getFriendsByStatus(final FriendStatus friendStatus) @Cacheable( value = "getFriendsByStatusWithCache", - key = "'getFriendsWithCache'.concat(#root.target.getMemberIdValue()).concat(#friendStatus.name())", + key = + "'getFriendsWithCache'.concat(#root.target.getMemberIdValue()).concat(#friendStatus.name())", cacheManager = "cacheManager", unless = "#result.size() <= 0") @Transactional(readOnly = true) diff --git a/backend/src/main/java/com/twtw/backend/domain/location/service/GeoService.java b/backend/src/main/java/com/twtw/backend/domain/location/service/GeoService.java index a8d8ce17..eef5ba05 100644 --- a/backend/src/main/java/com/twtw/backend/domain/location/service/GeoService.java +++ b/backend/src/main/java/com/twtw/backend/domain/location/service/GeoService.java @@ -5,7 +5,9 @@ import com.twtw.backend.domain.location.dto.request.LocationRequest; import com.twtw.backend.domain.location.dto.response.AverageCoordinate; import com.twtw.backend.domain.member.entity.Member; + import lombok.RequiredArgsConstructor; + import org.springframework.data.geo.Distance; import org.springframework.data.geo.Metrics; import org.springframework.data.geo.Point; diff --git a/backend/src/main/java/com/twtw/backend/domain/path/client/SearchCarPathClient.java b/backend/src/main/java/com/twtw/backend/domain/path/client/SearchCarPathClient.java index cee828a8..1208c822 100644 --- a/backend/src/main/java/com/twtw/backend/domain/path/client/SearchCarPathClient.java +++ b/backend/src/main/java/com/twtw/backend/domain/path/client/SearchCarPathClient.java @@ -7,7 +7,9 @@ import com.twtw.backend.global.properties.NaverProperties; import io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker; + import lombok.extern.slf4j.Slf4j; + import org.springframework.http.MediaType; import org.springframework.stereotype.Component; import org.springframework.web.reactive.function.client.WebClient; diff --git a/backend/src/main/java/com/twtw/backend/domain/path/client/SearchPedPathClient.java b/backend/src/main/java/com/twtw/backend/domain/path/client/SearchPedPathClient.java index 704c4a05..722934ed 100644 --- a/backend/src/main/java/com/twtw/backend/domain/path/client/SearchPedPathClient.java +++ b/backend/src/main/java/com/twtw/backend/domain/path/client/SearchPedPathClient.java @@ -7,7 +7,9 @@ import com.twtw.backend.global.properties.TmapProperties; import io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker; + import lombok.extern.slf4j.Slf4j; + import org.springframework.http.MediaType; import org.springframework.stereotype.Component; import org.springframework.web.reactive.function.client.WebClient; diff --git a/backend/src/main/java/com/twtw/backend/domain/path/dto/client/car/SearchCarPathResponse.java b/backend/src/main/java/com/twtw/backend/domain/path/dto/client/car/SearchCarPathResponse.java index 57a5184e..dd5f07e5 100644 --- a/backend/src/main/java/com/twtw/backend/domain/path/dto/client/car/SearchCarPathResponse.java +++ b/backend/src/main/java/com/twtw/backend/domain/path/dto/client/car/SearchCarPathResponse.java @@ -13,11 +13,8 @@ @AllArgsConstructor public class SearchCarPathResponse { - private static final SearchCarPathResponse ON_ERROR_RESPONSE = new SearchCarPathResponse( - 0, - "Internal Server Error", - "", - Map.of()); + private static final SearchCarPathResponse ON_ERROR_RESPONSE = + new SearchCarPathResponse(0, "Internal Server Error", "", Map.of()); private int code; private String message; diff --git a/backend/src/main/java/com/twtw/backend/domain/path/dto/client/ped/SearchPedPathResponse.java b/backend/src/main/java/com/twtw/backend/domain/path/dto/client/ped/SearchPedPathResponse.java index 1cbb9427..d79efb92 100644 --- a/backend/src/main/java/com/twtw/backend/domain/path/dto/client/ped/SearchPedPathResponse.java +++ b/backend/src/main/java/com/twtw/backend/domain/path/dto/client/ped/SearchPedPathResponse.java @@ -13,9 +13,8 @@ @AllArgsConstructor public class SearchPedPathResponse { - private static final SearchPedPathResponse ON_ERROR_RESPONSE = new SearchPedPathResponse( - "", - List.of()); + private static final SearchPedPathResponse ON_ERROR_RESPONSE = + new SearchPedPathResponse("", List.of()); private String type; private List features; diff --git a/backend/src/main/java/com/twtw/backend/domain/place/client/SurroundPlaceClient.java b/backend/src/main/java/com/twtw/backend/domain/place/client/SurroundPlaceClient.java index ae6de461..ef0245bd 100644 --- a/backend/src/main/java/com/twtw/backend/domain/place/client/SurroundPlaceClient.java +++ b/backend/src/main/java/com/twtw/backend/domain/place/client/SurroundPlaceClient.java @@ -8,7 +8,9 @@ import com.twtw.backend.global.properties.KakaoProperties; import io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker; + import lombok.extern.slf4j.Slf4j; + import org.springframework.stereotype.Component; import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.util.UriBuilder; diff --git a/backend/src/main/java/com/twtw/backend/domain/place/dto/client/SurroundPlaceResponse.java b/backend/src/main/java/com/twtw/backend/domain/place/dto/client/SurroundPlaceResponse.java index 2b78d64a..900ae435 100644 --- a/backend/src/main/java/com/twtw/backend/domain/place/dto/client/SurroundPlaceResponse.java +++ b/backend/src/main/java/com/twtw/backend/domain/place/dto/client/SurroundPlaceResponse.java @@ -14,9 +14,8 @@ @AllArgsConstructor public class SurroundPlaceResponse { -private static final SurroundPlaceResponse ON_ERROR_RESPONSE = new SurroundPlaceResponse( - new MetaDetails(true), - List.of()); + private static final SurroundPlaceResponse ON_ERROR_RESPONSE = + new SurroundPlaceResponse(new MetaDetails(true), List.of()); private MetaDetails meta; private List documents; diff --git a/backend/src/main/java/com/twtw/backend/domain/plan/client/SearchDestinationClient.java b/backend/src/main/java/com/twtw/backend/domain/plan/client/SearchDestinationClient.java index 075d42fe..04a583a0 100644 --- a/backend/src/main/java/com/twtw/backend/domain/plan/client/SearchDestinationClient.java +++ b/backend/src/main/java/com/twtw/backend/domain/plan/client/SearchDestinationClient.java @@ -5,8 +5,11 @@ import com.twtw.backend.domain.plan.dto.client.SearchDestinationResponse; import com.twtw.backend.global.client.KakaoMapClient; import com.twtw.backend.global.properties.KakaoProperties; + import io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker; + import lombok.extern.slf4j.Slf4j; + import org.springframework.http.MediaType; import org.springframework.stereotype.Component; import org.springframework.web.reactive.function.client.WebClient; diff --git a/backend/src/main/java/com/twtw/backend/domain/plan/dto/client/SearchDestinationResponse.java b/backend/src/main/java/com/twtw/backend/domain/plan/dto/client/SearchDestinationResponse.java index 85908ea5..ee53f8fb 100644 --- a/backend/src/main/java/com/twtw/backend/domain/plan/dto/client/SearchDestinationResponse.java +++ b/backend/src/main/java/com/twtw/backend/domain/plan/dto/client/SearchDestinationResponse.java @@ -11,9 +11,8 @@ @AllArgsConstructor public class SearchDestinationResponse { - private static final SearchDestinationResponse ON_ERROR_RESPONSE = new SearchDestinationResponse( - new MetaDetails(true), - List.of()); + private static final SearchDestinationResponse ON_ERROR_RESPONSE = + new SearchDestinationResponse(new MetaDetails(true), List.of()); private MetaDetails meta; private List documents; diff --git a/backend/src/main/java/com/twtw/backend/utils/SpringELParser.java b/backend/src/main/java/com/twtw/backend/utils/SpringELParser.java index 66c0656e..9105771a 100644 --- a/backend/src/main/java/com/twtw/backend/utils/SpringELParser.java +++ b/backend/src/main/java/com/twtw/backend/utils/SpringELParser.java @@ -11,7 +11,8 @@ public class SpringELParser { private static final ExpressionParser PARSER = new SpelExpressionParser(); private static final Integer START_INDEX = 0; - public Object getDynamicValue(final String[] parameterNames, final Object[] args, final String key) { + public Object getDynamicValue( + final String[] parameterNames, final Object[] args, final String key) { final StandardEvaluationContext context = new StandardEvaluationContext(); for (int i = START_INDEX; i < parameterNames.length; i++) { diff --git a/backend/src/test/java/com/twtw/backend/BackendApplicationTests.java b/backend/src/test/java/com/twtw/backend/BackendApplicationTests.java index e768581a..72667578 100644 --- a/backend/src/test/java/com/twtw/backend/BackendApplicationTests.java +++ b/backend/src/test/java/com/twtw/backend/BackendApplicationTests.java @@ -1,6 +1,7 @@ package com.twtw.backend; import com.twtw.backend.support.testcontainer.ContainerTest; + import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ContextConfiguration; diff --git a/backend/src/test/java/com/twtw/backend/domain/friend/controller/FriendControllerTest.java b/backend/src/test/java/com/twtw/backend/domain/friend/controller/FriendControllerTest.java index ec82b4d5..ebab2781 100644 --- a/backend/src/test/java/com/twtw/backend/domain/friend/controller/FriendControllerTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/friend/controller/FriendControllerTest.java @@ -1,11 +1,25 @@ package com.twtw.backend.domain.friend.controller; +import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentRequest; +import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentResponse; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.willDoNothing; +import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + import com.twtw.backend.domain.friend.dto.request.FriendRequest; import com.twtw.backend.domain.friend.dto.request.FriendUpdateRequest; import com.twtw.backend.domain.friend.dto.response.FriendResponse; import com.twtw.backend.domain.friend.entity.FriendStatus; import com.twtw.backend.domain.friend.service.FriendService; import com.twtw.backend.support.docs.RestDocsTest; + import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; @@ -16,18 +30,6 @@ import java.util.List; import java.util.UUID; -import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentRequest; -import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentResponse; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; -import static org.mockito.BDDMockito.willDoNothing; -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - @DisplayName("FriendController의") @WebMvcTest(FriendController.class) class FriendControllerTest extends RestDocsTest { @@ -84,7 +86,11 @@ void getFriendsWithCache() throws Exception { // docs perform.andDo(print()) - .andDo(document("get all friends with cache", getDocumentRequest(), getDocumentResponse())); + .andDo( + document( + "get all friends with cache", + getDocumentRequest(), + getDocumentResponse())); } @Test @@ -259,6 +265,10 @@ void getFriendByNameWithCache() throws Exception { // docs perform.andDo(print()) - .andDo(document("get search friend with cache", getDocumentRequest(), getDocumentResponse())); + .andDo( + document( + "get search friend with cache", + getDocumentRequest(), + getDocumentResponse())); } } diff --git a/backend/src/test/java/com/twtw/backend/domain/friend/service/FriendServiceTest.java b/backend/src/test/java/com/twtw/backend/domain/friend/service/FriendServiceTest.java index e554702b..1c58a717 100644 --- a/backend/src/test/java/com/twtw/backend/domain/friend/service/FriendServiceTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/friend/service/FriendServiceTest.java @@ -1,5 +1,7 @@ package com.twtw.backend.domain.friend.service; +import static org.assertj.core.api.Assertions.assertThat; + import com.twtw.backend.domain.friend.dto.request.FriendRequest; import com.twtw.backend.domain.friend.dto.request.FriendUpdateRequest; import com.twtw.backend.domain.friend.dto.response.FriendResponse; @@ -10,6 +12,7 @@ import com.twtw.backend.domain.member.entity.Member; import com.twtw.backend.domain.member.entity.OAuth2Info; import com.twtw.backend.support.service.LoginTest; + import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -18,8 +21,6 @@ import java.util.List; import java.util.UUID; -import static org.assertj.core.api.Assertions.assertThat; - @DisplayName("FriendService의") class FriendServiceTest extends LoginTest { diff --git a/backend/src/test/java/com/twtw/backend/domain/group/service/GroupServiceTest.java b/backend/src/test/java/com/twtw/backend/domain/group/service/GroupServiceTest.java index 1ebc169c..8bc599a2 100644 --- a/backend/src/test/java/com/twtw/backend/domain/group/service/GroupServiceTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/group/service/GroupServiceTest.java @@ -1,5 +1,7 @@ package com.twtw.backend.domain.group.service; +import static org.assertj.core.api.Assertions.assertThat; + import com.twtw.backend.domain.group.dto.request.InviteGroupRequest; import com.twtw.backend.domain.group.dto.request.JoinGroupRequest; import com.twtw.backend.domain.group.dto.request.MakeGroupRequest; @@ -12,6 +14,7 @@ import com.twtw.backend.domain.member.entity.Member; import com.twtw.backend.fixture.member.MemberEntityFixture; import com.twtw.backend.support.service.LoginTest; + import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -19,8 +22,6 @@ import java.util.List; -import static org.assertj.core.api.Assertions.assertThat; - @DisplayName("GroupService의") class GroupServiceTest extends LoginTest { @Autowired private GroupService groupService; diff --git a/backend/src/test/java/com/twtw/backend/domain/member/repository/MemberRepositoryTest.java b/backend/src/test/java/com/twtw/backend/domain/member/repository/MemberRepositoryTest.java index 4d7a2843..3f1ae18b 100644 --- a/backend/src/test/java/com/twtw/backend/domain/member/repository/MemberRepositoryTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/member/repository/MemberRepositoryTest.java @@ -1,19 +1,21 @@ package com.twtw.backend.domain.member.repository; +import static org.assertj.core.api.Assertions.assertThat; + import com.twtw.backend.domain.member.dto.request.DeviceTokenRequest; import com.twtw.backend.domain.member.entity.DeviceToken; import com.twtw.backend.domain.member.entity.Member; import com.twtw.backend.fixture.member.MemberEntityFixture; import com.twtw.backend.support.repository.RepositoryTest; + import jakarta.persistence.EntityManager; + import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import java.util.UUID; -import static org.assertj.core.api.Assertions.assertThat; - @DisplayName("MemberRepository의") class MemberRepositoryTest extends RepositoryTest { diff --git a/backend/src/test/java/com/twtw/backend/domain/member/service/AuthServiceTest.java b/backend/src/test/java/com/twtw/backend/domain/member/service/AuthServiceTest.java index 2c6fa5bc..ce6441b2 100644 --- a/backend/src/test/java/com/twtw/backend/domain/member/service/AuthServiceTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/member/service/AuthServiceTest.java @@ -1,5 +1,7 @@ package com.twtw.backend.domain.member.service; +import static org.assertj.core.api.Assertions.assertThat; + import com.twtw.backend.domain.member.dto.request.MemberSaveRequest; import com.twtw.backend.domain.member.dto.request.OAuthRequest; import com.twtw.backend.domain.member.dto.response.AfterLoginResponse; @@ -10,12 +12,11 @@ import com.twtw.backend.fixture.member.MemberEntityFixture; import com.twtw.backend.support.database.DatabaseTest; import com.twtw.backend.support.exclude.ExcludeTest; + import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import static org.assertj.core.api.Assertions.assertThat; - @DatabaseTest @DisplayName("AuthService의 ") class AuthServiceTest extends ExcludeTest { diff --git a/backend/src/test/java/com/twtw/backend/domain/plan/service/PlanServiceTest.java b/backend/src/test/java/com/twtw/backend/domain/plan/service/PlanServiceTest.java index 112b8594..96fe9db1 100644 --- a/backend/src/test/java/com/twtw/backend/domain/plan/service/PlanServiceTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/plan/service/PlanServiceTest.java @@ -1,5 +1,7 @@ package com.twtw.backend.domain.plan.service; +import static org.assertj.core.api.Assertions.assertThat; + import com.twtw.backend.domain.group.repository.GroupRepository; import com.twtw.backend.domain.member.entity.Member; import com.twtw.backend.domain.place.entity.CategoryGroupCode; @@ -17,6 +19,7 @@ import com.twtw.backend.fixture.place.PlaceEntityFixture; import com.twtw.backend.fixture.plan.PlanEntityFixture; import com.twtw.backend.support.service.LoginTest; + import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -27,8 +30,6 @@ import java.util.Optional; import java.util.UUID; -import static org.assertj.core.api.Assertions.assertThat; - @DisplayName("PlanService의") class PlanServiceTest extends LoginTest { diff --git a/backend/src/test/java/com/twtw/backend/support/database/DatabaseTest.java b/backend/src/test/java/com/twtw/backend/support/database/DatabaseTest.java index 12533092..35deb80f 100644 --- a/backend/src/test/java/com/twtw/backend/support/database/DatabaseTest.java +++ b/backend/src/test/java/com/twtw/backend/support/database/DatabaseTest.java @@ -5,7 +5,6 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Import; import org.springframework.test.context.ActiveProfiles; -import org.springframework.transaction.annotation.Transactional; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/backend/src/test/java/com/twtw/backend/support/database/ResetDatabase.java b/backend/src/test/java/com/twtw/backend/support/database/ResetDatabase.java index 6a699938..acd1c287 100644 --- a/backend/src/test/java/com/twtw/backend/support/database/ResetDatabase.java +++ b/backend/src/test/java/com/twtw/backend/support/database/ResetDatabase.java @@ -7,8 +7,7 @@ @TestComponent public class ResetDatabase { - @Autowired - private Flyway flyway; + @Autowired private Flyway flyway; public void reset() { flyway.clean(); diff --git a/backend/src/test/java/com/twtw/backend/support/exclude/ExcludeTest.java b/backend/src/test/java/com/twtw/backend/support/exclude/ExcludeTest.java index 29a8811d..e4bed6e2 100644 --- a/backend/src/test/java/com/twtw/backend/support/exclude/ExcludeTest.java +++ b/backend/src/test/java/com/twtw/backend/support/exclude/ExcludeTest.java @@ -1,17 +1,18 @@ package com.twtw.backend.support.exclude; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doNothing; + import com.twtw.backend.domain.notification.messagequeue.FcmProducer; import com.twtw.backend.support.database.ResetDatabase; import com.twtw.backend.support.testcontainer.ContainerTest; + import org.junit.jupiter.api.BeforeEach; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doNothing; - @Import(ResetDatabase.class) @ContextConfiguration(initializers = ContainerTest.class) public abstract class ExcludeTest { diff --git a/backend/src/test/java/com/twtw/backend/support/repository/EnableDataJpa.java b/backend/src/test/java/com/twtw/backend/support/repository/EnableDataJpa.java index 78f3751b..b775ef3b 100644 --- a/backend/src/test/java/com/twtw/backend/support/repository/EnableDataJpa.java +++ b/backend/src/test/java/com/twtw/backend/support/repository/EnableDataJpa.java @@ -5,7 +5,6 @@ import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.context.annotation.Import; -import org.springframework.test.context.ActiveProfiles; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/backend/src/test/java/com/twtw/backend/support/repository/RepositoryTest.java b/backend/src/test/java/com/twtw/backend/support/repository/RepositoryTest.java index 794b3228..6d2275a0 100644 --- a/backend/src/test/java/com/twtw/backend/support/repository/RepositoryTest.java +++ b/backend/src/test/java/com/twtw/backend/support/repository/RepositoryTest.java @@ -1,6 +1,7 @@ package com.twtw.backend.support.repository; import com.twtw.backend.support.database.ResetDatabase; + import org.junit.jupiter.api.BeforeEach; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Import; diff --git a/backend/src/test/java/com/twtw/backend/support/service/LoginTest.java b/backend/src/test/java/com/twtw/backend/support/service/LoginTest.java index 292665d1..b32bc8db 100644 --- a/backend/src/test/java/com/twtw/backend/support/service/LoginTest.java +++ b/backend/src/test/java/com/twtw/backend/support/service/LoginTest.java @@ -1,5 +1,9 @@ package com.twtw.backend.support.service; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.when; + import com.twtw.backend.domain.member.entity.Member; import com.twtw.backend.domain.member.repository.MemberRepository; import com.twtw.backend.domain.member.service.AuthService; @@ -8,16 +12,13 @@ import com.twtw.backend.support.database.DatabaseTest; import com.twtw.backend.support.database.ResetDatabase; import com.twtw.backend.support.testcontainer.ContainerTest; + import org.junit.jupiter.api.BeforeEach; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.when; - @DatabaseTest @Import(ResetDatabase.class) @ContextConfiguration(initializers = ContainerTest.class) diff --git a/backend/src/test/java/com/twtw/backend/support/testcontainer/ContainerTest.java b/backend/src/test/java/com/twtw/backend/support/testcontainer/ContainerTest.java index 79237a1d..a3060a5d 100644 --- a/backend/src/test/java/com/twtw/backend/support/testcontainer/ContainerTest.java +++ b/backend/src/test/java/com/twtw/backend/support/testcontainer/ContainerTest.java @@ -1,17 +1,17 @@ package com.twtw.backend.support.testcontainer; import com.redis.testcontainers.RedisContainer; + import org.springframework.boot.test.util.TestPropertyValues; import org.springframework.context.ApplicationContextInitializer; import org.springframework.context.ConfigurableApplicationContext; import org.testcontainers.containers.RabbitMQContainer; import org.testcontainers.utility.DockerImageName; -public class ContainerTest implements - ApplicationContextInitializer { +public class ContainerTest + implements ApplicationContextInitializer { private static final RedisContainer REDIS_CONTAINER = - new RedisContainer(DockerImageName.parse("redis:latest")) - .withExposedPorts(6379); + new RedisContainer(DockerImageName.parse("redis:latest")).withExposedPorts(6379); private static final RabbitMQContainer RABBIT_MQ_CONTAINER = new RabbitMQContainer(DockerImageName.parse("rabbitmq:3-management-alpine")) @@ -26,13 +26,13 @@ public class ContainerTest implements @Override public void initialize(final ConfigurableApplicationContext applicationContext) { TestPropertyValues.of( - "spring.data.redis.host=" + REDIS_CONTAINER.getHost(), - "spring.data.redis.port=" + REDIS_CONTAINER.getFirstMappedPort(), - "spring.rabbitmq.host=" + RABBIT_MQ_CONTAINER.getHost(), - "spring.rabbitmq.port=" + RABBIT_MQ_CONTAINER.getMappedPort(5672), - "spring.rabbitmq.stomp.port=" + RABBIT_MQ_CONTAINER.getMappedPort(61613), - "spring.rabbitmq.username=guest", - "spring.rabbitmq.password=guest" - ).applyTo(applicationContext.getEnvironment()); + "spring.data.redis.host=" + REDIS_CONTAINER.getHost(), + "spring.data.redis.port=" + REDIS_CONTAINER.getFirstMappedPort(), + "spring.rabbitmq.host=" + RABBIT_MQ_CONTAINER.getHost(), + "spring.rabbitmq.port=" + RABBIT_MQ_CONTAINER.getMappedPort(5672), + "spring.rabbitmq.stomp.port=" + RABBIT_MQ_CONTAINER.getMappedPort(61613), + "spring.rabbitmq.username=guest", + "spring.rabbitmq.password=guest") + .applyTo(applicationContext.getEnvironment()); } }