Skip to content

Commit

Permalink
fix: addCurrentPrice 수행시 액세스 토큰 호출 제거
Browse files Browse the repository at this point in the history
- fetchCurrentPrice 실행전 aop에 의해서 실행되기 때문에 제거
  • Loading branch information
yonghwankim-dev committed Aug 12, 2024
1 parent ebe75ad commit 7f7a0e8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
@RequiredArgsConstructor
@Component
public class CurrentPriceRepository {
private static final String format = "cp:%s";
private static final String CURRENT_PRICE_FORMAT = "cp:%s";
private final RedisTemplate<String, String> redisTemplate;
private final KisAccessTokenRepository accessTokenManager;
private final KisClient kisClient;
private final AccessTokenAspect accessTokenAspect;

Expand All @@ -30,12 +29,12 @@ public void addCurrentPrice(KisCurrentPrice currentPrice) {
public void addCurrentPrice(List<KisCurrentPrice> currentPrices) {
currentPrices.forEach(currentPrice ->
redisTemplate.opsForValue()
.set(String.format(format, currentPrice.getTickerSymbol()), String.valueOf(currentPrice.getPrice())));
.set(String.format(CURRENT_PRICE_FORMAT, currentPrice.getTickerSymbol()),
String.valueOf(currentPrice.getPrice())));
}

public Optional<Money> getCurrentPrice(String tickerSymbol) {
accessTokenAspect.checkAccessTokenExpiration();
String currentPrice = redisTemplate.opsForValue().get(String.format(format, tickerSymbol));
String currentPrice = redisTemplate.opsForValue().get(String.format(CURRENT_PRICE_FORMAT, tickerSymbol));
if (currentPrice == null) {
handleCurrentPrice(tickerSymbol);
return getCurrentPrice(tickerSymbol);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import codesquad.fineants.domain.fcm.domain.entity.FcmToken;
import codesquad.fineants.domain.holding.domain.entity.PortfolioHolding;
import codesquad.fineants.domain.kis.client.KisAccessToken;
import codesquad.fineants.domain.kis.repository.KisAccessTokenRepository;
import codesquad.fineants.domain.member.domain.entity.Member;
import codesquad.fineants.domain.member.domain.entity.MemberRole;
import codesquad.fineants.domain.member.domain.entity.Role;
Expand Down Expand Up @@ -98,11 +99,15 @@ public static void overrideProps(DynamicPropertyRegistry registry) {
registry.add("spring.datasource.password", () -> "password1234!");
}

@Autowired
private KisAccessTokenRepository kisAccessTokenRepository;

@BeforeEach
public void abstractSetup() {
createRoleIfNotFound("ROLE_ADMIN", "관리자");
createRoleIfNotFound("ROLE_MANAGER", "매니저");
createRoleIfNotFound("ROLE_USER", "회원");
kisAccessTokenRepository.refreshAccessToken(createKisAccessToken());
}

@AfterEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.util.Collection;
import java.util.List;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.DynamicTest;
import org.junit.jupiter.api.Test;
Expand All @@ -23,7 +22,6 @@
import codesquad.fineants.domain.kis.domain.dto.response.KisClosingPrice;
import codesquad.fineants.domain.kis.repository.ClosingPriceRepository;
import codesquad.fineants.domain.kis.repository.CurrentPriceRepository;
import codesquad.fineants.domain.kis.repository.KisAccessTokenRepository;
import codesquad.fineants.domain.kis.service.KisService;
import codesquad.fineants.domain.member.domain.entity.Member;
import codesquad.fineants.domain.member.repository.MemberRepository;
Expand Down Expand Up @@ -73,14 +71,6 @@ class WatchListServiceTest extends AbstractContainerBaseTest {
@MockBean
private KisService kisService;

@Autowired
private KisAccessTokenRepository kisAccessTokenRepository;

@BeforeEach
void setup() {
kisAccessTokenRepository.refreshAccessToken(createKisAccessToken());
}

@DisplayName("회원이 watchlist를 추가한다.")
@Test
void createWatchList() {
Expand Down

0 comments on commit 7f7a0e8

Please sign in to comment.