### Question:
FavoritePlaceServiceImpl implements FavoritePlaceService { @Override public FavoritePlaceDto update(FavoritePlaceDto favoritePlaceDto, String userEmail) { log.info(LogMessage.IN_UPDATE, favoritePlaceDto); FavoritePlace favoritePlace = repo.findByPlaceIdAndUserEmail(favoritePlaceDto.getPlaceId(), userEmail); if (favoritePlace == null) { throw new WrongIdException(ErrorMessage.FAVORITE_PLACE_NOT_FOUND + favoritePlaceDto.getPlaceId()); } favoritePlace.setName(favoritePlaceDto.getName()); return modelMapper.map(repo.save(favoritePlace), FavoritePlaceDto.class); }  @Override FavoritePlaceDto save(FavoritePlaceDto favoritePlaceDto, String userEmail); @Override FavoritePlaceDto update(FavoritePlaceDto favoritePlaceDto, String userEmail); @Override List<FavoritePlaceDto> findAllByUserEmail(String email); @Override @Transactional Long deleteByUserEmailAndPlaceId(Long placeId, String userEmail); @Override FavoritePlace findByPlaceId(Long placeId); @Override PlaceInfoDto getInfoFavoritePlace(Long placeId); @Override PlaceByBoundsDto getFavoritePlaceWithLocation(Long placeId, String email);  }### Answer:
@Test public void updateTest() { FavoritePlaceDto dto = ModelUtils.getFavoritePlaceDto(); FavoritePlace fp = ModelUtils.getFavoritePlace(); when(repo.findByPlaceIdAndUserEmail(any(), any())).thenReturn(fp); when(repo.save(any(FavoritePlace.class))).thenReturn(fp); favoritePlaceService.update(dto, fp.getUser().getEmail()); assertEquals(dto, dto); }
@Test public void updateFavoritePlaceNotExistTest() { FavoritePlaceDto dto = ModelUtils.getFavoritePlaceDto(); FavoritePlace fp = ModelUtils.getFavoritePlace(); Exception exception = assertThrows( WrongIdException.class, () -> { when(repo.findByPlaceIdAndUserEmail(any(), any())).thenReturn(null); favoritePlaceService.update(dto, fp.getUser().getEmail()); }); String expectedMessage = ErrorMessage.FAVORITE_PLACE_NOT_FOUND; String actualMessage = exception.getMessage(); assertTrue(actualMessage.contains(expectedMessage)); }