Skip to content

Commit

Permalink
Google Java Format
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Mar 10, 2024
1 parent b0a33c2 commit d8b9f5f
Show file tree
Hide file tree
Showing 32 changed files with 133 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -85,21 +88,23 @@ public List<Friend> 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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -116,7 +118,8 @@ private List<FriendResponse> 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<FriendResponse> getFriendsByStatus(final FriendStatus friendStatus) {
Expand All @@ -125,7 +128,8 @@ public List<FriendResponse> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Feature> features;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<PlaceClientDetails> documents;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<PlaceClientDetails> documents;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()));
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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 {

Expand Down
Loading

0 comments on commit d8b9f5f

Please sign in to comment.