### Question:
HabitStatisticServiceImpl implements HabitStatisticService { @Transactional @CacheEvict(value = CacheConstants.HABIT_ITEM_STATISTIC_CACHE, allEntries = true) @Override public UpdateHabitStatisticDto update(Long habitStatisticId, UpdateHabitStatisticDto dto) { HabitStatistic updatable = findById(habitStatisticId); updatable.setAmountOfItems(dto.getAmountOfItems()); updatable.setHabitRate(dto.getHabitRate()); return modelMapper.map(habitStatisticRepo.save(updatable), UpdateHabitStatisticDto.class); } @Autowired  HabitStatisticServiceImpl(HabitStatisticRepo habitStatisticRepo,
                                     HabitRepo habitRepo,
                                     HabitService habitService, ModelMapper modelMapper,
                                     DateService dateService); @Transactional @CacheEvict(value = CacheConstants.HABIT_ITEM_STATISTIC_CACHE, allEntries = true) @Override AddHabitStatisticDto save(AddHabitStatisticDto dto); @Transactional @CacheEvict(value = CacheConstants.HABIT_ITEM_STATISTIC_CACHE, allEntries = true) @Override UpdateHabitStatisticDto update(Long habitStatisticId, UpdateHabitStatisticDto dto); @Override HabitStatistic findById(Long id); @Override List<Habit> findAllHabitsByUserId(Long userId); @Override List<Habit> findAllHabitsByStatus(Long userId, Boolean status); @Override List<HabitDto> findAllHabitsAndTheirStatistics(Long id, Boolean status, String language); @Override CalendarUsefulHabitsDto getInfoAboutUserHabits(Long userId); @Override List<HabitStatisticDto> findAllByHabitId(Long habitId); @Cacheable(value = CacheConstants.HABIT_ITEM_STATISTIC_CACHE, key = "#language") @Override List<HabitItemsAmountStatisticDto> getTodayStatisticsForAllHabitItems(String language); @Override Long getAmountOfHabitsInProgressByUserId(Long id); @Override Long getAmountOfAcquiredHabitsByUserId(Long id);  }### Answer:
@Test void updateTest() { UpdateHabitStatisticDto updateHabStatDto = new UpdateHabitStatisticDto(); HabitStatistic habitStatistic = new HabitStatistic(); when(habitStatisticRepo.findById(anyLong())).thenReturn(Optional.of(habitStatistic)); when(habitStatisticService.update(anyLong(), updateHabStatDto)).thenReturn(updateHabStatDto); assertEquals(updateHabStatDto, habitStatisticService.update(anyLong(), updateHabStatDto)); Mockito.verify(habitStatisticRepo, times(2)).findById(anyLong()); }