Skip to content

Commit

Permalink
#45 - Test: MemberMapper 의 JoinFormToEntity() 테스트 코드 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
ahah525 committed Dec 13, 2022
1 parent f01c6a7 commit 937eeb4
Showing 1 changed file with 52 additions and 0 deletions.
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);
}
}

0 comments on commit 937eeb4

Please sign in to comment.