Skip to content

Commit

Permalink
Added ignorecase and dded tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ospodaryk committed Oct 12, 2023
1 parent 80658db commit e911875
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,18 @@ void findAllUnAchievedTest() throws Exception {
.andExpect(status().isOk());
verify(achievementService).findAllByType("[email protected]", "UNACHIEVED");
}

@Test
void findAllAchievedIgnoreCaseTest() throws Exception {
mockMvc.perform(get(achievementLink).principal(principal).param("achievementStatus", "AchieVED"))
.andExpect(status().isOk());
verify(achievementService).findAllByType("[email protected]", "AchieVED");
}

@Test
void findAllUnAchievedIgnoreCaseTest() throws Exception {
mockMvc.perform(get(achievementLink).principal(principal).param("achievementStatus", "unAchieVED"))
.andExpect(status().isOk());
verify(achievementService).findAllByType("[email protected]", "unAchieVED");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ private List<AchievementVO> findAll() {
public List<AchievementVO> findAllByType(String principalEmail, String achievementStatus) {
User currentUser = modelMapper.map(userService.findByEmail(principalEmail), User.class);
Long userId = currentUser.getId();
if (ACHIEVED.equals(achievementStatus)) {
if (ACHIEVED.equalsIgnoreCase(achievementStatus)) {
return findAllAchieved(userId);
} else if (UNACHIEVED.equals(achievementStatus)) {
} else if (UNACHIEVED.equalsIgnoreCase(achievementStatus)) {
return achievementRepo.searchAchievementsUnAchieved(userId).stream()
.map(achieve -> modelMapper.map(achieve, AchievementVO.class))
.collect(Collectors.toList());
Expand Down

0 comments on commit e911875

Please sign in to comment.