Skip to content

Commit

Permalink
test:테스트에 어플리케이션 콘텍스트 캐싱 위한 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
hum02 committed Oct 10, 2023
1 parent 62f0691 commit d96d6aa
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package com.project.yozmcafe.service;


import org.springframework.boot.test.mock.mockito.SpyBean;

import com.project.yozmcafe.BaseTest;
import com.project.yozmcafe.domain.S3Client;
import com.project.yozmcafe.service.auth.GoogleOAuthClient;
import org.springframework.boot.test.mock.mockito.SpyBean;

public abstract class BaseServiceTest extends BaseTest {

@SpyBean
protected S3Client s3Client;

@SpyBean
protected GoogleOAuthClient googleOAuthClient;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.project.yozmcafe.service;

import com.project.yozmcafe.BaseTest;
import com.project.yozmcafe.controller.auth.OAuthProvider;
import com.project.yozmcafe.domain.cafe.Cafe;
import com.project.yozmcafe.domain.cafe.CafeRepository;
Expand All @@ -10,11 +9,9 @@
import com.project.yozmcafe.domain.member.MemberRepository;
import com.project.yozmcafe.fixture.Fixture;
import com.project.yozmcafe.service.auth.AuthService;
import com.project.yozmcafe.service.auth.GoogleOAuthClient;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.test.context.event.ApplicationEvents;
import org.springframework.test.context.event.RecordApplicationEvents;

Expand All @@ -26,17 +23,14 @@
import static org.mockito.Mockito.doReturn;

@RecordApplicationEvents
class UnViewedCafeRefillListenerTest extends BaseTest {
class UnViewedCafeRefillListenerTest extends BaseServiceTest {

@Autowired
AuthService authService;

@Autowired
CafeService cafeService;

@SpyBean
private GoogleOAuthClient googleOAuthClient;

@Autowired
private MemberRepository memberRepository;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
package com.project.yozmcafe.service;

import static org.assertj.core.api.Assertions.assertThat;

import java.util.ArrayList;
import java.util.List;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;

import com.project.yozmcafe.domain.RandomCafeShuffleStrategy;
import com.project.yozmcafe.domain.cafe.Cafe;
import com.project.yozmcafe.domain.cafe.CafeRepository;
Expand All @@ -18,13 +8,22 @@
import com.project.yozmcafe.domain.member.Member;
import com.project.yozmcafe.domain.member.MemberRepository;
import com.project.yozmcafe.fixture.Fixture;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;

class UnViewedCafeServiceTest extends BaseServiceTest {

private UnViewedCafeService unViewedCafeService;

@Autowired
private CafeRepository cafeRepository;

@Autowired
UnViewedCafeRepository unViewedCafeRepository;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
package com.project.yozmcafe.service.auth;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.anyString;
import static org.mockito.Mockito.doReturn;

import java.util.List;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.transaction.annotation.Transactional;

import com.project.yozmcafe.controller.auth.OAuthProvider;
import com.project.yozmcafe.controller.dto.AuthorizationUrlDto;
import com.project.yozmcafe.domain.cafe.Cafe;
Expand All @@ -21,8 +9,16 @@
import com.project.yozmcafe.domain.member.MemberInfo;
import com.project.yozmcafe.domain.member.MemberRepository;
import com.project.yozmcafe.fixture.Fixture;

import com.project.yozmcafe.service.BaseServiceTest;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.anyString;
import static org.mockito.Mockito.doReturn;

class AuthServiceTest extends BaseServiceTest {

Expand All @@ -32,8 +28,6 @@ class AuthServiceTest extends BaseServiceTest {
private CafeRepository cafeRepository;
@Autowired
private AuthService authService;
@SpyBean
protected GoogleOAuthClient googleOAuthClient;

@Test
@DisplayName("회원가입된 상태의 유저로 createAccessToken 호출하면 멤버를 새로 저장하지 않는다")
Expand Down

0 comments on commit d96d6aa

Please sign in to comment.