### Question:
NoteMapper implements DataMapper<Note, NoteDto> { @Override public Note mapDtoToEntity(NoteDto noteDto) { Note note = new Note(); note.setText(noteDto.getNoteBody()); note.setId(noteDto.getNoteId()); note.setUserId(noteDto.getUserId()); note.setDate(noteDto.getDate()); KeyResult parentKeyResult = null; if (noteDto.getParentKeyResultId() != null) { parentKeyResult = new KeyResult(); parentKeyResult.setId(noteDto.getParentKeyResultId()); } note.setParentKeyResult(parentKeyResult); logger.info("Mapped NoteDto (id:" + noteDto.getNoteId() + ") successful to Note."); return note; }  @Override Note mapDtoToEntity(NoteDto noteDto); @Override NoteDto mapEntityToDto(Note note); @Override Collection<Note> mapDtosToEntities(Collection<NoteDto> input); @Override Collection<NoteDto> mapEntitiesToDtos(Collection<Note> notes);  }### Answer:
@Test public void test_mapDtoToEntity_expectsBodyIsMapped() { String expected = "test"; noteDto.setNoteBody(expected); note = noteMapper.mapDtoToEntity(noteDto); Assert.assertEquals(expected, note.getText()); }
@Test public void test_mapDtoToEntity_expectsIdIsMapped() { Long expected = 5L; noteDto.setNoteId(expected); note = noteMapper.mapDtoToEntity(noteDto); Assert.assertEquals(expected, note.getId()); }
@Test public void test_mapDtoToEntity_expects_expectsParentIsNull() { note = noteMapper.mapDtoToEntity(noteDto); Assert.assertNull(note.getParentKeyResult()); }
@Test public void test_mapDtoToEntity_expects_expectsParentIdIsMapped() { Long expected = 123L; noteDto.setParentKeyResultId(expected); note = noteMapper.mapDtoToEntity(noteDto); Assert.assertEquals(expected, note.getParentKeyResult().getId()); }
@Test public void test_mapDtoToEntity_expectsParentIsMapped() { LocalDateTime expected = LocalDateTime.now(); noteDto.setDate(expected); note = noteMapper.mapDtoToEntity(noteDto); Assert.assertEquals(expected, note.getDate()); }