Skip to content

Commit

Permalink
Commit with update habit method change
Browse files Browse the repository at this point in the history
  • Loading branch information
Lena Sotnik authored and ospodaryk committed Oct 4, 2023
1 parent 22737dc commit 86a045e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,11 @@ private void enhanceHabitWithNewData(Habit toUpdate, CustomHabitDtoRequest habit
toUpdate.setDefaultDuration(habitDto.getDefaultDuration());
}
if (isNotEmpty(habitDto.getHabitTranslations())) {
toUpdate.setHabitTranslations(mapHabitTranslationFromAddCustomHabitDtoRequest(habitDto));
habitTranslationRepo.deleteAllByHabit(toUpdate);
saveHabitTranslationListsToHabitTranslationRepo(habitDto, toUpdate);
}
if (isNotEmpty(habitDto.getCustomShoppingListItemDto())) {
customShoppingListItemRepo.deleteCustomShoppingListItemsByHabitId(toUpdate.getId());
setCustomShoppingListItemToHabit(habitDto, toUpdate, user);
}
if (StringUtils.isNotBlank(habitDto.getImage())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ void updateCustomHabitTest() throws IOException {
verify(habitRepo).save(any());
verify(customHabitMapper).convert(customHabitDtoRequest);
verify(tagsRepo).findById(20L);
verify(habitTranslationMapper, times(3)).mapAllToList(List.of(habitTranslationDto));
verify(habitTranslationMapper, times(2)).mapAllToList(List.of(habitTranslationDto));
verify(languageRepo, times(2)).findByCode(anyString());
verify(customShoppingListItemRepo).findAllByUserIdAndHabitId(anyLong(), anyLong());
verify(customShoppingListMapper).mapAllToList(anyList());
Expand Down Expand Up @@ -895,7 +895,7 @@ void updateCustomHabitNoSuchElementExceptionWithNotExistingLanguageCodes() throw

verify(habitRepo).findById(anyLong());
verify(userRepo).findByEmail(user.getEmail());
verify(habitTranslationMapper, times(3))
verify(habitTranslationMapper, times(2))
.mapAllToList(customHabitDtoRequest.getHabitTranslations());
verify(languageRepo, times(2)).findByCode(anyString());
}
Expand Down

0 comments on commit 86a045e

Please sign in to comment.