From ed8ada99448de917bea03373000ee3f9ad2785f3 Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Thu, 4 Jan 2024 17:35:14 +0900 Subject: [PATCH 01/25] =?UTF-8?q?feat=20:=20Owner=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=EC=9D=84=20=EC=9C=84=ED=95=9C=20email=20&=20Password?= =?UTF-8?q?=20=ED=95=84=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/prgrms/catchtable/owner/domain/Owner.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/prgrms/catchtable/owner/domain/Owner.java b/src/main/java/com/prgrms/catchtable/owner/domain/Owner.java index f6d09f8f..64b7ea81 100644 --- a/src/main/java/com/prgrms/catchtable/owner/domain/Owner.java +++ b/src/main/java/com/prgrms/catchtable/owner/domain/Owner.java @@ -35,6 +35,12 @@ public class Owner extends BaseEntity { @Column(name = "owner_name") private String name; + @Column(name = "email") + private String email; + + @Column(name = "password") + private String password; + @Column(name = "phone_number") private String phoneNumber; @@ -50,8 +56,10 @@ public class Owner extends BaseEntity { private Shop shop; @Builder - public Owner(String name, String phoneNumber, Gender gender, LocalDate dateBirth) { + public Owner(String name, String email, String password, String phoneNumber, Gender gender, LocalDate dateBirth) { this.name = name; + this.email = email; + this.password = password; this.phoneNumber = phoneNumber; this.gender = gender; this.dateBirth = dateBirth; From 28c3c45261c70891992c4353c8076fb1323baa66 Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Thu, 4 Jan 2024 17:36:32 +0900 Subject: [PATCH 02/25] =?UTF-8?q?feat=20:=20Owner=20=ED=9A=8C=EC=9B=90?= =?UTF-8?q?=EA=B0=80=EC=9E=85=20dto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../catchtable/owner/dto/OwnerMapper.java | 31 +++++++++++++++++++ .../owner/dto/request/JoinOwnerRequest.java | 21 +++++++++++++ .../owner/dto/response/JoinOwnerResponse.java | 16 ++++++++++ 3 files changed, 68 insertions(+) create mode 100644 src/main/java/com/prgrms/catchtable/owner/dto/OwnerMapper.java create mode 100644 src/main/java/com/prgrms/catchtable/owner/dto/request/JoinOwnerRequest.java create mode 100644 src/main/java/com/prgrms/catchtable/owner/dto/response/JoinOwnerResponse.java diff --git a/src/main/java/com/prgrms/catchtable/owner/dto/OwnerMapper.java b/src/main/java/com/prgrms/catchtable/owner/dto/OwnerMapper.java new file mode 100644 index 00000000..bca17dd2 --- /dev/null +++ b/src/main/java/com/prgrms/catchtable/owner/dto/OwnerMapper.java @@ -0,0 +1,31 @@ +package com.prgrms.catchtable.owner.dto; + +import com.prgrms.catchtable.member.domain.Gender; +import com.prgrms.catchtable.owner.domain.Owner; +import com.prgrms.catchtable.owner.dto.request.JoinOwnerRequest; +import com.prgrms.catchtable.owner.dto.response.JoinOwnerResponse; + +public class OwnerMapper { + + public static Owner toEntity(JoinOwnerRequest joinOwnerRequest, String encodePassword, Gender gender){ + return Owner.builder() + .name(joinOwnerRequest.name()) + .email(joinOwnerRequest.email()) + .password(joinOwnerRequest.password()) + .phoneNumber(joinOwnerRequest.phoneNumber()) + .gender(gender) + .dateBirth(joinOwnerRequest.dateBirth()) + .build(); + } + + public static JoinOwnerResponse from(Owner owner){ + return JoinOwnerResponse.builder() + .name(owner.getName()) + .email(owner.getEmail()) + .phoneNumber(owner.getPhoneNumber()) + .gender(owner.getGender().getType()) + .dateBirth(owner.getDateBirth()) + .build(); + } + +} diff --git a/src/main/java/com/prgrms/catchtable/owner/dto/request/JoinOwnerRequest.java b/src/main/java/com/prgrms/catchtable/owner/dto/request/JoinOwnerRequest.java new file mode 100644 index 00000000..80c67856 --- /dev/null +++ b/src/main/java/com/prgrms/catchtable/owner/dto/request/JoinOwnerRequest.java @@ -0,0 +1,21 @@ +package com.prgrms.catchtable.owner.dto.request; + +import com.fasterxml.jackson.annotation.JsonFormat; +import jakarta.validation.constraints.Email; +import jakarta.validation.constraints.Pattern; +import java.time.LocalDate; + +public record JoinOwnerRequest( + + String name, + @Email + String email, + String password, + @Pattern(regexp = "^(01[016789]){1}([0-9]{3,4}){1}([0-9]{4}){1}$") + String phoneNumber, + String gender, + @JsonFormat(pattern = "yyyy-MM-dd") + LocalDate dateBirth +) { + +} diff --git a/src/main/java/com/prgrms/catchtable/owner/dto/response/JoinOwnerResponse.java b/src/main/java/com/prgrms/catchtable/owner/dto/response/JoinOwnerResponse.java new file mode 100644 index 00000000..766c0606 --- /dev/null +++ b/src/main/java/com/prgrms/catchtable/owner/dto/response/JoinOwnerResponse.java @@ -0,0 +1,16 @@ +package com.prgrms.catchtable.owner.dto.response; + +import java.time.LocalDate; +import lombok.Builder; + +@Builder +public record JoinOwnerResponse( + + String name, + String email, + String phoneNumber, + String gender, + LocalDate dateBirth +) { + +} From 2179ae05611130dbfa55d78b594c13792c60b4fa Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Thu, 4 Jan 2024 17:36:50 +0900 Subject: [PATCH 03/25] feat : PasswordEncoder --- .../prgrms/catchtable/security/config/SecurityConfig.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/prgrms/catchtable/security/config/SecurityConfig.java b/src/main/java/com/prgrms/catchtable/security/config/SecurityConfig.java index 4871a801..2dc6af45 100644 --- a/src/main/java/com/prgrms/catchtable/security/config/SecurityConfig.java +++ b/src/main/java/com/prgrms/catchtable/security/config/SecurityConfig.java @@ -10,6 +10,8 @@ import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; import org.springframework.security.config.http.SessionCreationPolicy; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.oauth2.client.web.OAuth2AuthorizationRequestRedirectFilter; import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.util.matcher.AntPathRequestMatcher; @@ -24,6 +26,11 @@ public class SecurityConfig { private final ExceptionHandlerFilter exceptionHandlerFilter; private final JwtAuthenticationFilter jwtAuthenticationFilter; + @Bean + public PasswordEncoder passwordEncoder(){ + return new BCryptPasswordEncoder(); + } + @Bean public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { From ae90cfb45b70a86a262e76eccde51e5b3d7d66ae Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Thu, 4 Jan 2024 17:41:16 +0900 Subject: [PATCH 04/25] =?UTF-8?q?fix=20:=20=EC=A0=80=EC=9E=A5=20=EC=8B=9C?= =?UTF-8?q?=20encoding=EB=90=9C=20Password=20=EC=A0=80=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/prgrms/catchtable/owner/dto/OwnerMapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/prgrms/catchtable/owner/dto/OwnerMapper.java b/src/main/java/com/prgrms/catchtable/owner/dto/OwnerMapper.java index bca17dd2..36386be2 100644 --- a/src/main/java/com/prgrms/catchtable/owner/dto/OwnerMapper.java +++ b/src/main/java/com/prgrms/catchtable/owner/dto/OwnerMapper.java @@ -11,7 +11,7 @@ public static Owner toEntity(JoinOwnerRequest joinOwnerRequest, String encodePas return Owner.builder() .name(joinOwnerRequest.name()) .email(joinOwnerRequest.email()) - .password(joinOwnerRequest.password()) + .password(encodePassword) .phoneNumber(joinOwnerRequest.phoneNumber()) .gender(gender) .dateBirth(joinOwnerRequest.dateBirth()) From 76678a99cb970d6742744a09713d6f08002d537b Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Thu, 4 Jan 2024 17:48:16 +0900 Subject: [PATCH 05/25] =?UTF-8?q?feat=20:=20=EC=84=B1=EB=B3=84=20=EC=9E=85?= =?UTF-8?q?=EB=A0=A5=EC=97=90=20=EB=8C=80=ED=95=9C=20=ED=83=80=EC=9E=85=20?= =?UTF-8?q?=EA=B2=80=EC=A6=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/exception/ErrorCode.java | 4 ++- .../catchtable/member/domain/Gender.java | 26 +++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/prgrms/catchtable/common/exception/ErrorCode.java b/src/main/java/com/prgrms/catchtable/common/exception/ErrorCode.java index cff7cd26..5c7df7f4 100644 --- a/src/main/java/com/prgrms/catchtable/common/exception/ErrorCode.java +++ b/src/main/java/com/prgrms/catchtable/common/exception/ErrorCode.java @@ -18,7 +18,9 @@ public enum ErrorCode { CAN_NOT_COMPLETE_WAITING("입장 처리가 불가한 대기 상태입니다."), EXISTING_MEMBER_WAITING("이미 회원이 웨이팅 중인 가게가 존재합니다."), SHOP_NOT_RUNNING("가게가 영업시간이 아닙니다."), - INTERNAL_SERVER_ERROR("내부 서버 오류입니다."); + INTERNAL_SERVER_ERROR("내부 서버 오류입니다."), + + BAD_REQUEST_INPUT_GENDER_TYPE("성별 타입을 양식대로 입력해주세요"); private final String message; } diff --git a/src/main/java/com/prgrms/catchtable/member/domain/Gender.java b/src/main/java/com/prgrms/catchtable/member/domain/Gender.java index 7339bcfe..999f8a71 100644 --- a/src/main/java/com/prgrms/catchtable/member/domain/Gender.java +++ b/src/main/java/com/prgrms/catchtable/member/domain/Gender.java @@ -1,6 +1,28 @@ package com.prgrms.catchtable.member.domain; +import static com.prgrms.catchtable.common.exception.ErrorCode.*; + +import com.prgrms.catchtable.common.exception.custom.BadRequestCustomException; +import java.util.Arrays; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor public enum Gender { - MALE, - FEMALE + MALE("male"), + FEMALE("female"); + + private final String type; + + public static Gender of(String input){ + return Arrays.stream(values()) + .filter(gender -> gender.isEqual(input)) + .findAny() + .orElseThrow(() -> new BadRequestCustomException(BAD_REQUEST_INPUT_GENDER_TYPE)); + } + + private boolean isEqual(String input){ + return input.equals(this.type); + } } From 15849da642c8e0f666070f8908c02e6601f300ee Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Thu, 4 Jan 2024 17:49:12 +0900 Subject: [PATCH 06/25] =?UTF-8?q?feat=20:=20Owner=20=ED=9A=8C=EC=9B=90?= =?UTF-8?q?=EA=B0=80=EC=9E=85=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/exception/ErrorCode.java | 1 + .../owner/repository/OwnerRepository.java | 2 + .../owner/service/OwnerService.java | 40 +++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 src/main/java/com/prgrms/catchtable/owner/service/OwnerService.java diff --git a/src/main/java/com/prgrms/catchtable/common/exception/ErrorCode.java b/src/main/java/com/prgrms/catchtable/common/exception/ErrorCode.java index 5c7df7f4..e0ef1d00 100644 --- a/src/main/java/com/prgrms/catchtable/common/exception/ErrorCode.java +++ b/src/main/java/com/prgrms/catchtable/common/exception/ErrorCode.java @@ -20,6 +20,7 @@ public enum ErrorCode { SHOP_NOT_RUNNING("가게가 영업시간이 아닙니다."), INTERNAL_SERVER_ERROR("내부 서버 오류입니다."), + ALREADY_EXIST_OWNER("이미 존재하는 점주입니다"), BAD_REQUEST_INPUT_GENDER_TYPE("성별 타입을 양식대로 입력해주세요"); private final String message; diff --git a/src/main/java/com/prgrms/catchtable/owner/repository/OwnerRepository.java b/src/main/java/com/prgrms/catchtable/owner/repository/OwnerRepository.java index 3dbeb442..be512d0f 100644 --- a/src/main/java/com/prgrms/catchtable/owner/repository/OwnerRepository.java +++ b/src/main/java/com/prgrms/catchtable/owner/repository/OwnerRepository.java @@ -5,4 +5,6 @@ public interface OwnerRepository extends JpaRepository { + boolean existsOwnerByEmail(String email); + } diff --git a/src/main/java/com/prgrms/catchtable/owner/service/OwnerService.java b/src/main/java/com/prgrms/catchtable/owner/service/OwnerService.java new file mode 100644 index 00000000..cc7518dc --- /dev/null +++ b/src/main/java/com/prgrms/catchtable/owner/service/OwnerService.java @@ -0,0 +1,40 @@ +package com.prgrms.catchtable.owner.service; + +import static com.prgrms.catchtable.common.exception.ErrorCode.*; + +import com.prgrms.catchtable.common.exception.custom.BadRequestCustomException; +import com.prgrms.catchtable.member.domain.Gender; +import com.prgrms.catchtable.owner.domain.Owner; +import com.prgrms.catchtable.owner.dto.OwnerMapper; +import com.prgrms.catchtable.owner.dto.request.JoinOwnerRequest; +import com.prgrms.catchtable.owner.dto.response.JoinOwnerResponse; +import com.prgrms.catchtable.owner.repository.OwnerRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class OwnerService { + + private final OwnerRepository ownerRepository; + private final PasswordEncoder passwordEncoder; + + public JoinOwnerResponse joinOwner(JoinOwnerRequest joinOwnerRequest) { + + //이미 존재하는 이메일이라면 + if (ownerRepository.existsOwnerByEmail(joinOwnerRequest.email())) { + throw new BadRequestCustomException(ALREADY_EXIST_OWNER); + } + + String encodePassword = passwordEncoder.encode(joinOwnerRequest.password()); + + Gender gender = Gender.of(joinOwnerRequest.gender()); + + Owner joinOwner = ownerRepository.save(OwnerMapper.toEntity(joinOwnerRequest, encodePassword, gender)); + + return OwnerMapper.from(joinOwner); + + } + +} From 5b67aeaa4bfc40619b3a928f0d568206aabbd576 Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Thu, 4 Jan 2024 17:58:04 +0900 Subject: [PATCH 07/25] =?UTF-8?q?feat=20:=20Owner=20=ED=9A=8C=EC=9B=90?= =?UTF-8?q?=EA=B0=80=EC=9E=85=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../owner/controller/OwnerController.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/main/java/com/prgrms/catchtable/owner/controller/OwnerController.java diff --git a/src/main/java/com/prgrms/catchtable/owner/controller/OwnerController.java b/src/main/java/com/prgrms/catchtable/owner/controller/OwnerController.java new file mode 100644 index 00000000..39dedd68 --- /dev/null +++ b/src/main/java/com/prgrms/catchtable/owner/controller/OwnerController.java @@ -0,0 +1,29 @@ +package com.prgrms.catchtable.owner.controller; + +import com.prgrms.catchtable.owner.dto.request.JoinOwnerRequest; +import com.prgrms.catchtable.owner.dto.response.JoinOwnerResponse; +import com.prgrms.catchtable.owner.service.OwnerService; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/owners") +public class OwnerController { + + private final OwnerService ownerService; + + @PostMapping("/join") + public ResponseEntity join(@Valid @RequestBody JoinOwnerRequest joinOwnerRequest){ + JoinOwnerResponse joinOwnerResponse = ownerService.joinOwner(joinOwnerRequest); + + return ResponseEntity.status(HttpStatus.CREATED).body(joinOwnerResponse); + } + +} From 22cfd9bde0e927b656794d3313709517ee42ca98 Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Thu, 4 Jan 2024 18:18:21 +0900 Subject: [PATCH 08/25] =?UTF-8?q?feat=20:=20UserDetails=20=EC=83=81?= =?UTF-8?q?=EC=86=8D=20&=20role=20=ED=95=84=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../prgrms/catchtable/owner/domain/Owner.java | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/prgrms/catchtable/owner/domain/Owner.java b/src/main/java/com/prgrms/catchtable/owner/domain/Owner.java index 64b7ea81..7d397eba 100644 --- a/src/main/java/com/prgrms/catchtable/owner/domain/Owner.java +++ b/src/main/java/com/prgrms/catchtable/owner/domain/Owner.java @@ -6,11 +6,13 @@ import static lombok.AccessLevel.PROTECTED; import com.prgrms.catchtable.common.BaseEntity; +import com.prgrms.catchtable.common.Role; import com.prgrms.catchtable.member.domain.Gender; import com.prgrms.catchtable.shop.domain.Shop; import jakarta.persistence.Column; import jakarta.persistence.ConstraintMode; import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; import jakarta.persistence.Enumerated; import jakarta.persistence.ForeignKey; import jakarta.persistence.GeneratedValue; @@ -18,14 +20,19 @@ import jakarta.persistence.JoinColumn; import jakarta.persistence.OneToOne; import java.time.LocalDate; +import java.util.Collection; +import java.util.Collections; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.core.userdetails.UserDetails; @Getter @NoArgsConstructor(access = PROTECTED) @Entity -public class Owner extends BaseEntity { +public class Owner extends BaseEntity implements UserDetails { @Id @GeneratedValue(strategy = IDENTITY) @@ -48,6 +55,10 @@ public class Owner extends BaseEntity { @Enumerated(STRING) private Gender gender; + @Column(name = "role") + @Enumerated(STRING) + private Role role; + @Column(name = "date_birth") private LocalDate dateBirth; @@ -63,5 +74,36 @@ public Owner(String name, String email, String password, String phoneNumber, Gen this.phoneNumber = phoneNumber; this.gender = gender; this.dateBirth = dateBirth; + this.role = Role.OWNER; + } + + @Override + public Collection getAuthorities() { + return Collections.singletonList(new SimpleGrantedAuthority(role.getRole())); + } + + @Override + public String getUsername() { + return email; + } + + @Override + public boolean isAccountNonExpired() { + return true; + } + + @Override + public boolean isAccountNonLocked() { + return true; + } + + @Override + public boolean isCredentialsNonExpired() { + return true; + } + + @Override + public boolean isEnabled() { + return true; } } From eed4958c83a4ffba43de7997e7206d15de728557 Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Thu, 4 Jan 2024 18:31:59 +0900 Subject: [PATCH 09/25] =?UTF-8?q?feat=20:=20Owner=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../catchtable/common/exception/ErrorCode.java | 1 + .../owner/dto/request/LoginOwnerRequest.java | 13 +++++++++++++ .../owner/repository/OwnerRepository.java | 3 +++ .../catchtable/owner/service/OwnerService.java | 18 ++++++++++++++++++ 4 files changed, 35 insertions(+) create mode 100644 src/main/java/com/prgrms/catchtable/owner/dto/request/LoginOwnerRequest.java diff --git a/src/main/java/com/prgrms/catchtable/common/exception/ErrorCode.java b/src/main/java/com/prgrms/catchtable/common/exception/ErrorCode.java index e0ef1d00..fc11434b 100644 --- a/src/main/java/com/prgrms/catchtable/common/exception/ErrorCode.java +++ b/src/main/java/com/prgrms/catchtable/common/exception/ErrorCode.java @@ -21,6 +21,7 @@ public enum ErrorCode { INTERNAL_SERVER_ERROR("내부 서버 오류입니다."), ALREADY_EXIST_OWNER("이미 존재하는 점주입니다"), + BAD_REQUEST_EMAIL_OR_PASSWORD("이메일 혹은 비밀번호를 확인해주세요"), BAD_REQUEST_INPUT_GENDER_TYPE("성별 타입을 양식대로 입력해주세요"); private final String message; diff --git a/src/main/java/com/prgrms/catchtable/owner/dto/request/LoginOwnerRequest.java b/src/main/java/com/prgrms/catchtable/owner/dto/request/LoginOwnerRequest.java new file mode 100644 index 00000000..91368d5f --- /dev/null +++ b/src/main/java/com/prgrms/catchtable/owner/dto/request/LoginOwnerRequest.java @@ -0,0 +1,13 @@ +package com.prgrms.catchtable.owner.dto.request; + +import jakarta.validation.constraints.Email; + +public record LoginOwnerRequest( + + @Email + String email, + String password + +) { + +} diff --git a/src/main/java/com/prgrms/catchtable/owner/repository/OwnerRepository.java b/src/main/java/com/prgrms/catchtable/owner/repository/OwnerRepository.java index be512d0f..5e783c0e 100644 --- a/src/main/java/com/prgrms/catchtable/owner/repository/OwnerRepository.java +++ b/src/main/java/com/prgrms/catchtable/owner/repository/OwnerRepository.java @@ -1,10 +1,13 @@ package com.prgrms.catchtable.owner.repository; import com.prgrms.catchtable.owner.domain.Owner; +import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; public interface OwnerRepository extends JpaRepository { boolean existsOwnerByEmail(String email); + Optional findOwnerByEmail(String email); + } diff --git a/src/main/java/com/prgrms/catchtable/owner/service/OwnerService.java b/src/main/java/com/prgrms/catchtable/owner/service/OwnerService.java index cc7518dc..a425756f 100644 --- a/src/main/java/com/prgrms/catchtable/owner/service/OwnerService.java +++ b/src/main/java/com/prgrms/catchtable/owner/service/OwnerService.java @@ -3,10 +3,13 @@ import static com.prgrms.catchtable.common.exception.ErrorCode.*; import com.prgrms.catchtable.common.exception.custom.BadRequestCustomException; +import com.prgrms.catchtable.jwt.provider.JwtTokenProvider; +import com.prgrms.catchtable.jwt.token.Token; import com.prgrms.catchtable.member.domain.Gender; import com.prgrms.catchtable.owner.domain.Owner; import com.prgrms.catchtable.owner.dto.OwnerMapper; import com.prgrms.catchtable.owner.dto.request.JoinOwnerRequest; +import com.prgrms.catchtable.owner.dto.request.LoginOwnerRequest; import com.prgrms.catchtable.owner.dto.response.JoinOwnerResponse; import com.prgrms.catchtable.owner.repository.OwnerRepository; import lombok.RequiredArgsConstructor; @@ -19,6 +22,7 @@ public class OwnerService { private final OwnerRepository ownerRepository; private final PasswordEncoder passwordEncoder; + private final JwtTokenProvider jwtTokenProvider; public JoinOwnerResponse joinOwner(JoinOwnerRequest joinOwnerRequest) { @@ -37,4 +41,18 @@ public JoinOwnerResponse joinOwner(JoinOwnerRequest joinOwnerRequest) { } + public Token ownerLogin(LoginOwnerRequest loginRequest){ + + //email 확인 + Owner loginOwner = ownerRepository.findOwnerByEmail(loginRequest.email()) + .orElseThrow(() -> new BadRequestCustomException(BAD_REQUEST_EMAIL_OR_PASSWORD)); + + //password 확인 + if(passwordEncoder.matches(loginRequest.password(), loginOwner.getPassword())){ + throw new BadRequestCustomException(BAD_REQUEST_EMAIL_OR_PASSWORD); + } + + return jwtTokenProvider.createToken(loginOwner.getEmail()); + } + } From 44c78afb00441625d8cf6138e9c10f8469e4949f Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Thu, 4 Jan 2024 18:34:19 +0900 Subject: [PATCH 10/25] =?UTF-8?q?refactor=20:=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/prgrms/catchtable/owner/service/OwnerService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/prgrms/catchtable/owner/service/OwnerService.java b/src/main/java/com/prgrms/catchtable/owner/service/OwnerService.java index a425756f..464ebd7d 100644 --- a/src/main/java/com/prgrms/catchtable/owner/service/OwnerService.java +++ b/src/main/java/com/prgrms/catchtable/owner/service/OwnerService.java @@ -41,7 +41,7 @@ public JoinOwnerResponse joinOwner(JoinOwnerRequest joinOwnerRequest) { } - public Token ownerLogin(LoginOwnerRequest loginRequest){ + public Token loginOwner(LoginOwnerRequest loginRequest){ //email 확인 Owner loginOwner = ownerRepository.findOwnerByEmail(loginRequest.email()) From 2fe4fb521ea8defed8ad63af48e0c730e3960258 Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Thu, 4 Jan 2024 18:34:31 +0900 Subject: [PATCH 11/25] =?UTF-8?q?feat=20:=20Owner=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../catchtable/owner/controller/OwnerController.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/prgrms/catchtable/owner/controller/OwnerController.java b/src/main/java/com/prgrms/catchtable/owner/controller/OwnerController.java index 39dedd68..8a047521 100644 --- a/src/main/java/com/prgrms/catchtable/owner/controller/OwnerController.java +++ b/src/main/java/com/prgrms/catchtable/owner/controller/OwnerController.java @@ -1,6 +1,8 @@ package com.prgrms.catchtable.owner.controller; +import com.prgrms.catchtable.jwt.token.Token; import com.prgrms.catchtable.owner.dto.request.JoinOwnerRequest; +import com.prgrms.catchtable.owner.dto.request.LoginOwnerRequest; import com.prgrms.catchtable.owner.dto.response.JoinOwnerResponse; import com.prgrms.catchtable.owner.service.OwnerService; import jakarta.validation.Valid; @@ -26,4 +28,11 @@ public ResponseEntity join(@Valid @RequestBody JoinOwnerReque return ResponseEntity.status(HttpStatus.CREATED).body(joinOwnerResponse); } + @PostMapping("/login") + public ResponseEntity login(@Valid @RequestBody LoginOwnerRequest loginOwnerRequest){ + Token responseToken = ownerService.loginOwner(loginOwnerRequest); + + return ResponseEntity.ok(responseToken); + } + } From 135068d5e8d06d345573c8168b2adc0ad644ab61 Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Fri, 5 Jan 2024 01:53:18 +0900 Subject: [PATCH 12/25] =?UTF-8?q?refactor=20:=20=EA=B2=80=EC=A6=9D=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../catchtable/owner/service/OwnerService.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/prgrms/catchtable/owner/service/OwnerService.java b/src/main/java/com/prgrms/catchtable/owner/service/OwnerService.java index 464ebd7d..da30bcf8 100644 --- a/src/main/java/com/prgrms/catchtable/owner/service/OwnerService.java +++ b/src/main/java/com/prgrms/catchtable/owner/service/OwnerService.java @@ -27,9 +27,7 @@ public class OwnerService { public JoinOwnerResponse joinOwner(JoinOwnerRequest joinOwnerRequest) { //이미 존재하는 이메일이라면 - if (ownerRepository.existsOwnerByEmail(joinOwnerRequest.email())) { - throw new BadRequestCustomException(ALREADY_EXIST_OWNER); - } + validateExistsOwner(joinOwnerRequest); String encodePassword = passwordEncoder.encode(joinOwnerRequest.password()); @@ -41,6 +39,12 @@ public JoinOwnerResponse joinOwner(JoinOwnerRequest joinOwnerRequest) { } + private void validateExistsOwner(JoinOwnerRequest joinOwnerRequest) { + if (ownerRepository.existsOwnerByEmail(joinOwnerRequest.email())) { + throw new BadRequestCustomException(ALREADY_EXIST_OWNER); + } + } + public Token loginOwner(LoginOwnerRequest loginRequest){ //email 확인 @@ -48,11 +52,15 @@ public Token loginOwner(LoginOwnerRequest loginRequest){ .orElseThrow(() -> new BadRequestCustomException(BAD_REQUEST_EMAIL_OR_PASSWORD)); //password 확인 + validatePassword(loginRequest, loginOwner); + + return jwtTokenProvider.createToken(loginOwner.getEmail()); + } + + private void validatePassword(LoginOwnerRequest loginRequest, Owner loginOwner){ if(passwordEncoder.matches(loginRequest.password(), loginOwner.getPassword())){ throw new BadRequestCustomException(BAD_REQUEST_EMAIL_OR_PASSWORD); } - - return jwtTokenProvider.createToken(loginOwner.getEmail()); } } From a0f369038a467c2d85481e19fe616bdc594010e1 Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Fri, 5 Jan 2024 10:44:40 +0900 Subject: [PATCH 13/25] =?UTF-8?q?fix=20:=20=EB=B9=84=EB=B0=80=EB=B2=88?= =?UTF-8?q?=ED=98=B8=20=EA=B2=80=EC=A6=9D=20=EB=85=BC=EB=A6=AC=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/prgrms/catchtable/owner/service/OwnerService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/prgrms/catchtable/owner/service/OwnerService.java b/src/main/java/com/prgrms/catchtable/owner/service/OwnerService.java index da30bcf8..095412d6 100644 --- a/src/main/java/com/prgrms/catchtable/owner/service/OwnerService.java +++ b/src/main/java/com/prgrms/catchtable/owner/service/OwnerService.java @@ -58,7 +58,7 @@ public Token loginOwner(LoginOwnerRequest loginRequest){ } private void validatePassword(LoginOwnerRequest loginRequest, Owner loginOwner){ - if(passwordEncoder.matches(loginRequest.password(), loginOwner.getPassword())){ + if(!passwordEncoder.matches(loginRequest.password(), loginOwner.getPassword())){ throw new BadRequestCustomException(BAD_REQUEST_EMAIL_OR_PASSWORD); } } From 885b63d99a97832f2d893ca5a47e575b23d27823 Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Fri, 5 Jan 2024 10:45:10 +0900 Subject: [PATCH 14/25] =?UTF-8?q?feat=20:=20dto=20builder=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../prgrms/catchtable/owner/dto/request/JoinOwnerRequest.java | 2 ++ .../prgrms/catchtable/owner/dto/request/LoginOwnerRequest.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/main/java/com/prgrms/catchtable/owner/dto/request/JoinOwnerRequest.java b/src/main/java/com/prgrms/catchtable/owner/dto/request/JoinOwnerRequest.java index 80c67856..bc3adbdc 100644 --- a/src/main/java/com/prgrms/catchtable/owner/dto/request/JoinOwnerRequest.java +++ b/src/main/java/com/prgrms/catchtable/owner/dto/request/JoinOwnerRequest.java @@ -4,7 +4,9 @@ import jakarta.validation.constraints.Email; import jakarta.validation.constraints.Pattern; import java.time.LocalDate; +import lombok.Builder; +@Builder public record JoinOwnerRequest( String name, diff --git a/src/main/java/com/prgrms/catchtable/owner/dto/request/LoginOwnerRequest.java b/src/main/java/com/prgrms/catchtable/owner/dto/request/LoginOwnerRequest.java index 91368d5f..a9a0d2e4 100644 --- a/src/main/java/com/prgrms/catchtable/owner/dto/request/LoginOwnerRequest.java +++ b/src/main/java/com/prgrms/catchtable/owner/dto/request/LoginOwnerRequest.java @@ -1,7 +1,9 @@ package com.prgrms.catchtable.owner.dto.request; import jakarta.validation.constraints.Email; +import lombok.Builder; +@Builder public record LoginOwnerRequest( @Email From 32a9584969fd7ea1a34fa011107ec8e13b7cdf3c Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Fri, 5 Jan 2024 10:45:50 +0900 Subject: [PATCH 15/25] =?UTF-8?q?feat=20:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=9A=A9=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../owner/fixture/OwnerFixture.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/test/java/com/prgrms/catchtable/owner/fixture/OwnerFixture.java diff --git a/src/test/java/com/prgrms/catchtable/owner/fixture/OwnerFixture.java b/src/test/java/com/prgrms/catchtable/owner/fixture/OwnerFixture.java new file mode 100644 index 00000000..0959abb8 --- /dev/null +++ b/src/test/java/com/prgrms/catchtable/owner/fixture/OwnerFixture.java @@ -0,0 +1,39 @@ +package com.prgrms.catchtable.owner.fixture; + +import com.prgrms.catchtable.member.domain.Gender; +import com.prgrms.catchtable.owner.domain.Owner; +import com.prgrms.catchtable.owner.dto.request.JoinOwnerRequest; +import com.prgrms.catchtable.owner.dto.request.LoginOwnerRequest; +import java.time.LocalDate; + +public class OwnerFixture { + + public static Owner getOwner(String email, String encodePassword){ + return Owner.builder() + .name("test") + .email(email) + .password(encodePassword) + .phoneNumber("010-8830-4795") + .gender(Gender.MALE) + .dateBirth(LocalDate.of(1998,3,25)) + .build(); + } + + public static JoinOwnerRequest getJoinOwnerRequest(String email, String password){ + return JoinOwnerRequest.builder() + .name("test") + .email(email) + .password(password) + .phoneNumber("010-8830-4795") + .gender("male") + .dateBirth(LocalDate.of(1998,3,25)) + .build(); + } + + public static LoginOwnerRequest getLoginOwnerRequest(String email, String password){ + return LoginOwnerRequest.builder() + .email(email) + .password(password) + .build(); + } +} From 7ea8395e2d31eb1e4aec0c8cdfae07e364a803ff Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Fri, 5 Jan 2024 10:46:08 +0900 Subject: [PATCH 16/25] feat : OwnerService Test --- .../owner/service/OwnerServiceTest.java | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 src/test/java/com/prgrms/catchtable/owner/service/OwnerServiceTest.java diff --git a/src/test/java/com/prgrms/catchtable/owner/service/OwnerServiceTest.java b/src/test/java/com/prgrms/catchtable/owner/service/OwnerServiceTest.java new file mode 100644 index 00000000..905a2940 --- /dev/null +++ b/src/test/java/com/prgrms/catchtable/owner/service/OwnerServiceTest.java @@ -0,0 +1,118 @@ +package com.prgrms.catchtable.owner.service; + +import static org.assertj.core.api.Assertions.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import com.prgrms.catchtable.common.exception.custom.BadRequestCustomException; +import com.prgrms.catchtable.jwt.provider.JwtTokenProvider; +import com.prgrms.catchtable.jwt.token.Token; +import com.prgrms.catchtable.owner.domain.Owner; +import com.prgrms.catchtable.owner.dto.request.JoinOwnerRequest; +import com.prgrms.catchtable.owner.dto.request.LoginOwnerRequest; +import com.prgrms.catchtable.owner.dto.response.JoinOwnerResponse; +import com.prgrms.catchtable.owner.fixture.OwnerFixture; +import com.prgrms.catchtable.owner.repository.OwnerRepository; +import java.util.Optional; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.crypto.password.PasswordEncoder; + +class OwnerServiceTest { + + private OwnerRepository ownerRepository = mock(OwnerRepository.class); + private JwtTokenProvider jwtTokenProvider = mock(JwtTokenProvider.class); + private PasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); + + private OwnerService ownerService = new OwnerService(ownerRepository, passwordEncoder, + jwtTokenProvider); + + String email = "abc1234@gmail.com"; + String password = "qwer1234"; + String wrongPassword = "qwer12345"; + + + @Test + @DisplayName("유저의 회원가입이 성공한다.") + void joinSuccess() { + //given + JoinOwnerRequest joinOwnerRequest = OwnerFixture.getJoinOwnerRequest(email, password); + String encodePassword = passwordEncoder.encode(password); + + //when + when(ownerRepository.existsOwnerByEmail(joinOwnerRequest.email())).thenReturn(false); + when(ownerRepository.save(any(Owner.class))).thenReturn( + OwnerFixture.getOwner(email, encodePassword)); + JoinOwnerResponse joinOwnerResponse = ownerService.joinOwner(joinOwnerRequest); + + //then + assertThat(joinOwnerRequest.name()).isEqualTo(joinOwnerResponse.name()); + assertThat(joinOwnerRequest.email()).isEqualTo(joinOwnerResponse.email()); + assertThat(joinOwnerRequest.gender()).isEqualTo(joinOwnerResponse.gender()); + assertThat(joinOwnerRequest.phoneNumber()).isEqualTo(joinOwnerResponse.phoneNumber()); + assertThat(joinOwnerRequest.dateBirth()).isEqualTo(joinOwnerResponse.dateBirth()); + } + + @Test + @DisplayName("이미 회원가입한 이메일로 회원가입 시도 시, 예외 발생한다.") + void joinFailure() { + //given + JoinOwnerRequest joinOwnerRequest = OwnerFixture.getJoinOwnerRequest(email, password); + + //when + when(ownerRepository.existsOwnerByEmail(joinOwnerRequest.email())).thenReturn(true); + + //then + assertThatThrownBy(() -> ownerService.joinOwner(joinOwnerRequest)).isInstanceOf( + BadRequestCustomException.class); + } + + @Test + @DisplayName("로그인을 성공하면, 토큰을 반환한다") + void loginSuccess() { + //given + LoginOwnerRequest loginOwnerRequest = OwnerFixture.getLoginOwnerRequest(email, password); + String encodePassword = passwordEncoder.encode(password); + + //when + when(ownerRepository.findOwnerByEmail(loginOwnerRequest.email())).thenReturn( + Optional.of(OwnerFixture.getOwner(email, encodePassword))); + when(jwtTokenProvider.createToken(loginOwnerRequest.email())).thenReturn(any(Token.class)); + + //then + assertThat(ownerService.loginOwner(loginOwnerRequest)).isEqualTo(any(Token.class)); + } + + @Test + @DisplayName("해당 이메일의 유저가 존재하지 않으면 로그인을 실패한다") + void loginFailureId() { + //given + LoginOwnerRequest loginOwnerRequest = OwnerFixture.getLoginOwnerRequest(email, password); + + //when + when(ownerRepository.findOwnerByEmail(loginOwnerRequest.email())).thenReturn( + Optional.empty()); + + //then + assertThatThrownBy(() -> ownerService.loginOwner(loginOwnerRequest)).isInstanceOf( + BadRequestCustomException.class); + } + + @Test + @DisplayName("비밀번호가 다르면 로그인을 실패한다.") + void loginFailurePassword() { + //given + LoginOwnerRequest loginOwnerRequest = OwnerFixture.getLoginOwnerRequest(email, wrongPassword); + String encodePassword = passwordEncoder.encode(password); + + //when + when(ownerRepository.findOwnerByEmail(loginOwnerRequest.email())).thenReturn( + Optional.of(OwnerFixture.getOwner(email, encodePassword))); + + //then + assertThatThrownBy(() -> ownerService.loginOwner(loginOwnerRequest)).isInstanceOf( + BadRequestCustomException.class); + } +} \ No newline at end of file From 7b1923ecd83e4fa3520d8ac4235e57a1c847abdc Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Fri, 5 Jan 2024 19:12:14 +0900 Subject: [PATCH 17/25] =?UTF-8?q?fix=20:=20=EA=B0=80=EC=9E=85=20=EC=8B=9C?= =?UTF-8?q?=20=EC=A0=84=ED=99=94=EB=B2=88=ED=98=B8=20=EC=9E=85=EB=A0=A5=20?= =?UTF-8?q?=ED=8C=A8=ED=84=B4=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../prgrms/catchtable/owner/dto/request/JoinOwnerRequest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/prgrms/catchtable/owner/dto/request/JoinOwnerRequest.java b/src/main/java/com/prgrms/catchtable/owner/dto/request/JoinOwnerRequest.java index bc3adbdc..536745cf 100644 --- a/src/main/java/com/prgrms/catchtable/owner/dto/request/JoinOwnerRequest.java +++ b/src/main/java/com/prgrms/catchtable/owner/dto/request/JoinOwnerRequest.java @@ -13,7 +13,7 @@ public record JoinOwnerRequest( @Email String email, String password, - @Pattern(regexp = "^(01[016789]){1}([0-9]{3,4}){1}([0-9]{4}){1}$") + @Pattern(regexp = "^(01[016789]){1}-([0-9]{3,4}){1}-([0-9]{4}){1}$") String phoneNumber, String gender, @JsonFormat(pattern = "yyyy-MM-dd") From e030fccb082332752d3bccc288bc3379941138f7 Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Fri, 5 Jan 2024 19:14:01 +0900 Subject: [PATCH 18/25] =?UTF-8?q?fix=20:=20LocalDateTime=EC=9D=84=20Json?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EB=B3=80=ED=99=98=ED=95=98=EA=B8=B0=20?= =?UTF-8?q?=EC=9C=84=ED=95=9C=20=EB=AA=A8=EB=93=88=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/prgrms/catchtable/common/base/BaseIntegrationTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/java/com/prgrms/catchtable/common/base/BaseIntegrationTest.java b/src/test/java/com/prgrms/catchtable/common/base/BaseIntegrationTest.java index 1d86293a..0e2bc05c 100644 --- a/src/test/java/com/prgrms/catchtable/common/base/BaseIntegrationTest.java +++ b/src/test/java/com/prgrms/catchtable/common/base/BaseIntegrationTest.java @@ -1,6 +1,7 @@ package com.prgrms.catchtable.common.base; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; @@ -15,6 +16,7 @@ public abstract class BaseIntegrationTest { public MockMvc mockMvc; public static String asJsonString(final Object object) throws Exception { + objectMapper.registerModule(new JavaTimeModule()); return objectMapper.writeValueAsString(object); } } From 86e1a5a6d5443af6ba8420fdd72f30b52c79fad8 Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Fri, 5 Jan 2024 20:06:46 +0900 Subject: [PATCH 19/25] feat : OwnerController Test --- .../owner/controller/OwnerControllerTest.java | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 src/test/java/com/prgrms/catchtable/owner/controller/OwnerControllerTest.java diff --git a/src/test/java/com/prgrms/catchtable/owner/controller/OwnerControllerTest.java b/src/test/java/com/prgrms/catchtable/owner/controller/OwnerControllerTest.java new file mode 100644 index 00000000..d5d9dab2 --- /dev/null +++ b/src/test/java/com/prgrms/catchtable/owner/controller/OwnerControllerTest.java @@ -0,0 +1,114 @@ +package com.prgrms.catchtable.owner.controller; + +import static org.springframework.http.MediaType.*; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import com.prgrms.catchtable.common.base.BaseIntegrationTest; +import com.prgrms.catchtable.jwt.provider.JwtTokenProvider; +import com.prgrms.catchtable.jwt.token.Token; +import com.prgrms.catchtable.owner.dto.request.JoinOwnerRequest; +import com.prgrms.catchtable.owner.dto.request.LoginOwnerRequest; +import com.prgrms.catchtable.owner.fixture.OwnerFixture; +import com.prgrms.catchtable.owner.service.OwnerService; +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 org.springframework.transaction.annotation.Transactional; + +@Transactional +class OwnerControllerTest extends BaseIntegrationTest { + + @Autowired + private OwnerService ownerService; + @Autowired + private JwtTokenProvider jwtTokenProvider; + + private final String joinEmail = "qwer@56782naver.com"; + private final String notJoinEmail = "abc1234@gmail.com"; + private final String password = "qwer1234"; + + @BeforeEach + public void init() { + ownerService.joinOwner(OwnerFixture.getJoinOwnerRequest(joinEmail, password)); + } + + @Test + @DisplayName("회원가입에 성공한다.") + void joinTest() throws Exception { + //given + JoinOwnerRequest joinOwnerRequest = OwnerFixture.getJoinOwnerRequest(notJoinEmail, + password); + + //then + mockMvc.perform(post("/owners/join") + .contentType(APPLICATION_JSON) + .content(asJsonString(joinOwnerRequest))) + .andExpect(status().isCreated()) + .andExpect(jsonPath("$.name").value(joinOwnerRequest.name())) + .andExpect(jsonPath("$.email").value(joinOwnerRequest.email())) + .andExpect(jsonPath("$.phoneNumber").value(joinOwnerRequest.phoneNumber())) + .andExpect(jsonPath("$.gender").value(joinOwnerRequest.gender())) + .andExpect(jsonPath("$.dateBirth").value(joinOwnerRequest.dateBirth().toString())); + } + + @Test + @DisplayName("중복 이메일이 존재하여 테스트에 실패한다.") + void joinFailureTest() throws Exception { + //given + JoinOwnerRequest joinOwnerRequest = OwnerFixture.getJoinOwnerRequest(joinEmail, password); + + //then + mockMvc.perform(post("/owners/join") + .contentType(APPLICATION_JSON) + .content(asJsonString(joinOwnerRequest))) + .andExpect(status().isBadRequest()); + } + + @Test + @DisplayName("로그인이 정상적으로 작동한다.") + void loginTest() throws Exception { + //given + LoginOwnerRequest loginOwnerRequest = OwnerFixture.getLoginOwnerRequest(joinEmail, + password); + Token token = jwtTokenProvider.createToken(joinEmail); + + //then + mockMvc.perform(post("/owners/login") + .contentType(APPLICATION_JSON) + .content(asJsonString(loginOwnerRequest))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.email").value(token.getEmail())); + } + + @Test + @DisplayName("존재하지 않는 이메일로 로그인 시, 예외가 발생한다.") + void invalidatedEmail() throws Exception { + //given + LoginOwnerRequest loginOwnerRequest = OwnerFixture.getLoginOwnerRequest(notJoinEmail, + password); + + //then + mockMvc.perform(post("/owners/login") + .contentType(APPLICATION_JSON) + .content(asJsonString(loginOwnerRequest))) + .andExpect(status().isBadRequest()); + } + + @Test + @DisplayName("잘못된 비밀번호 입력 시, 예외가 발생한다.") + void invalidatedPassword() throws Exception { + //given + LoginOwnerRequest loginOwnerRequest = OwnerFixture.getLoginOwnerRequest(notJoinEmail, + "poiu0987"); + + //then + mockMvc.perform(post("/owners/login") + .contentType(APPLICATION_JSON) + .content(asJsonString(loginOwnerRequest))) + .andExpect(status().isBadRequest()); + + } +} \ No newline at end of file From 80aca16de0e361e17dbb826bf5be15a65b74d75d Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Fri, 5 Jan 2024 20:08:14 +0900 Subject: [PATCH 20/25] =?UTF-8?q?style=20:=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=ED=8F=AC=EB=A7=B7=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/prgrms/catchtable/member/domain/Gender.java | 6 +++--- .../catchtable/owner/controller/OwnerController.java | 5 +++-- .../com/prgrms/catchtable/owner/domain/Owner.java | 4 ++-- .../com/prgrms/catchtable/owner/dto/OwnerMapper.java | 5 +++-- .../catchtable/owner/service/OwnerService.java | 12 +++++++----- .../reservation/service/ReservationService.java | 3 ++- .../catchtable/security/config/SecurityConfig.java | 3 +-- .../security/controller/TestController.java | 2 +- 8 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/prgrms/catchtable/member/domain/Gender.java b/src/main/java/com/prgrms/catchtable/member/domain/Gender.java index 999f8a71..a5449d29 100644 --- a/src/main/java/com/prgrms/catchtable/member/domain/Gender.java +++ b/src/main/java/com/prgrms/catchtable/member/domain/Gender.java @@ -1,6 +1,6 @@ package com.prgrms.catchtable.member.domain; -import static com.prgrms.catchtable.common.exception.ErrorCode.*; +import static com.prgrms.catchtable.common.exception.ErrorCode.BAD_REQUEST_INPUT_GENDER_TYPE; import com.prgrms.catchtable.common.exception.custom.BadRequestCustomException; import java.util.Arrays; @@ -15,14 +15,14 @@ public enum Gender { private final String type; - public static Gender of(String input){ + public static Gender of(String input) { return Arrays.stream(values()) .filter(gender -> gender.isEqual(input)) .findAny() .orElseThrow(() -> new BadRequestCustomException(BAD_REQUEST_INPUT_GENDER_TYPE)); } - private boolean isEqual(String input){ + private boolean isEqual(String input) { return input.equals(this.type); } } diff --git a/src/main/java/com/prgrms/catchtable/owner/controller/OwnerController.java b/src/main/java/com/prgrms/catchtable/owner/controller/OwnerController.java index 8a047521..a8e781df 100644 --- a/src/main/java/com/prgrms/catchtable/owner/controller/OwnerController.java +++ b/src/main/java/com/prgrms/catchtable/owner/controller/OwnerController.java @@ -22,14 +22,15 @@ public class OwnerController { private final OwnerService ownerService; @PostMapping("/join") - public ResponseEntity join(@Valid @RequestBody JoinOwnerRequest joinOwnerRequest){ + public ResponseEntity join( + @Valid @RequestBody JoinOwnerRequest joinOwnerRequest) { JoinOwnerResponse joinOwnerResponse = ownerService.joinOwner(joinOwnerRequest); return ResponseEntity.status(HttpStatus.CREATED).body(joinOwnerResponse); } @PostMapping("/login") - public ResponseEntity login(@Valid @RequestBody LoginOwnerRequest loginOwnerRequest){ + public ResponseEntity login(@Valid @RequestBody LoginOwnerRequest loginOwnerRequest) { Token responseToken = ownerService.loginOwner(loginOwnerRequest); return ResponseEntity.ok(responseToken); diff --git a/src/main/java/com/prgrms/catchtable/owner/domain/Owner.java b/src/main/java/com/prgrms/catchtable/owner/domain/Owner.java index 7d397eba..78c13636 100644 --- a/src/main/java/com/prgrms/catchtable/owner/domain/Owner.java +++ b/src/main/java/com/prgrms/catchtable/owner/domain/Owner.java @@ -12,7 +12,6 @@ import jakarta.persistence.Column; import jakarta.persistence.ConstraintMode; import jakarta.persistence.Entity; -import jakarta.persistence.EnumType; import jakarta.persistence.Enumerated; import jakarta.persistence.ForeignKey; import jakarta.persistence.GeneratedValue; @@ -67,7 +66,8 @@ public class Owner extends BaseEntity implements UserDetails { private Shop shop; @Builder - public Owner(String name, String email, String password, String phoneNumber, Gender gender, LocalDate dateBirth) { + public Owner(String name, String email, String password, String phoneNumber, Gender gender, + LocalDate dateBirth) { this.name = name; this.email = email; this.password = password; diff --git a/src/main/java/com/prgrms/catchtable/owner/dto/OwnerMapper.java b/src/main/java/com/prgrms/catchtable/owner/dto/OwnerMapper.java index 36386be2..33cf7ce7 100644 --- a/src/main/java/com/prgrms/catchtable/owner/dto/OwnerMapper.java +++ b/src/main/java/com/prgrms/catchtable/owner/dto/OwnerMapper.java @@ -7,7 +7,8 @@ public class OwnerMapper { - public static Owner toEntity(JoinOwnerRequest joinOwnerRequest, String encodePassword, Gender gender){ + public static Owner toEntity(JoinOwnerRequest joinOwnerRequest, String encodePassword, + Gender gender) { return Owner.builder() .name(joinOwnerRequest.name()) .email(joinOwnerRequest.email()) @@ -18,7 +19,7 @@ public static Owner toEntity(JoinOwnerRequest joinOwnerRequest, String encodePas .build(); } - public static JoinOwnerResponse from(Owner owner){ + public static JoinOwnerResponse from(Owner owner) { return JoinOwnerResponse.builder() .name(owner.getName()) .email(owner.getEmail()) diff --git a/src/main/java/com/prgrms/catchtable/owner/service/OwnerService.java b/src/main/java/com/prgrms/catchtable/owner/service/OwnerService.java index 095412d6..d8a12a97 100644 --- a/src/main/java/com/prgrms/catchtable/owner/service/OwnerService.java +++ b/src/main/java/com/prgrms/catchtable/owner/service/OwnerService.java @@ -1,6 +1,7 @@ package com.prgrms.catchtable.owner.service; -import static com.prgrms.catchtable.common.exception.ErrorCode.*; +import static com.prgrms.catchtable.common.exception.ErrorCode.ALREADY_EXIST_OWNER; +import static com.prgrms.catchtable.common.exception.ErrorCode.BAD_REQUEST_EMAIL_OR_PASSWORD; import com.prgrms.catchtable.common.exception.custom.BadRequestCustomException; import com.prgrms.catchtable.jwt.provider.JwtTokenProvider; @@ -33,7 +34,8 @@ public JoinOwnerResponse joinOwner(JoinOwnerRequest joinOwnerRequest) { Gender gender = Gender.of(joinOwnerRequest.gender()); - Owner joinOwner = ownerRepository.save(OwnerMapper.toEntity(joinOwnerRequest, encodePassword, gender)); + Owner joinOwner = ownerRepository.save( + OwnerMapper.toEntity(joinOwnerRequest, encodePassword, gender)); return OwnerMapper.from(joinOwner); @@ -45,7 +47,7 @@ private void validateExistsOwner(JoinOwnerRequest joinOwnerRequest) { } } - public Token loginOwner(LoginOwnerRequest loginRequest){ + public Token loginOwner(LoginOwnerRequest loginRequest) { //email 확인 Owner loginOwner = ownerRepository.findOwnerByEmail(loginRequest.email()) @@ -57,8 +59,8 @@ public Token loginOwner(LoginOwnerRequest loginRequest){ return jwtTokenProvider.createToken(loginOwner.getEmail()); } - private void validatePassword(LoginOwnerRequest loginRequest, Owner loginOwner){ - if(!passwordEncoder.matches(loginRequest.password(), loginOwner.getPassword())){ + private void validatePassword(LoginOwnerRequest loginRequest, Owner loginOwner) { + if (!passwordEncoder.matches(loginRequest.password(), loginOwner.getPassword())) { throw new BadRequestCustomException(BAD_REQUEST_EMAIL_OR_PASSWORD); } } diff --git a/src/main/java/com/prgrms/catchtable/reservation/service/ReservationService.java b/src/main/java/com/prgrms/catchtable/reservation/service/ReservationService.java index 83a4fd1b..00f3f124 100644 --- a/src/main/java/com/prgrms/catchtable/reservation/service/ReservationService.java +++ b/src/main/java/com/prgrms/catchtable/reservation/service/ReservationService.java @@ -70,7 +70,8 @@ public CreateReservationResponse preOccupyReservation(CreateReservationRequest r @Transactional public CreateReservationResponse registerReservation(CreateReservationRequest request) { - ReservationTime reservationTime = reservationTimeRepository.findByIdWithShop( //예약시간과 매장 한번에 가져옴 + ReservationTime reservationTime = reservationTimeRepository.findByIdWithShop( + //예약시간과 매장 한번에 가져옴 request.reservationTimeId()). orElseThrow(() -> new NotFoundCustomException(NOT_EXIST_TIME)); diff --git a/src/main/java/com/prgrms/catchtable/security/config/SecurityConfig.java b/src/main/java/com/prgrms/catchtable/security/config/SecurityConfig.java index 2dc6af45..e4c67aa6 100644 --- a/src/main/java/com/prgrms/catchtable/security/config/SecurityConfig.java +++ b/src/main/java/com/prgrms/catchtable/security/config/SecurityConfig.java @@ -15,7 +15,6 @@ import org.springframework.security.oauth2.client.web.OAuth2AuthorizationRequestRedirectFilter; import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.util.matcher.AntPathRequestMatcher; -import org.springframework.stereotype.Component; @Configuration @RequiredArgsConstructor @@ -27,7 +26,7 @@ public class SecurityConfig { private final JwtAuthenticationFilter jwtAuthenticationFilter; @Bean - public PasswordEncoder passwordEncoder(){ + public PasswordEncoder passwordEncoder() { return new BCryptPasswordEncoder(); } diff --git a/src/main/java/com/prgrms/catchtable/security/controller/TestController.java b/src/main/java/com/prgrms/catchtable/security/controller/TestController.java index 6973411d..56f32d9a 100644 --- a/src/main/java/com/prgrms/catchtable/security/controller/TestController.java +++ b/src/main/java/com/prgrms/catchtable/security/controller/TestController.java @@ -10,7 +10,7 @@ public class TestController { @GetMapping("/testMember") - public ResponseEntity testMember(){ + public ResponseEntity testMember() { log.info("testMember"); return ResponseEntity.ok("testMember OK"); } From 4d234f9e873846c875a549cab89139b7b5edb78f Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Fri, 5 Jan 2024 20:16:15 +0900 Subject: [PATCH 21/25] fix : conflict resolve --- .../catchtable/reservation/service/ReservationService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/prgrms/catchtable/reservation/service/ReservationService.java b/src/main/java/com/prgrms/catchtable/reservation/service/ReservationService.java index 00f3f124..bbe02070 100644 --- a/src/main/java/com/prgrms/catchtable/reservation/service/ReservationService.java +++ b/src/main/java/com/prgrms/catchtable/reservation/service/ReservationService.java @@ -71,7 +71,6 @@ public CreateReservationResponse preOccupyReservation(CreateReservationRequest r @Transactional public CreateReservationResponse registerReservation(CreateReservationRequest request) { ReservationTime reservationTime = reservationTimeRepository.findByIdWithShop( - //예약시간과 매장 한번에 가져옴 request.reservationTimeId()). orElseThrow(() -> new NotFoundCustomException(NOT_EXIST_TIME)); From bd3b603e6e912f72c6ffe74e995b11322d3bcd3a Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Fri, 5 Jan 2024 22:18:53 +0900 Subject: [PATCH 22/25] =?UTF-8?q?fix=20:=20=EC=9E=98=EB=AA=BB=EB=90=9C=20?= =?UTF-8?q?=EB=AC=B8=EB=B2=95=20=EC=82=AC=EC=9A=A9=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../catchtable/owner/service/OwnerServiceTest.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/test/java/com/prgrms/catchtable/owner/service/OwnerServiceTest.java b/src/test/java/com/prgrms/catchtable/owner/service/OwnerServiceTest.java index 905a2940..dd8d297e 100644 --- a/src/test/java/com/prgrms/catchtable/owner/service/OwnerServiceTest.java +++ b/src/test/java/com/prgrms/catchtable/owner/service/OwnerServiceTest.java @@ -22,11 +22,11 @@ class OwnerServiceTest { - private OwnerRepository ownerRepository = mock(OwnerRepository.class); - private JwtTokenProvider jwtTokenProvider = mock(JwtTokenProvider.class); - private PasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); + private final OwnerRepository ownerRepository = mock(OwnerRepository.class); + private final JwtTokenProvider jwtTokenProvider = mock(JwtTokenProvider.class); + private final PasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); - private OwnerService ownerService = new OwnerService(ownerRepository, passwordEncoder, + private final OwnerService ownerService = new OwnerService(ownerRepository, passwordEncoder, jwtTokenProvider); String email = "abc1234@gmail.com"; @@ -75,14 +75,15 @@ void loginSuccess() { //given LoginOwnerRequest loginOwnerRequest = OwnerFixture.getLoginOwnerRequest(email, password); String encodePassword = passwordEncoder.encode(password); + Token token = new Token("AccessToken", "RefreshToken", loginOwnerRequest.email()); //when when(ownerRepository.findOwnerByEmail(loginOwnerRequest.email())).thenReturn( Optional.of(OwnerFixture.getOwner(email, encodePassword))); - when(jwtTokenProvider.createToken(loginOwnerRequest.email())).thenReturn(any(Token.class)); + when(jwtTokenProvider.createToken(loginOwnerRequest.email())).thenReturn(token); //then - assertThat(ownerService.loginOwner(loginOwnerRequest)).isEqualTo(any(Token.class)); + assertThat(ownerService.loginOwner(loginOwnerRequest)).isEqualTo(token); } @Test From 845a49773c9aa59ed30ae421d93ed0f5a23461fa Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Sun, 7 Jan 2024 21:11:47 +0900 Subject: [PATCH 23/25] =?UTF-8?q?fix=20:=20=EC=A0=91=EA=B7=BC=20=EC=A0=9C?= =?UTF-8?q?=EC=96=B4=EC=9E=90=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../prgrms/catchtable/owner/service/OwnerServiceTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/prgrms/catchtable/owner/service/OwnerServiceTest.java b/src/test/java/com/prgrms/catchtable/owner/service/OwnerServiceTest.java index dd8d297e..3c7e59e7 100644 --- a/src/test/java/com/prgrms/catchtable/owner/service/OwnerServiceTest.java +++ b/src/test/java/com/prgrms/catchtable/owner/service/OwnerServiceTest.java @@ -29,9 +29,9 @@ class OwnerServiceTest { private final OwnerService ownerService = new OwnerService(ownerRepository, passwordEncoder, jwtTokenProvider); - String email = "abc1234@gmail.com"; - String password = "qwer1234"; - String wrongPassword = "qwer12345"; + private final String email = "abc1234@gmail.com"; + private final String password = "qwer1234"; + private final String wrongPassword = "qwer12345"; @Test From 2a8801b5100681500873265c10fc7ffe4b0fc673 Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Sun, 7 Jan 2024 21:40:02 +0900 Subject: [PATCH 24/25] fix : conflict resolve --- .../com/prgrms/catchtable/owner/fixture/OwnerFixture.java | 4 +++- .../controller/OwnerReservationControllerTest.java | 2 +- .../reservation/service/OwnerReservationServiceTest.java | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/prgrms/catchtable/owner/fixture/OwnerFixture.java b/src/test/java/com/prgrms/catchtable/owner/fixture/OwnerFixture.java index f8cd2c02..5666f366 100644 --- a/src/test/java/com/prgrms/catchtable/owner/fixture/OwnerFixture.java +++ b/src/test/java/com/prgrms/catchtable/owner/fixture/OwnerFixture.java @@ -14,9 +14,11 @@ public class OwnerFixture { - public static Owner getOwner() { + public static Owner getOwner(String email, String password) { Owner owner = Owner.builder() .name("ownerA") + .email(email) + .password(password) .phoneNumber("010-3462-2480") .gender(MALE) .dateBirth(LocalDate.of(2000, 9, 13)) diff --git a/src/test/java/com/prgrms/catchtable/reservation/controller/OwnerReservationControllerTest.java b/src/test/java/com/prgrms/catchtable/reservation/controller/OwnerReservationControllerTest.java index a0237637..e2d7ef7b 100644 --- a/src/test/java/com/prgrms/catchtable/reservation/controller/OwnerReservationControllerTest.java +++ b/src/test/java/com/prgrms/catchtable/reservation/controller/OwnerReservationControllerTest.java @@ -62,7 +62,7 @@ void setUp() { Reservation reservation2 = reservationRepository.save( ReservationFixture.getReservation(savedReservationTime2)); - Owner owner = OwnerFixture.getOwner(); + Owner owner = OwnerFixture.getOwner("email", "password"); owner.insertShop(shop); ownerRepository.save(owner); } diff --git a/src/test/java/com/prgrms/catchtable/reservation/service/OwnerReservationServiceTest.java b/src/test/java/com/prgrms/catchtable/reservation/service/OwnerReservationServiceTest.java index f114d342..96c21097 100644 --- a/src/test/java/com/prgrms/catchtable/reservation/service/OwnerReservationServiceTest.java +++ b/src/test/java/com/prgrms/catchtable/reservation/service/OwnerReservationServiceTest.java @@ -109,7 +109,7 @@ void getAllReservation() { reservations.add(reservation1); reservations.add(reservation2); - Owner owner = OwnerFixture.getOwner(); + Owner owner = OwnerFixture.getOwner("email", "password"); when(reservationRepository.findAllWithReservationTimeAndShopByShopId( any(Long.class))).thenReturn(reservations); when(ownerRepository.findById(any(Long.class))).thenReturn(Optional.of(owner)); @@ -127,7 +127,7 @@ void getAllReservation() { @Test @DisplayName("매장에 예약이 없을 시 빈 리스트가 조회된다.") void getAllReservationEmpty() { - Owner owner = OwnerFixture.getOwner(); + Owner owner = OwnerFixture.getOwner("email", "password"); when(reservationRepository.findAllWithReservationTimeAndShopByShopId( any(Long.class))).thenReturn(List.of()); From 4b756c2a3891b6656608a80d01acd0ee2cbd391c Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Sun, 7 Jan 2024 21:47:09 +0900 Subject: [PATCH 25/25] fix : conflict resolve --- .../com/prgrms/catchtable/owner/fixture/OwnerFixture.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/prgrms/catchtable/owner/fixture/OwnerFixture.java b/src/test/java/com/prgrms/catchtable/owner/fixture/OwnerFixture.java index 5666f366..54089c3c 100644 --- a/src/test/java/com/prgrms/catchtable/owner/fixture/OwnerFixture.java +++ b/src/test/java/com/prgrms/catchtable/owner/fixture/OwnerFixture.java @@ -31,12 +31,12 @@ public static Owner getOwner(String email, String password) { public static JoinOwnerRequest getJoinOwnerRequest(String email, String password){ return JoinOwnerRequest.builder() - .name("test") + .name("ownerA") .email(email) .password(password) - .phoneNumber("010-8830-4795") + .phoneNumber("010-3462-2480") .gender("male") - .dateBirth(LocalDate.of(1998,3,25)) + .dateBirth(LocalDate.of(2000, 9, 13)) .build(); }