### Question:
NoteMapper implements DataMapper<Note, NoteDto> { @Override public NoteDto mapEntityToDto(Note note) { NoteDto noteDto = new NoteDto(); noteDto.setNoteBody(note.getText()); noteDto.setNoteId(note.getId()); noteDto.setUserId(note.getUserId()); noteDto.setDate(note.getDate()); noteDto.setParentKeyResultId(note.getParentKeyResult().getId()); logger.info("Mapped Note (id:" + note.getId() + ") successful to NoteDto."); return noteDto; }  @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_mapEntityToDto_expectsBodyIsMapped() { String expected = "test"; note.setText(expected); noteDto = noteMapper.mapEntityToDto(note); Assert.assertEquals(expected, noteDto.getNoteBody()); }
@Test public void test_mapEntityToDto_expectsIdIsMapped() { Long expected = 5L; note.setId(expected); noteDto = noteMapper.mapEntityToDto(note); Assert.assertEquals(expected, noteDto.getNoteId()); }
@Test public void test_mapEntityToDto_expectsParentKeyResultIsMapped() { Long expected = 5L; KeyResult keyResult = new KeyResult(); keyResult.setId(expected); note.setParentKeyResult(keyResult); noteDto = noteMapper.mapEntityToDto(note); Assert.assertEquals(expected, noteDto.getParentKeyResultId()); }
@Test public void test_mapEntityToDto_expectsUserIsMapped() { UUID expectedUuid = UUID.randomUUID(); note.setUserId(expectedUuid); noteDto = noteMapper.mapEntityToDto(note); Assert.assertEquals(expectedUuid, noteDto.getUserId()); }
@Test public void test_mapEntityToDto_expectsDateIsMapped() { LocalDateTime expected = LocalDateTime.now(); note.setDate(expected); noteDto = noteMapper.mapEntityToDto(note); Assert.assertEquals(expected, noteDto.getDate()); }