- 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");
}
}
참고 자료