### Question:
CustomGoalServiceImpl implements CustomGoalService { @Transactional @Override public List<CustomGoalResponseDto> save(BulkSaveCustomGoalDto bulkSave, User user) { List<CustomGoalSaveRequestDto> dto = bulkSave.getCustomGoalSaveRequestDtoList(); List<String> errorMessages = findDuplicates(dto, user); if (!errorMessages.isEmpty()) { throw new CustomGoalNotSavedException(CUSTOM_GOAL_WHERE_NOT_SAVED + errorMessages.toString()); } customGoalRepo.saveAll(user.getCustomGoals()); return user.getCustomGoals().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);  }### Answer:
@Test public void saveEmptyBulkSaveCustomGoalDtoTest() { List<CustomGoalResponseDto> saveResult = customGoalService.save( new BulkSaveCustomGoalDto(Collections.emptyList()), user ); assertTrue(saveResult.isEmpty()); assertTrue(user.getCustomGoals().isEmpty()); }
@Test public void saveNonExistentBulkSaveCustomGoalDtoTest() { CustomGoalSaveRequestDto customGoalDtoToSave = new CustomGoalSaveRequestDto("foo"); CustomGoal customGoal = new CustomGoal(1L, customGoalDtoToSave.getText(), null, null); when(modelMapper.map(customGoalDtoToSave, CustomGoal.class)).thenReturn(customGoal); when(modelMapper.map(customGoal, CustomGoalResponseDto.class)).thenReturn(new CustomGoalResponseDto(1L, "bar")); List<CustomGoalResponseDto> saveResult = customGoalService.save( new BulkSaveCustomGoalDto(Collections.singletonList(customGoalDtoToSave)), user ); assertEquals(user.getCustomGoals().get(0), customGoal); assertEquals("bar", saveResult.get(0).getText()); }
@Test(expected = CustomGoalNotSavedException.class) public void saveDuplicatedBulkSaveCustomGoalDtoTest() { CustomGoalSaveRequestDto customGoalDtoToSave = new CustomGoalSaveRequestDto("foo"); CustomGoal customGoal = new CustomGoal(1L, customGoalDtoToSave.getText(), null, null); user.setCustomGoals(Collections.singletonList(customGoal)); when(modelMapper.map(customGoalDtoToSave, CustomGoal.class)).thenReturn(customGoal); customGoalService.save( new BulkSaveCustomGoalDto(Collections.singletonList(customGoalDtoToSave)), user ); }