diff --git a/src/main/kotlin/com/petqua/presentation/member/MemberController.kt b/src/main/kotlin/com/petqua/presentation/member/MemberController.kt index b1fdf902..1456769d 100644 --- a/src/main/kotlin/com/petqua/presentation/member/MemberController.kt +++ b/src/main/kotlin/com/petqua/presentation/member/MemberController.kt @@ -6,7 +6,6 @@ import com.petqua.common.config.SIGN_UP_TOKEN_SECURITY_SCHEME_KEY import com.petqua.domain.auth.Auth import com.petqua.domain.auth.LoginMember import com.petqua.domain.auth.SignUpGuest -import com.petqua.presentation.member.dto.MemberAddProfileRequest import com.petqua.presentation.member.dto.MemberSignUpRequest import com.petqua.presentation.member.dto.UpdateProfileRequest import io.swagger.v3.oas.annotations.Operation @@ -71,18 +70,18 @@ class MemberController( return ResponseEntity.noContent().build() } - @Operation(summary = "회원 물생활 프로필 입력 API", description = "회원의 추가적인 물생활 정보를 입력합니다") - @ApiResponse(responseCode = "204", description = "회원 물생활 프로필 입력 성공") - @SecurityRequirement(name = ACCESS_TOKEN_SECURITY_SCHEME_KEY) - @PostMapping("/profiles") - fun addProfile( - @Auth loginMember: LoginMember, - @RequestBody request: MemberAddProfileRequest, - ): ResponseEntity { - val command = request.toCommand(loginMember.memberId) - memberService.addProfile(command) - return ResponseEntity.noContent().build() - } +// @Operation(summary = "회원 물생활 프로필 입력 API", description = "회원의 추가적인 물생활 정보를 입력합니다") +// @ApiResponse(responseCode = "204", description = "회원 물생활 프로필 입력 성공") +// @SecurityRequirement(name = ACCESS_TOKEN_SECURITY_SCHEME_KEY) +// @PostMapping("/profiles") +// fun addProfile( +// @Auth loginMember: LoginMember, +// @RequestBody request: MemberAddProfileRequest, +// ): ResponseEntity { +// val command = request.toCommand(loginMember.memberId) +// memberService.addProfile(command) +// return ResponseEntity.noContent().build() +// } @Operation(summary = "회원 프로필 수정 API", description = "회원의 프로필 정보를 수정합니다") @ApiResponse(responseCode = "204", description = "회원 프로필 수정 성공") diff --git a/src/test/kotlin/com/petqua/presentation/member/MemberControllerTest.kt b/src/test/kotlin/com/petqua/presentation/member/MemberControllerTest.kt index e2d0c82a..04b8c691 100644 --- a/src/test/kotlin/com/petqua/presentation/member/MemberControllerTest.kt +++ b/src/test/kotlin/com/petqua/presentation/member/MemberControllerTest.kt @@ -8,8 +8,6 @@ import com.petqua.domain.fish.FishRepository import com.petqua.domain.member.FishTankRepository import com.petqua.domain.member.MemberRepository import com.petqua.domain.member.PetFishRepository -import com.petqua.domain.member.PetFishSex -import com.petqua.domain.member.TankSize import com.petqua.domain.member.nickname.NicknameWord import com.petqua.domain.member.nickname.NicknameWordRepository import com.petqua.domain.policy.bannedword.BannedWord @@ -18,14 +16,10 @@ import com.petqua.exception.member.MemberExceptionType import com.petqua.exception.member.MemberExceptionType.CONTAINING_BANNED_WORD_NAME import com.petqua.exception.member.MemberExceptionType.HAS_SIGNED_UP_MEMBER import com.petqua.exception.member.MemberExceptionType.NOT_FOUND_MEMBER -import com.petqua.presentation.member.dto.MemberAddProfileRequest import com.petqua.presentation.member.dto.MemberSignUpRequest -import com.petqua.presentation.member.dto.PetFishAddRequest import com.petqua.presentation.member.dto.UpdateProfileRequest import com.petqua.test.ApiTestConfig -import com.petqua.test.fixture.fish import com.petqua.test.fixture.member -import com.petqua.test.fixture.memberAddProfileRequest import io.kotest.assertions.assertSoftly import io.kotest.matchers.shouldBe import io.kotest.matchers.shouldNotBe @@ -36,10 +30,7 @@ import org.springframework.http.HttpStatus.BAD_REQUEST import org.springframework.http.HttpStatus.CREATED import org.springframework.http.HttpStatus.NOT_FOUND import org.springframework.http.HttpStatus.NO_CONTENT -import java.time.LocalDate -import java.time.YearMonth -import java.util.Date -import kotlin.Long.Companion.MIN_VALUE +import java.util.* class MemberControllerTest( private val nicknameWordRepository: NicknameWordRepository, @@ -140,181 +131,181 @@ class MemberControllerTest( } } } - - Given("회원 물생활 프로필을 등록할 때") { - nicknameWordRepository.saveAll( - listOf( - NicknameWord(word = "펫쿠아"), - NicknameWord(word = "물고기"), - ) - ) - bannedWordRepository.saveAll( - listOf( - BannedWord(word = "금지"), - BannedWord(word = "단어") - ) - ) - val fish = fishRepository.save(fish()) - - val accessToken = signInAsMember().accessToken - val memberId = getMemberIdByAccessToken(accessToken) - - When("어항과 수조, 반려어 등 정보를 입력하면") { - val request = MemberAddProfileRequest( - fishTankName = "펫쿠아 어항", - installationDate = YearMonth.of(2024, 3), - fishTankSize = "TANK_1", - fishLifeYear = 1, - petFishes = listOf( - PetFishAddRequest( - fishId = fish.id, - sex = "FEMALE", - count = 1 - ) - ) - ) - - val response = requestAddProfile(request, accessToken) - - Then("회원의 물생활 정보가 저장된다") { - assertSoftly { - response.statusCode shouldBe NO_CONTENT.value() - - val member = memberRepository.findByIdOrThrow(memberId) - member.fishTankCount shouldBe 1 - member.fishLifeYear.value shouldBe 1 - - val fishTank = fishTankRepository.findByMemberId(member.id)[0] - fishTank.memberId shouldBe member.id - fishTank.name.value shouldBe "펫쿠아 어항" - fishTank.installationDate shouldBe LocalDate.of(2024, 3, 1) - fishTank.size shouldBe TankSize.TANK_1 - - val petFish = petFishRepository.findByFishTankId(fishTank.id)[0] - petFish.memberId shouldBe member.id - petFish.fishId shouldBe fish.id - petFish.fishTankId shouldBe fishTank.id - petFish.sex shouldBe PetFishSex.FEMALE - petFish.count.value shouldBe 1 - } - } - } - - When("수조 이름으로 부적절한 단어를 입력하면") { - val request = memberAddProfileRequest(fishTankName = "금지단어포함이름") - val response = requestAddProfile(request, accessToken) - - Then("예외를 응답한다") { - val errorResponse = response.`as`(ExceptionResponse::class.java) - assertSoftly(response) { - statusCode shouldBe BAD_REQUEST.value() - errorResponse.message shouldBe CONTAINING_BANNED_WORD_NAME.errorMessage() - } - } - } - - When("유효하지 않은 물생활 경력을 입력하면") { - val request = memberAddProfileRequest(fishLifeYear = -1) - val response = requestAddProfile(request, accessToken) - - Then("예외를 응답한다") { - val errorResponse = response.`as`(ExceptionResponse::class.java) - assertSoftly(response) { - statusCode shouldBe BAD_REQUEST.value() - errorResponse.message shouldBe MemberExceptionType.INVALID_MEMBER_FISH_LIFE_YEAR.errorMessage() - } - } - } - - When("수조 이름 정책을 위반해서 입력하면") { - val request = memberAddProfileRequest(fishTankName = "열 여 덟 자 이 상 으 로 긴 어 항 이 름") - val response = requestAddProfile(request, accessToken) - - Then("예외를 응답한다") { - val errorResponse = response.`as`(ExceptionResponse::class.java) - assertSoftly(response) { - statusCode shouldBe BAD_REQUEST.value() - errorResponse.message shouldBe MemberExceptionType.INVALID_MEMBER_FISH_TANK_NAME.errorMessage() - } - } - } - - When("존재하지 않는 수조 크기를 입력하면") { - val request = memberAddProfileRequest(fishTankSize = "TANK_100") - val response = requestAddProfile(request, accessToken) - - Then("예외를 응답한다") { - val errorResponse = response.`as`(ExceptionResponse::class.java) - assertSoftly(response) { - statusCode shouldBe BAD_REQUEST.value() - errorResponse.message shouldBe MemberExceptionType.INVALID_MEMBER_FISH_TANK_SIZE.errorMessage() - } - } - } - - When("존재하지 않는 반려어 id를 입력하면") { - val request = memberAddProfileRequest( - petFishes = listOf( - PetFishAddRequest( - fishId = MIN_VALUE, - sex = "FEMALE", - count = 1 - ) - ) - ) - val response = requestAddProfile(request, accessToken) - - Then("예외를 응답한다") { - val errorResponse = response.`as`(ExceptionResponse::class.java) - assertSoftly(response) { - statusCode shouldBe BAD_REQUEST.value() - errorResponse.message shouldBe MemberExceptionType.INVALID_MEMBER_PET_FISH.errorMessage() - } - } - } - - When("존재하지 않는 반려어 성별을 입력하면") { - val request = memberAddProfileRequest( - petFishes = listOf( - PetFishAddRequest( - fishId = MIN_VALUE, - sex = "수컷", - count = 1 - ) - ) - ) - val response = requestAddProfile(request, accessToken) - - Then("예외를 응답한다") { - val errorResponse = response.`as`(ExceptionResponse::class.java) - assertSoftly(response) { - statusCode shouldBe BAD_REQUEST.value() - errorResponse.message shouldBe MemberExceptionType.INVALID_MEMBER_FISH_SEX.errorMessage() - } - } - } - - When("유효하지 않은 반려어 마릿수를 입력하면") { - val request = memberAddProfileRequest( - petFishes = listOf( - PetFishAddRequest( - fishId = MIN_VALUE, - sex = "FEMALE", - count = -1 - ) - ) - ) - val response = requestAddProfile(request, accessToken) - - Then("예외를 응답한다") { - val errorResponse = response.`as`(ExceptionResponse::class.java) - assertSoftly(response) { - statusCode shouldBe BAD_REQUEST.value() - errorResponse.message shouldBe MemberExceptionType.INVALID_MEMBER_PET_FISH_COUNT.errorMessage() - } - } - } - } +// +// Given("회원 물생활 프로필을 등록할 때") { +// nicknameWordRepository.saveAll( +// listOf( +// NicknameWord(word = "펫쿠아"), +// NicknameWord(word = "물고기"), +// ) +// ) +// bannedWordRepository.saveAll( +// listOf( +// BannedWord(word = "금지"), +// BannedWord(word = "단어") +// ) +// ) +// val fish = fishRepository.save(fish()) +// +// val accessToken = signInAsMember().accessToken +// val memberId = getMemberIdByAccessToken(accessToken) +// +// When("어항과 수조, 반려어 등 정보를 입력하면") { +// val request = MemberAddProfileRequest( +// fishTankName = "펫쿠아 어항", +// installationDate = YearMonth.of(2024, 3), +// fishTankSize = "TANK_1", +// fishLifeYear = 1, +// petFishes = listOf( +// PetFishAddRequest( +// fishId = fish.id, +// sex = "FEMALE", +// count = 1 +// ) +// ) +// ) +// +// val response = requestAddProfile(request, accessToken) +// +// Then("회원의 물생활 정보가 저장된다") { +// assertSoftly { +// response.statusCode shouldBe NO_CONTENT.value() +// +// val member = memberRepository.findByIdOrThrow(memberId) +// member.fishTankCount shouldBe 1 +// member.fishLifeYear.value shouldBe 1 +// +// val fishTank = fishTankRepository.findByMemberId(member.id)[0] +// fishTank.memberId shouldBe member.id +// fishTank.name.value shouldBe "펫쿠아 어항" +// fishTank.installationDate shouldBe LocalDate.of(2024, 3, 1) +// fishTank.size shouldBe TankSize.TANK_1 +// +// val petFish = petFishRepository.findByFishTankId(fishTank.id)[0] +// petFish.memberId shouldBe member.id +// petFish.fishId shouldBe fish.id +// petFish.fishTankId shouldBe fishTank.id +// petFish.sex shouldBe PetFishSex.FEMALE +// petFish.count.value shouldBe 1 +// } +// } +// } +// +// When("수조 이름으로 부적절한 단어를 입력하면") { +// val request = memberAddProfileRequest(fishTankName = "금지단어포함이름") +// val response = requestAddProfile(request, accessToken) +// +// Then("예외를 응답한다") { +// val errorResponse = response.`as`(ExceptionResponse::class.java) +// assertSoftly(response) { +// statusCode shouldBe BAD_REQUEST.value() +// errorResponse.message shouldBe CONTAINING_BANNED_WORD_NAME.errorMessage() +// } +// } +// } +// +// When("유효하지 않은 물생활 경력을 입력하면") { +// val request = memberAddProfileRequest(fishLifeYear = -1) +// val response = requestAddProfile(request, accessToken) +// +// Then("예외를 응답한다") { +// val errorResponse = response.`as`(ExceptionResponse::class.java) +// assertSoftly(response) { +// statusCode shouldBe BAD_REQUEST.value() +// errorResponse.message shouldBe MemberExceptionType.INVALID_MEMBER_FISH_LIFE_YEAR.errorMessage() +// } +// } +// } +// +// When("수조 이름 정책을 위반해서 입력하면") { +// val request = memberAddProfileRequest(fishTankName = "열 여 덟 자 이 상 으 로 긴 어 항 이 름") +// val response = requestAddProfile(request, accessToken) +// +// Then("예외를 응답한다") { +// val errorResponse = response.`as`(ExceptionResponse::class.java) +// assertSoftly(response) { +// statusCode shouldBe BAD_REQUEST.value() +// errorResponse.message shouldBe MemberExceptionType.INVALID_MEMBER_FISH_TANK_NAME.errorMessage() +// } +// } +// } +// +// When("존재하지 않는 수조 크기를 입력하면") { +// val request = memberAddProfileRequest(fishTankSize = "TANK_100") +// val response = requestAddProfile(request, accessToken) +// +// Then("예외를 응답한다") { +// val errorResponse = response.`as`(ExceptionResponse::class.java) +// assertSoftly(response) { +// statusCode shouldBe BAD_REQUEST.value() +// errorResponse.message shouldBe MemberExceptionType.INVALID_MEMBER_FISH_TANK_SIZE.errorMessage() +// } +// } +// } +// +// When("존재하지 않는 반려어 id를 입력하면") { +// val request = memberAddProfileRequest( +// petFishes = listOf( +// PetFishAddRequest( +// fishId = MIN_VALUE, +// sex = "FEMALE", +// count = 1 +// ) +// ) +// ) +// val response = requestAddProfile(request, accessToken) +// +// Then("예외를 응답한다") { +// val errorResponse = response.`as`(ExceptionResponse::class.java) +// assertSoftly(response) { +// statusCode shouldBe BAD_REQUEST.value() +// errorResponse.message shouldBe MemberExceptionType.INVALID_MEMBER_PET_FISH.errorMessage() +// } +// } +// } +// +// When("존재하지 않는 반려어 성별을 입력하면") { +// val request = memberAddProfileRequest( +// petFishes = listOf( +// PetFishAddRequest( +// fishId = MIN_VALUE, +// sex = "수컷", +// count = 1 +// ) +// ) +// ) +// val response = requestAddProfile(request, accessToken) +// +// Then("예외를 응답한다") { +// val errorResponse = response.`as`(ExceptionResponse::class.java) +// assertSoftly(response) { +// statusCode shouldBe BAD_REQUEST.value() +// errorResponse.message shouldBe MemberExceptionType.INVALID_MEMBER_FISH_SEX.errorMessage() +// } +// } +// } +// +// When("유효하지 않은 반려어 마릿수를 입력하면") { +// val request = memberAddProfileRequest( +// petFishes = listOf( +// PetFishAddRequest( +// fishId = MIN_VALUE, +// sex = "FEMALE", +// count = -1 +// ) +// ) +// ) +// val response = requestAddProfile(request, accessToken) +// +// Then("예외를 응답한다") { +// val errorResponse = response.`as`(ExceptionResponse::class.java) +// assertSoftly(response) { +// statusCode shouldBe BAD_REQUEST.value() +// errorResponse.message shouldBe MemberExceptionType.INVALID_MEMBER_PET_FISH_COUNT.errorMessage() +// } +// } +// } +// } Given("회원 프로필을 수정할 때") { val accessToken = signInAsMember().accessToken