Skip to content

[BE/test] 회원가입 API 테스트 #362

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

Merged
merged 21 commits into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0526d50
test/#360 : 반복 가능한 테스트를 위해 testData.sql 데이터의 CURRENT_TIMESTAMP 의존성 제거
hwangdaesun Jul 6, 2024
a64b4af
test/#360 : testData가 특정 날짜를 나타내도록 수정
hwangdaesun Jul 6, 2024
08300c9
test/#360 : 공통된 의존성 제거
hwangdaesun Jul 6, 2024
1ba19f8
refactor/#360 : 사용하지 않는 필드 제거
hwangdaesun Jul 6, 2024
479d14c
test/#360 : ValidateEmailService 단위 테스트 생성
hwangdaesun Jul 6, 2024
bfd9d80
test/#360 : CreateMemberService 단위 테스트 작성
hwangdaesun Jul 6, 2024
e8ecf9b
refactor/#360 : HttpStatus.CREATED -> HttpStatus.OK
hwangdaesun Jul 7, 2024
6d17096
refactor/#360 : 온보딩 통합 테스트 리팩토링
hwangdaesun Jul 7, 2024
ce8c088
refactor/#360 : HttpStatus.OK -> HttpStatus.CREATED
hwangdaesun Jul 7, 2024
e47b277
test/#360 : 회원가입 성공 및 실패시 통합 테스트 수행
hwangdaesun Jul 7, 2024
3dee16d
refactor/#360 : SignUpMemberController 클래스에 있던 API들 다른 클래스로 분리
hwangdaesun Jul 7, 2024
f86f255
test/#360 : 이메일 인증 여부 확인하는 API 통합 테스트 수행
hwangdaesun Jul 7, 2024
e56475c
test/#360 : 이미 회원가입한 이메일인지 검증하는 서비스 단위테스트 수행
hwangdaesun Jul 7, 2024
c62d742
refactor/#360 : 조건에서 isChecked 메서드 제외
hwangdaesun Jul 7, 2024
27b2900
refactor/#360 : 테스트 프로필 제외
hwangdaesun Jul 7, 2024
bb3295e
refactor/#360 : @Profile("test") 제거
hwangdaesun Jul 7, 2024
be267de
refactor/#360 : 메서드명 when_then 형식으로 수정
hwangdaesun Jul 7, 2024
1623cc5
refactor/#360 : 사용하지 않는 클래스 제거
hwangdaesun Jul 7, 2024
2402023
test/#360 : when_then 형식으로 메서드명 수정
hwangdaesun Jul 7, 2024
40f854e
test/#360 : isChecked() -> existsByEmail() 변경
hwangdaesun Jul 7, 2024
cc16927
style/#360 : spotless 적용
hwangdaesun Jul 7, 2024
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
10 changes: 7 additions & 3 deletions BE/exceed/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ dependencies {
testImplementation "org.testcontainers:mariadb:1.19.8"
testImplementation "org.testcontainers:testcontainers:1.19.8"
testImplementation "org.testcontainers:junit-jupiter:1.19.8"
testImplementation "org.junit.jupiter:junit-jupiter:5.8.1"


// querydsl
Expand Down Expand Up @@ -213,7 +212,7 @@ jacocoTestReport {
classDirectories.setFrom(
files(classDirectories.files.collect{
fileTree(dir: it, excludes: [
"**/*Application",
"**/ExceedApplication",
"**/*Config*",
"**/*Request*",
"**/*Response*",
Expand All @@ -222,7 +221,12 @@ jacocoTestReport {
"**/*Docs*",
"**/*DTO*",
"**/common/**",
"**/health/**"
"**/health/**",
"**/*Error*",
"**/*Adapter*",
"**/*Port*",
"**/*Converter*",
"**/Q*"
])
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.concurrent.Executor;

import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
Expand All @@ -11,6 +12,7 @@

@EnableAsync
@Configuration
@Profile("!test")
public class AsyncConfig implements AsyncConfigurer {
@Override
public Executor getAsyncExecutor() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.gaebaljip.exceed.member.adapter.in;

import javax.validation.Valid;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.gaebaljip.exceed.common.ApiResponse;
import com.gaebaljip.exceed.common.ApiResponseGenerator;
import com.gaebaljip.exceed.dto.request.CheckMemberRequest;
import com.gaebaljip.exceed.member.application.port.in.CheckCodeUsecase;

import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;

@RestController
@RequiredArgsConstructor
@RequestMapping("/v1")
@SecurityRequirement(name = "access-token")
@Tag(name = "[회원가입]")
public class CheckMemberEmailController {

private final CheckCodeUsecase checkCodeUsecase;

@GetMapping("/members/checked")
public ApiResponse<ApiResponse.CustomBody<Void>> checkMemberEmail(
@ModelAttribute @Valid CheckMemberRequest checkMemberRequest) {
checkCodeUsecase.execute(checkMemberRequest);
return ApiResponseGenerator.success(HttpStatus.OK);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ public ApiResponse<CustomBody<Void>> onBoardingMember(
@Parameter(hidden = true) @AuthenticationMemberId Long memberId) {
OnBoardingMemberCommand command = OnBoardingMemberCommand.of(memberId, request);
onBoardingMemberUsecase.execute(command);
return ApiResponseGenerator.success(HttpStatus.CREATED);
return ApiResponseGenerator.success(HttpStatus.OK);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.gaebaljip.exceed.common.ApiResponse.CustomBody;
import com.gaebaljip.exceed.common.ApiResponseGenerator;
import com.gaebaljip.exceed.common.swagger.ApiErrorExceptionsExample;
import com.gaebaljip.exceed.dto.request.CheckMemberRequest;
import com.gaebaljip.exceed.dto.request.SignUpMemberRequest;
import com.gaebaljip.exceed.member.application.port.in.*;
import com.gaebaljip.exceed.member.docs.SignUpMemberExceptionDocs;
Expand All @@ -29,8 +28,6 @@ public class SignUpMemberController {
private final ValidateEmailUsecase validateEmailUsecase;
private final SendEmailUsecase sendEmailUsecase;
private final CreateMemberUsecase createMemberUsecase;
private final CheckCodeUsecase checkCodeUsecase;
private final VerifyEmailCheckedUsecase verifyEmailCheckedUsecase;

@Operation(summary = "회원 가입", description = "회원 가입한다.")
@PostMapping("/members")
Expand All @@ -40,21 +37,6 @@ public ApiResponse<CustomBody<Void>> signUpMember(
validateEmailUsecase.execute(new ValidateEmailCommand(signUpMemberRequest.email()));
sendEmailUsecase.execute(new SendEmailCommand(signUpMemberRequest.email()));
createMemberUsecase.execute(signUpMemberRequest);
return ApiResponseGenerator.success(HttpStatus.OK);
}

@GetMapping("/members/checked")
public ApiResponse<CustomBody<Void>> checkMemberEmail(
@ModelAttribute @Valid CheckMemberRequest checkMemberRequest) {
checkCodeUsecase.execute(checkMemberRequest);
return ApiResponseGenerator.success(HttpStatus.OK);
}

@Operation(summary = "회원 가입후 이메일 인증 여부 확인", description = "회원 가입후 이메일 인증 여부 확인한다.")
@GetMapping("/members/email/checked")
public ApiResponse<CustomBody<Boolean>> verifyEmailChecked(
@RequestParam(value = "email") String email) {
Boolean isChecked = verifyEmailCheckedUsecase.execute(email);
return ApiResponseGenerator.success(isChecked, HttpStatus.OK);
return ApiResponseGenerator.success(HttpStatus.CREATED);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.gaebaljip.exceed.member.adapter.in;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.gaebaljip.exceed.common.ApiResponse;
import com.gaebaljip.exceed.common.ApiResponseGenerator;
import com.gaebaljip.exceed.member.application.port.in.VerifyEmailCheckedUsecase;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;

@RestController
@RequiredArgsConstructor
@RequestMapping("/v1")
@SecurityRequirement(name = "access-token")
@Tag(name = "[회원가입]")
public class VerifyEmailCheckedController {

private final VerifyEmailCheckedUsecase verifyEmailCheckedUsecase;

@Operation(summary = "회원 가입후 이메일 인증 여부 확인", description = "회원 가입후 이메일 인증 여부 확인한다.")
@GetMapping("/members/email/checked")
public ApiResponse<ApiResponse.CustomBody<Boolean>> verifyEmailChecked(
@RequestParam(value = "email") String email) {
Boolean isChecked = verifyEmailCheckedUsecase.execute(email);
return ApiResponseGenerator.success(isChecked, HttpStatus.OK);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import java.time.LocalDateTime;
import java.util.Optional;

import javax.persistence.EntityManager;

import org.springframework.stereotype.Repository;

import com.gaebaljip.exceed.member.adapter.out.persistence.MemberEntity;
Expand All @@ -19,7 +17,7 @@
@Repository
@RequiredArgsConstructor
public class CustomMemberRepositoryImpl implements CustomMemberRepository {
private final EntityManager em;

private final JPAQueryFactory queryFactory;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ValidateEmailService implements ValidateEmailUsecase {
@Override
@Transactional
public void execute(ValidateEmailCommand command) {
if (memberPort.existsByEmail(command.email()) || memberPort.isChecked(command.email())) {
if (memberPort.existsByEmail(command.email())) {
throw AlreadySignUpMemberException.EXECPTION;
}
}
Expand Down
Loading
Loading