Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HotFix: 보호자의 회원가입때만 환영 포인트 지급하도록 수정 #212

Merged
merged 1 commit into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.util.Optional;

@Service
public class MemberService{
public class MemberService {

private static final int WELCOME_POINT = 10000;

Expand Down Expand Up @@ -80,8 +80,10 @@ public RegisterResponse registerNewMember(String name, String phoneNumber, Strin
Member newMember = new Member(name, phoneNumber, email, isSinitto);
memberRepository.save(newMember);

pointRepository.save(new Point(WELCOME_POINT, newMember));
pointLogRepository.save(new PointLog(PointLog.Content.WELCOME_POINT, newMember, WELCOME_POINT, PointLog.Status.EARN));
if (!isSinitto) {
pointRepository.save(new Point(WELCOME_POINT, newMember));
pointLogRepository.save(new PointLog(PointLog.Content.WELCOME_POINT, newMember, WELCOME_POINT, PointLog.Status.EARN));
}

String accessToken = tokenService.generateAccessToken(email);
String refreshToken = tokenService.generateRefreshToken(email);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.example.sinitto.auth.service.TokenService;
import com.example.sinitto.callback.service.CallbackService;
import com.example.sinitto.common.exception.ConflictException;
import com.example.sinitto.common.exception.NotFoundException;
import com.example.sinitto.helloCall.service.HelloCallService;
import com.example.sinitto.member.dto.RegisterResponse;
import com.example.sinitto.member.entity.Member;
Expand Down Expand Up @@ -49,8 +48,8 @@ public class MemberServiceTest {
PointLogRepository pointLogRepository;

@Test
@DisplayName("registerNewMember 메소드 테스트")
void registerNewMemberTest() {
@DisplayName("registerNewMember 메소드 테스트 - 시니또의 회원가입인 경우 환영 포인트 미지급")
void registerNewMemberTest1() {
//given
String name = "testName";
String phoneNumber = "01000000000";
Expand All @@ -62,6 +61,27 @@ void registerNewMemberTest() {
//when
RegisterResponse result = memberService.registerNewMember(name, phoneNumber, email, isSinitto);

//then
verify(memberRepository, times(1)).save(any(Member.class));
verify(pointRepository, never()).save(any());
verify(pointLogRepository, never()).save(any());
assertEquals(isSinitto, result.isSinitto());
}

@Test
@DisplayName("registerNewMember 메소드 테스트 - 보호자의 회원가입인 경우 환영 포인트 지급")
void registerNewMemberTest2() {
//given
String name = "testName";
String phoneNumber = "01000000000";
String email = "test@email.com";
boolean isSinitto = false;

when(memberRepository.existsByEmail(email)).thenReturn(false);

//when
RegisterResponse result = memberService.registerNewMember(name, phoneNumber, email, isSinitto);

//then
verify(memberRepository, times(1)).save(any(Member.class));
verify(pointRepository, times(1)).save(any());
Expand Down