Skip to content

Commit

Permalink
Formatted and added test to coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ospodaryk committed Sep 25, 2023
1 parent 78c1687 commit d2bb1a5
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit d2bb1a5

Please sign in to comment.