Skip to content

Commit

Permalink
more test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
holotsvan committed Dec 4, 2024
1 parent 2bc2066 commit 0e0c727
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import greencity.entity.event.Address;
import greencity.entity.event.Event;
import greencity.entity.event.EventDateLocation;
import greencity.entity.event.EventGrade;
import greencity.entity.event.EventImages;
import greencity.enums.NotificationType;
import greencity.enums.Role;
Expand Down Expand Up @@ -513,7 +514,7 @@ void getEventWithoutUser() {
assertEquals(eventDto.getTitleImage(), actual.getTitleImage());
assertFalse(actual.isSubscribed());
assertFalse(actual.isFavorite());

assertNull(actual.getCurrentUserGrade());
verify(eventRepo, never()).findFavoritesAmongEventIds(anyList(), anyLong());
verify(eventRepo, never()).findSubscribedAmongEventIds(anyList(), anyLong());
}
Expand All @@ -526,6 +527,8 @@ void getEventWithCurrentUser() {
Principal principal = ModelUtils.getPrincipal();
User user = ModelUtils.getUser();

event.setEventGrades(List.of(EventGrade.builder().grade(5).user(user).event(event).build()));

when(modelMapper.map(testUserVo, User.class)).thenReturn(user);
when(restClient.findByEmail(principal.getName())).thenReturn(testUserVo);
when(eventRepo.findById(anyLong())).thenReturn(Optional.of(event));
Expand All @@ -537,7 +540,7 @@ void getEventWithCurrentUser() {

assertTrue(actual.isSubscribed());
assertTrue(actual.isFavorite());

assertEquals(5, actual.getCurrentUserGrade());
verify(eventRepo).findFavoritesAmongEventIds(eventIds, user.getId());
verify(eventRepo).findSubscribedAmongEventIds(eventIds, user.getId());
}
Expand Down

0 comments on commit 0e0c727

Please sign in to comment.