From d2bb1a557fb32ed5b679a803638d51ec1cb4404c Mon Sep 17 00:00:00 2001 From: ospodaryk Date: Mon, 25 Sep 2023 11:27:16 +0300 Subject: [PATCH] Formatted and added test to coverage --- .../java/greencity/service/HabitAssignServiceImplTest.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/service/src/test/java/greencity/service/HabitAssignServiceImplTest.java b/service/src/test/java/greencity/service/HabitAssignServiceImplTest.java index 2a7b94804a..08f535c9aa 100644 --- a/service/src/test/java/greencity/service/HabitAssignServiceImplTest.java +++ b/service/src/test/java/greencity/service/HabitAssignServiceImplTest.java @@ -1,6 +1,7 @@ package greencity.service; import greencity.ModelUtils; +import greencity.achievement.AchievementCalculation; import greencity.constant.AppConstant; import greencity.constant.ErrorMessage; import greencity.dto.habit.HabitAssignCustomPropertiesDto; @@ -132,6 +133,9 @@ class HabitAssignServiceImplTest { @Mock private RatingCalculation ratingCalculation; + @Mock + private AchievementCalculation achievementCalculation; + private static ZonedDateTime zonedDateTime = ZonedDateTime.now(); private HabitDto habitDto = HabitDto.builder().id(1L).build(); @@ -469,6 +473,7 @@ void unenrollHabit() { .thenReturn(Optional.of(habitAssign)); when(habitStatusCalendarRepo.findHabitStatusCalendarByEnrollDateAndHabitAssign(date, habitAssign)) .thenReturn(habitStatusCalendar); + when(userService.findById(any())).thenReturn(ModelUtils.getUserVO()); habitAssignService.unenrollHabit(habitAssignId, userId, date); assertEquals(0, habitAssign.getHabitStatusCalendars().size()); @@ -558,6 +563,7 @@ void deleteHabitAssign() { habitAssign.setWorkingDays(10); when(habitAssignRepo.findById(habitAssignId)).thenReturn(Optional.of(habitAssign)); + when(userService.findById(any())).thenReturn(ModelUtils.getUserVO()); habitAssignService.deleteHabitAssign(habitAssignId, userId); @@ -884,6 +890,7 @@ void enrollHabit() { .thenReturn(null); when(modelMapper.map(habitAssign, HabitAssignDto.class)).thenReturn(habitAssignDto); when(modelMapper.map(translation, HabitDto.class)).thenReturn(habitDto); + when(userService.findById(any())).thenReturn(ModelUtils.getUserVO()); HabitAssignDto actualDto = habitAssignService.enrollHabit(habitAssignId, userId, localDate, language); assertEquals(1, habitAssign.getWorkingDays());