@Test void getTodayStatisticsForAllHabitItemsTest() { when(habitStatisticRepo.getStatisticsForAllHabitItemsByDate(new Date(), "en")) .thenReturn(new ArrayList<>()); assertEquals(new ArrayList<HabitItemsAmountStatisticDto>(), habitStatisticService.getTodayStatisticsForAllHabitItems("en")); }
@Cacheable(value = CacheConstants.HABIT_ITEM_STATISTIC_CACHE, key = "#language") @Override public List<HabitItemsAmountStatisticDto> getTodayStatisticsForAllHabitItems(String language) { return habitStatisticRepo.getStatisticsForAllHabitItemsByDate(new Date(), language).stream() .map(it -> HabitItemsAmountStatisticDto.builder() .habitItem((String) it.get(0)) .notTakenItems((long) it.get(1)) .build() ).collect(Collectors.toList()); }
HabitStatisticServiceImpl implements HabitStatisticService { @Cacheable(value = CacheConstants.HABIT_ITEM_STATISTIC_CACHE, key = "#language") @Override public List<HabitItemsAmountStatisticDto> getTodayStatisticsForAllHabitItems(String language) { return habitStatisticRepo.getStatisticsForAllHabitItemsByDate(new Date(), language).stream() .map(it -> HabitItemsAmountStatisticDto.builder() .habitItem((String) it.get(0)) .notTakenItems((long) it.get(1)) .build() ).collect(Collectors.toList()); } }
HabitStatisticServiceImpl implements HabitStatisticService { @Cacheable(value = CacheConstants.HABIT_ITEM_STATISTIC_CACHE, key = "#language") @Override public List<HabitItemsAmountStatisticDto> getTodayStatisticsForAllHabitItems(String language) { return habitStatisticRepo.getStatisticsForAllHabitItemsByDate(new Date(), language).stream() .map(it -> HabitItemsAmountStatisticDto.builder() .habitItem((String) it.get(0)) .notTakenItems((long) it.get(1)) .build() ).collect(Collectors.toList()); } @Autowired  HabitStatisticServiceImpl(HabitStatisticRepo habitStatisticRepo,
                                     HabitRepo habitRepo,
                                     HabitService habitService, ModelMapper modelMapper,
                                     DateService dateService); }
HabitStatisticServiceImpl implements HabitStatisticService { @Cacheable(value = CacheConstants.HABIT_ITEM_STATISTIC_CACHE, key = "#language") @Override public List<HabitItemsAmountStatisticDto> getTodayStatisticsForAllHabitItems(String language) { return habitStatisticRepo.getStatisticsForAllHabitItemsByDate(new Date(), language).stream() .map(it -> HabitItemsAmountStatisticDto.builder() .habitItem((String) it.get(0)) .notTakenItems((long) it.get(1)) .build() ).collect(Collectors.toList()); } @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); }
HabitStatisticServiceImpl implements HabitStatisticService { @Cacheable(value = CacheConstants.HABIT_ITEM_STATISTIC_CACHE, key = "#language") @Override public List<HabitItemsAmountStatisticDto> getTodayStatisticsForAllHabitItems(String language) { return habitStatisticRepo.getStatisticsForAllHabitItemsByDate(new Date(), language).stream() .map(it -> HabitItemsAmountStatisticDto.builder() .habitItem((String) it.get(0)) .notTakenItems((long) it.get(1)) .build() ).collect(Collectors.toList()); } @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);  }