From 193df330425a997f18e1c4a24faa19a190a74457 Mon Sep 17 00:00:00 2001 From: ospodaryk Date: Thu, 12 Oct 2023 16:30:49 +0300 Subject: [PATCH] Fixed tests --- .../greencity/service/AchievementServiceImplTest.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/service/src/test/java/greencity/service/AchievementServiceImplTest.java b/service/src/test/java/greencity/service/AchievementServiceImplTest.java index ac771395af..21f2b71dc1 100644 --- a/service/src/test/java/greencity/service/AchievementServiceImplTest.java +++ b/service/src/test/java/greencity/service/AchievementServiceImplTest.java @@ -125,19 +125,16 @@ void findAllACHIEVEDInRepoTest() { @Test void findAllUNACHIEVEDInRepoTest() { when(userService.findByEmail("email@gmail.com")).thenReturn(ModelUtils.getUserVO()); - when(achievementRepo.findAll()).thenReturn(Arrays.asList(ModelUtils.getAchievement())); when(modelMapper.map(ModelUtils.getUserVO(), User.class)).thenReturn(ModelUtils.getUser()); - when(userAchievementRepo.getUserAchievementByUserId(anyLong())) - .thenReturn(Arrays.asList(ModelUtils.getUserAchievement())); - when(achievementRepo.findById(anyLong())).thenReturn(Optional.of(ModelUtils.getAchievement())); + when(achievementRepo.searchAchievementsUnAchieved(anyLong())) + .thenReturn(Arrays.asList(ModelUtils.getAchievement())); when(modelMapper.map(ModelUtils.getAchievement(), AchievementVO.class)) .thenReturn(ModelUtils.getAchievementVO()); List findAllResult = achievementService.findAllByType("email@gmail.com", "UNACHIEVED"); - assertTrue(findAllResult.isEmpty()); + assertEquals(1L, (long) findAllResult.get(0).getId()); verify(userService).findByEmail("email@gmail.com"); verify(modelMapper).map(ModelUtils.getUserVO(), User.class); - verify(userAchievementRepo).getUserAchievementByUserId(anyLong()); - verify(modelMapper, times(2)).map(ModelUtils.getAchievement(), AchievementVO.class); + verify(achievementRepo).searchAchievementsUnAchieved(anyLong()); } @Test