SystemNotificationServiceImpl implements SystemNotificationService { @Override public List<SystemNotificationDto> findAllSystemNotificationDtosByPatient( long patientId) { List<SystemNotification> systemNotifications = systemNotificationRepository .findAllByPatientId(patientId); List<SystemNotificationDto> systemNotificationDtos = makeSystemNotificationDtos(); for (SystemNotification systemNotification : systemNotifications) { systemNotificationDtos.add(modelMapper.map(systemNotification, SystemNotificationDto.class)); } return getReversed(systemNotificationDtos); } SystemNotificationServiceImpl(PatientRepository patientRepository,
			SystemNotificationRepository systemNotificationRepository,
			ModelMapper modelMapper); @Override List<SystemNotificationDto> findAllSystemNotificationDtosByPatient(
			long patientId); @Override ArrayList<SystemNotificationDto> makeSystemNotificationDtos(); @Override List<SystemNotificationDto> getReversed(
			List<SystemNotificationDto> original);  }
@Test public void testFindAllSystemNotificationDtosByPatient() { SystemNotificationService spy = spy(snst); List<SystemNotification> systemNotifications = new ArrayList<SystemNotification>(); SystemNotification systemNotification = new SystemNotification(); systemNotifications.add(systemNotification); when(systemNotificationRepository.findAllByPatientId(anyLong())) .thenReturn(systemNotifications); ArrayList<SystemNotificationDto> systemNotificationDtos = new ArrayList<SystemNotificationDto>(); when(spy.makeSystemNotificationDtos()).thenReturn( systemNotificationDtos); SystemNotificationDto systemNotificationDto = new SystemNotificationDto(); when(modelMapper.map(systemNotification, SystemNotificationDto.class)) .thenReturn(systemNotificationDto); systemNotificationDtos.add(systemNotificationDto); Assert.assertEquals( spy.findAllSystemNotificationDtosByPatient(anyLong()), systemNotificationDtos); }