[Mapstruct] Test Code 작성

귀찮Lee·2023년 2월 6일
0
  • MapStruct MapperImpl 불러오는 법
private final MemberMapper memberMapper = Mappers.getMapper(MemberMapper.class);
  • MapStruct Test Code 작성 예시
public class MemberMapperTest {

    private final MemberMapper memberMapper = Mappers.getMapper(MemberMapper.class);

    @Test
    void memberPatchDtoToMemberTest() {
        MemberDto.Patch dto = new MemberDto.Patch("nickname", "http://url", "location",
                "title", "aboutMe");

        Member member = memberMapper.memberPatchDtoToMember(dto);

        assertThat(member.getDisplayName()).isEqualTo("nickname");
        assertThat(member.getImage()).isEqualTo("http://url");
        assertThat(member.getLocation()).isEqualTo("location");
        assertThat(member.getMemberTitle()).isEqualTo("title");
        assertThat(member.getAboutMe()).isEqualTo("aboutMe");
    }
}

참고 자료

profile
배운 것은 기록하자! / 오류 지적은 언제나 환영!

0개의 댓글