@Test public void findAllTest() { CustomGoal customGoal = new CustomGoal(1L, "foo", null, null); when(customGoalRepo.findAll()).thenReturn(Collections.singletonList(customGoal)); when(modelMapper.map(customGoal, CustomGoalResponseDto.class)) .thenReturn(new CustomGoalResponseDto(customGoal.getId(), customGoal.getText())); List<CustomGoalResponseDto> findAllResult = customGoalService.findAll(); assertEquals("foo", findAllResult.get(0).getText()); assertEquals(1L, (long) findAllResult.get(0).getId()); }
@Transactional @Override public List<CustomGoalResponseDto> findAll() { return customGoalRepo.findAll().stream() .map(customGoal -> modelMapper.map(customGoal, CustomGoalResponseDto.class)) .collect(Collectors.toList()); }
CustomGoalServiceImpl implements CustomGoalService { @Transactional @Override public List<CustomGoalResponseDto> findAll() { return customGoalRepo.findAll().stream() .map(customGoal -> modelMapper.map(customGoal, CustomGoalResponseDto.class)) .collect(Collectors.toList()); } }
CustomGoalServiceImpl implements CustomGoalService { @Transactional @Override public List<CustomGoalResponseDto> findAll() { return customGoalRepo.findAll().stream() .map(customGoal -> modelMapper.map(customGoal, CustomGoalResponseDto.class)) .collect(Collectors.toList()); }  }
CustomGoalServiceImpl implements CustomGoalService { @Transactional @Override public List<CustomGoalResponseDto> findAll() { return customGoalRepo.findAll().stream() .map(customGoal -> modelMapper.map(customGoal, CustomGoalResponseDto.class)) .collect(Collectors.toList()); }  @Transactional @Override List<CustomGoalResponseDto> save(BulkSaveCustomGoalDto bulkSave, User user); @Transactional @Override List<CustomGoalResponseDto> findAll(); @Transactional @Override CustomGoalResponseDto findById(Long id); @Transactional @Override List<CustomGoalResponseDto> updateBulk(BulkCustomGoalDto bulkCustomGoalDto); @Transactional @Override List<CustomGoalResponseDto> findAllByUser(Long userId); @Transactional @Override List<Long> bulkDelete(String ids); }
CustomGoalServiceImpl implements CustomGoalService { @Transactional @Override public List<CustomGoalResponseDto> findAll() { return customGoalRepo.findAll().stream() .map(customGoal -> modelMapper.map(customGoal, CustomGoalResponseDto.class)) .collect(Collectors.toList()); }  @Transactional @Override List<CustomGoalResponseDto> save(BulkSaveCustomGoalDto bulkSave, User user); @Transactional @Override List<CustomGoalResponseDto> findAll(); @Transactional @Override CustomGoalResponseDto findById(Long id); @Transactional @Override List<CustomGoalResponseDto> updateBulk(BulkCustomGoalDto bulkCustomGoalDto); @Transactional @Override List<CustomGoalResponseDto> findAllByUser(Long userId); @Transactional @Override List<Long> bulkDelete(String ids);  }