Skip to content

Commit

Permalink
#228 test: 회원 조회 서비스 클래스명 수정에 따른 테스트 코드 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
JeongUijeong committed Feb 15, 2024
1 parent 75c6912 commit d7a384a
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.backoffice.upjuyanolja.domain.accommodation.service.AccommodationCommandService;
import com.backoffice.upjuyanolja.domain.member.entity.Authority;
import com.backoffice.upjuyanolja.domain.member.entity.Member;
import com.backoffice.upjuyanolja.domain.member.service.MemberGetService;
import com.backoffice.upjuyanolja.domain.member.service.MemberQueryService;
import com.backoffice.upjuyanolja.domain.room.dto.request.RoomImageRequest;
import com.backoffice.upjuyanolja.domain.room.dto.request.RoomOptionRequest;
import com.backoffice.upjuyanolja.domain.room.dto.request.RoomRegisterRequest;
Expand Down Expand Up @@ -50,7 +50,7 @@ public class AccommodationCommandServiceTest {
private AccommodationCommandService accommodationCommandService;

@Mock
private MemberGetService memberGetService;
private MemberQueryService memberQueryService;

@Mock
private AccommodationRepository accommodationRepository;
Expand Down Expand Up @@ -193,7 +193,7 @@ void _willSuccess() {
.build())
.build();

given(memberGetService.getMemberById(any(Long.TYPE))).willReturn(member);
given(memberQueryService.getMemberById(any(Long.TYPE))).willReturn(member);
given(categoryRepository.findByName(any(String.class)))
.willReturn(Optional.of(category));
given(accommodationRepository.save(any(Accommodation.class))).willReturn(accommodation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import com.backoffice.upjuyanolja.domain.accommodation.service.AccommodationQueryService;
import com.backoffice.upjuyanolja.domain.member.entity.Authority;
import com.backoffice.upjuyanolja.domain.member.entity.Member;
import com.backoffice.upjuyanolja.domain.member.service.MemberGetService;
import com.backoffice.upjuyanolja.domain.member.service.MemberQueryService;
import java.util.List;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
Expand All @@ -31,7 +31,7 @@ public class AccommodationQueryServiceTest {
private AccommodationQueryService accommodationQueryService;

@Mock
private MemberGetService memberGetService;
private MemberQueryService memberQueryService;

@Mock
private AccommodationOwnershipRepository accommodationOwnershipRepository;
Expand Down Expand Up @@ -74,7 +74,7 @@ void _willSuccess() {
.member(member)
.build();

given(memberGetService.getMemberById(any(Long.TYPE))).willReturn(member);
given(memberQueryService.getMemberById(any(Long.TYPE))).willReturn(member);
given(accommodationOwnershipRepository.findAllByMember(any(Member.class)))
.willReturn(List.of(accommodationOwnership));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import com.backoffice.upjuyanolja.domain.member.dto.response.MemberInfoResponse;
import com.backoffice.upjuyanolja.domain.member.entity.Authority;
import com.backoffice.upjuyanolja.domain.member.entity.Member;
import com.backoffice.upjuyanolja.domain.member.service.MemberGetService;
import com.backoffice.upjuyanolja.domain.member.service.MemberQueryService;
import com.backoffice.upjuyanolja.domain.room.entity.Room;
import com.backoffice.upjuyanolja.domain.room.entity.RoomStatus;
import com.backoffice.upjuyanolja.global.security.SecurityUtil;
Expand Down Expand Up @@ -76,7 +76,7 @@ class CouponBackofficeControllerDocsTest extends RestDocsSupport {
private SecurityUtil securityUtil;

@MockBean
private MemberGetService memberGetService;
private MemberQueryService memberQueryService;

@MockBean
private CouponBackofficeService couponBackofficeService;
Expand Down Expand Up @@ -145,7 +145,7 @@ public void createCouponResponseTest() throws Exception {
public void createCouponRequestTest() throws Exception {
// given
when(securityUtil.getCurrentMemberId()).thenReturn(1L);
when(memberGetService.getMemberById(1L)).thenReturn(mockMember);
when(memberQueryService.getMemberById(1L)).thenReturn(mockMember);

List<CouponRoomsRequest> mockRequests = List.of(
new CouponRoomsRequest(1L, DiscountType.FLAT, 5000, 10, 10000),
Expand Down Expand Up @@ -210,7 +210,7 @@ public void createCouponRequestTest() throws Exception {
public void manageCouponResponseTest() throws Exception {
// given
when(securityUtil.getCurrentMemberId()).thenReturn(1L);
when(memberGetService.getMemberById(1L)).thenReturn(mockMember);
when(memberQueryService.getMemberById(1L)).thenReturn(mockMember);

Accommodation mockAccommodation = createAccommodation(1L);
List<Long> roomIdSet = List.of(1L, 2L, 3L);
Expand Down Expand Up @@ -296,7 +296,7 @@ public void manageCouponResponseTest() throws Exception {
public void addonCouponRequestTest() throws Exception {
// given
when(securityUtil.getCurrentMemberId()).thenReturn(1L);
when(memberGetService.getMemberById(1L)).thenReturn(mockMember);
when(memberQueryService.getMemberById(1L)).thenReturn(mockMember);

List<CouponAddRooms> rooms = createMockAddCoupons();
CouponAddRequest mockCouponAddRequest = new CouponAddRequest(
Expand Down Expand Up @@ -382,7 +382,7 @@ public void addonCouponRequestTest() throws Exception {
public void modifyCouponRequestTest() throws Exception {
// given
when(securityUtil.getCurrentMemberId()).thenReturn(1L);
when(memberGetService.getMemberById(1L)).thenReturn(mockMember);
when(memberQueryService.getMemberById(1L)).thenReturn(mockMember);

List<CouponModifyRooms> rooms = createMockModifyCoupons();
CouponModifyRequest mockCouponModifyRequest = new CouponModifyRequest(
Expand Down Expand Up @@ -453,7 +453,7 @@ public void modifyCouponRequestTest() throws Exception {
public void deleteCouponRequestTest() throws Exception {
// given
when(securityUtil.getCurrentMemberId()).thenReturn(1L);
when(memberGetService.getMemberById(1L)).thenReturn(mockMember);
when(memberQueryService.getMemberById(1L)).thenReturn(mockMember);

List<CouponDeleteRooms> rooms = createMockDeleteCoupons();
CouponDeleteRequest mockDeleteRequest = new CouponDeleteRequest(
Expand Down Expand Up @@ -499,7 +499,7 @@ public void deleteCouponRequestTest() throws Exception {
public void couponStatisticsTest() throws Exception {
// given
when(securityUtil.getCurrentMemberId()).thenReturn(1L);
when(memberGetService.getMemberById(1L)).thenReturn(mockMember);
when(memberQueryService.getMemberById(1L)).thenReturn(mockMember);

// when & Then
CouponStatisticsResponse mockResponse = createMockStatisticsResponse();
Expand Down Expand Up @@ -540,7 +540,7 @@ public void revenueStatisticsTest() throws Exception {
.build();

given(securityUtil.getCurrentMemberId()).willReturn(1L);
given(memberGetService.getMember(any(Long.TYPE))).willReturn(memberInfoResponse);
given(memberQueryService.getMember(any(Long.TYPE))).willReturn(memberInfoResponse);
String mockName = mockMember.getName();

// when & Then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import com.backoffice.upjuyanolja.domain.member.dto.response.MemberInfoResponse;
import com.backoffice.upjuyanolja.domain.member.entity.Authority;
import com.backoffice.upjuyanolja.domain.member.entity.Member;
import com.backoffice.upjuyanolja.domain.member.service.MemberGetService;
import com.backoffice.upjuyanolja.domain.member.service.MemberQueryService;
import com.backoffice.upjuyanolja.domain.point.entity.Point;
import com.backoffice.upjuyanolja.domain.room.entity.Room;
import com.backoffice.upjuyanolja.domain.room.entity.RoomStatus;
Expand Down Expand Up @@ -99,7 +99,7 @@ class CouponBackofficeControllerTest {
private SecurityUtil securityUtil;

@MockBean
private MemberGetService memberGetService;
private MemberQueryService memberQueryService;

Member mockMember;

Expand All @@ -121,7 +121,7 @@ class Context_makeCouponViewResponse {
public void couponMakeViewResponse_test() throws Exception {
// given
when(securityUtil.getCurrentMemberId()).thenReturn(1L);
when(memberGetService.getMemberById(1L)).thenReturn(mockMember);
when(memberQueryService.getMemberById(1L)).thenReturn(mockMember);

Long accommodationId = 1L;
CouponMakeViewResponse makeViewResponse = makeCouponViewResponse();
Expand Down Expand Up @@ -149,7 +149,7 @@ public void couponMakeViewResponse_test() throws Exception {
public void couponMakeRequestTest() throws Exception {
// given
when(securityUtil.getCurrentMemberId()).thenReturn(1L);
when(memberGetService.getMemberById(1L)).thenReturn(mockMember);
when(memberQueryService.getMemberById(1L)).thenReturn(mockMember);

List<CouponRoomsRequest> mockCouponRoomsRequests = createCouponRooms();
CouponMakeRequest mockCouponMakeRequest = createCouponMakeRequest(
Expand Down Expand Up @@ -177,7 +177,7 @@ class Context_couponManage {
public void couponManageViewResponse_test() throws Exception {
// given
when(securityUtil.getCurrentMemberId()).thenReturn(1L);
when(memberGetService.getMemberById(1L)).thenReturn(mockMember);
when(memberQueryService.getMemberById(1L)).thenReturn(mockMember);

List<Long> roomIdSet = List.of(1L, 2L, 3L);
List<String> roomNameSet = List.of("스탠다드", "디럭스", "스위트");
Expand Down Expand Up @@ -246,7 +246,7 @@ public void couponManageViewResponse_test() throws Exception {
public void addonCouponTest() throws Exception {
// given
when(securityUtil.getCurrentMemberId()).thenReturn(1L);
when(memberGetService.getMemberById(1L)).thenReturn(mockMember);
when(memberQueryService.getMemberById(1L)).thenReturn(mockMember);

List<CouponAddRooms> rooms = createMockAddCoupons();
CouponAddRequest couponAddRequest = new CouponAddRequest(
Expand All @@ -266,7 +266,7 @@ public void addonCouponTest() throws Exception {
public void couponModifyTest() throws Exception {
// given
when(securityUtil.getCurrentMemberId()).thenReturn(1L);
when(memberGetService.getMemberById(1L)).thenReturn(mockMember);
when(memberQueryService.getMemberById(1L)).thenReturn(mockMember);

List<CouponModifyRooms> rooms = createModifyCouponMock();
CouponModifyRequest couponModifyRequest = new CouponModifyRequest(
Expand All @@ -286,7 +286,7 @@ public void couponModifyTest() throws Exception {
public void couponDeleteTest() throws Exception {
// given
when(securityUtil.getCurrentMemberId()).thenReturn(1L);
when(memberGetService.getMemberById(1L)).thenReturn(mockMember);
when(memberQueryService.getMemberById(1L)).thenReturn(mockMember);

List<CouponDeleteRooms> rooms = createMockDeleteRooms();
CouponDeleteRequest mockDeleteRequest = new CouponDeleteRequest(
Expand All @@ -311,7 +311,7 @@ class Context_couponStatisticse {
public void couponStatisticsTest() throws Exception {
// given
when(securityUtil.getCurrentMemberId()).thenReturn(1L);
when(memberGetService.getMemberById(1L)).thenReturn(mockMember);
when(memberQueryService.getMemberById(1L)).thenReturn(mockMember);

// when & Then
CouponStatisticsResponse mockResponse = createMockStatisticsResponse();
Expand Down Expand Up @@ -345,7 +345,7 @@ public void revenueStatisticsTest() throws Exception {
.build();

given(securityUtil.getCurrentMemberId()).willReturn(1L);
given(memberGetService.getMember(any(Long.TYPE))).willReturn(memberInfoResponse);
given(memberQueryService.getMember(any(Long.TYPE))).willReturn(memberInfoResponse);
String mockName = mockMember.getName();

// when & Then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import com.backoffice.upjuyanolja.domain.coupon.service.CouponBackofficeService;
import com.backoffice.upjuyanolja.domain.member.entity.Authority;
import com.backoffice.upjuyanolja.domain.member.entity.Member;
import com.backoffice.upjuyanolja.domain.member.service.MemberGetService;
import com.backoffice.upjuyanolja.domain.member.service.MemberQueryService;
import com.backoffice.upjuyanolja.domain.point.entity.Point;
import com.backoffice.upjuyanolja.domain.point.repository.PointRepository;
import com.backoffice.upjuyanolja.domain.room.entity.Room;
Expand All @@ -40,7 +40,7 @@ class CouponBackofficeServiceTest {
CouponBackofficeService couponBackofficeService;

@Mock
MemberGetService memberGetService;
MemberQueryService memberQueryService;

@Mock
CouponRepository couponRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields;
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;

import com.backoffice.upjuyanolja.domain.accommodation.service.AccommodationQueryService;
import com.backoffice.upjuyanolja.domain.member.dto.request.EmailRequest;
import com.backoffice.upjuyanolja.domain.member.dto.response.CheckEmailDuplicateResponse;
import com.backoffice.upjuyanolja.domain.member.dto.response.MemberInfoResponse;
import com.backoffice.upjuyanolja.domain.member.service.MemberAuthService;
import com.backoffice.upjuyanolja.domain.member.service.MemberGetService;
import com.backoffice.upjuyanolja.domain.member.service.MemberQueryService;
import com.backoffice.upjuyanolja.global.security.SecurityUtil;
import com.backoffice.upjuyanolja.global.util.RestDocsSupport;
import org.junit.jupiter.api.DisplayName;
Expand All @@ -32,7 +31,7 @@ public class MemberAuthControllerDocsTest extends RestDocsSupport {
private MemberAuthService memberAuthService;

@MockBean
private MemberGetService memberGetService;
private MemberQueryService memberQueryService;

@MockBean
private SecurityUtil securityUtil;
Expand Down Expand Up @@ -78,7 +77,7 @@ void getMember() throws Exception {
.build();

given(securityUtil.getCurrentMemberId()).willReturn(1L);
given(memberGetService.getMember(any(Long.TYPE)))
given(memberQueryService.getMember(any(Long.TYPE)))
.willReturn(memberInfoResponse);

// when then
Expand All @@ -96,6 +95,6 @@ void getMember() throws Exception {
)
));

verify(memberGetService, times(1)).getMember(any(Long.TYPE));
verify(memberQueryService, times(1)).getMember(any(Long.TYPE));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import com.backoffice.upjuyanolja.domain.member.dto.response.CheckEmailDuplicateResponse;
import com.backoffice.upjuyanolja.domain.member.dto.response.MemberInfoResponse;
import com.backoffice.upjuyanolja.domain.member.service.MemberAuthService;
import com.backoffice.upjuyanolja.domain.member.service.MemberGetService;
import com.backoffice.upjuyanolja.domain.member.service.MemberQueryService;
import com.backoffice.upjuyanolja.global.security.AuthenticationConfig;
import com.backoffice.upjuyanolja.global.security.SecurityUtil;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down Expand Up @@ -51,7 +51,7 @@ public class MemberAuthControllerTest {
private MemberAuthService memberAuthService;

@MockBean
private MemberGetService memberGetService;
private MemberQueryService memberQueryService;

@MockBean
private SecurityUtil securityUtil;
Expand Down Expand Up @@ -127,7 +127,7 @@ void _willSuccess() throws Exception {
.build();

given(securityUtil.getCurrentMemberId()).willReturn(1L);
given(memberGetService.getMember(any(Long.TYPE)))
given(memberQueryService.getMember(any(Long.TYPE)))
.willReturn(memberInfoResponse);

// when then
Expand All @@ -139,7 +139,7 @@ void _willSuccess() throws Exception {
.andExpect(jsonPath("$.phoneNumber").isString())
.andDo(print());

verify(memberGetService, times(1)).getMember(any(Long.class));
verify(memberQueryService, times(1)).getMember(any(Long.class));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import com.backoffice.upjuyanolja.domain.member.entity.Member;
import com.backoffice.upjuyanolja.domain.member.exception.MemberNotFoundException;
import com.backoffice.upjuyanolja.domain.member.repository.MemberRepository;
import com.backoffice.upjuyanolja.domain.member.service.MemberGetService;
import com.backoffice.upjuyanolja.domain.member.service.MemberQueryService;
import java.util.Optional;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
Expand All @@ -26,10 +26,10 @@

@Transactional
@ExtendWith(MockitoExtension.class)
public class MemberGetServiceTest {
public class MemberQueryServiceTest {

@InjectMocks
private MemberGetService memberGetService;
private MemberQueryService memberQueryService;

@Mock
private MemberRepository memberRepository;
Expand All @@ -55,7 +55,7 @@ void _willSuccess() {
given(memberRepository.findById(any(Long.TYPE))).willReturn(Optional.of(member));

// when
MemberInfoResponse result = memberGetService.getMember(1L);
MemberInfoResponse result = memberQueryService.getMember(1L);

// then
assertThat(result.memberId()).isEqualTo(1L);
Expand All @@ -74,7 +74,7 @@ void memberNotFound_willFail() {

// when
Throwable exception = assertThrows(MemberNotFoundException.class, () -> {
memberGetService.getMember(1L);
memberQueryService.getMember(1L);
});

// then
Expand Down
Loading

0 comments on commit d7a384a

Please sign in to comment.