-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#45 - Test: MemberMapper 의 JoinFormToEntity() 테스트 코드 작성
- Loading branch information
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
mutbooks/src/test/java/com/example/mutbooks/app/global/mapper/MemberMapperTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.example.mutbooks.app.global.mapper; | ||
|
||
import com.example.mutbooks.app.member.entity.Member; | ||
import com.example.mutbooks.app.member.form.JoinForm; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class MemberMapperTest { | ||
|
||
@Test | ||
@DisplayName("회원가입폼을 엔티티에 매핑하기(emailVerified, restCash 디폴트 값 매핑)") | ||
void joinFormToEntity() { | ||
// given | ||
JoinForm joinForm = JoinForm.builder() | ||
.username("user5") | ||
.password("1234") | ||
.email("[email protected]") | ||
.nickname("사과") | ||
.build(); | ||
// when | ||
Member member = MemberMapper.INSTANCE.JoinFormToEntity(joinForm); | ||
// then | ||
assertThat(member.getUsername()).isEqualTo("user5"); | ||
assertThat(member.getPassword()).isEqualTo("1234"); | ||
assertThat(member.getEmail()).isEqualTo("[email protected]"); | ||
assertThat(member.getNickname()).isEqualTo("사과"); | ||
assertThat(member.getEmailVerified()).isEqualTo(false); | ||
assertThat(member.getRestCash()).isEqualTo(0); | ||
} | ||
|
||
@Test | ||
@DisplayName("회원가입폼의 닉네임이 null 일 때 엔티티에 매핑하기") | ||
void joinFormToEntity2() { | ||
// given | ||
JoinForm joinForm = JoinForm.builder() | ||
.username("user5") | ||
.password("1234") | ||
.email("[email protected]") | ||
.build(); | ||
// when | ||
Member member = MemberMapper.INSTANCE.JoinFormToEntity(joinForm); | ||
// then | ||
assertThat(member.getUsername()).isEqualTo("user5"); | ||
assertThat(member.getPassword()).isEqualTo("1234"); | ||
assertThat(member.getEmail()).isEqualTo("[email protected]"); | ||
assertThat(member.getNickname()).isNull(); | ||
assertThat(member.getEmailVerified()).isEqualTo(false); | ||
assertThat(member.getRestCash()).isEqualTo(0); | ||
} | ||
} |