@Test void saveTest() { when(modelMapper.map(placeAddDto,Place.class)).thenReturn(place); when(userService.findByEmail(anyString())).thenReturn(user); when(categoryService.findByName(anyString())).thenReturn(category); when(placeRepo.save(place)).thenReturn(place); assertEquals(place, placeService.save(placeAddDto, user.getEmail())); }
@Transactional @Override public Place save(PlaceAddDto dto, String email) { log.info(LogMessage.IN_SAVE, dto.getName(), email); proposePlaceService.checkLocationValues(dto.getLocation()); proposePlaceService.checkInputTime(dto.getOpeningHoursList()); Place place = modelMapper.map(dto, Place.class); setUserToPlaceByEmail(email, place); place.setCategory(categoryService.findByName(dto.getCategory().getName())); proposePlaceService.saveDiscountValuesWithPlace(place.getDiscountValues(), place); proposePlaceService.savePhotosWithPlace(place.getPhotos(), place); return placeRepo.save(place); }
PlaceServiceImpl implements PlaceService { @Transactional @Override public Place save(PlaceAddDto dto, String email) { log.info(LogMessage.IN_SAVE, dto.getName(), email); proposePlaceService.checkLocationValues(dto.getLocation()); proposePlaceService.checkInputTime(dto.getOpeningHoursList()); Place place = modelMapper.map(dto, Place.class); setUserToPlaceByEmail(email, place); place.setCategory(categoryService.findByName(dto.getCategory().getName())); proposePlaceService.saveDiscountValuesWithPlace(place.getDiscountValues(), place); proposePlaceService.savePhotosWithPlace(place.getPhotos(), place); return placeRepo.save(place); } }
PlaceServiceImpl implements PlaceService { @Transactional @Override public Place save(PlaceAddDto dto, String email) { log.info(LogMessage.IN_SAVE, dto.getName(), email); proposePlaceService.checkLocationValues(dto.getLocation()); proposePlaceService.checkInputTime(dto.getOpeningHoursList()); Place place = modelMapper.map(dto, Place.class); setUserToPlaceByEmail(email, place); place.setCategory(categoryService.findByName(dto.getCategory().getName())); proposePlaceService.saveDiscountValuesWithPlace(place.getDiscountValues(), place); proposePlaceService.savePhotosWithPlace(place.getPhotos(), place); return placeRepo.save(place); } @Autowired  PlaceServiceImpl(PlaceRepo placeRepo,
                            ModelMapper modelMapper,
                            CategoryService categoryService,
                            LocationService locationService,
                            SpecificationService specificationService,
                            UserService userService,
                            OpenHoursService openingHoursService,
                            DiscountService discountService,
                            NotificationService notificationService,
                            @Qualifier(value = "datasourceTimezone") ZoneId datasourceTimezone,
                            RabbitTemplate rabbitTemplate,
                            ProposePlaceServiceImpl proposePlaceService); }
PlaceServiceImpl implements PlaceService { @Transactional @Override public Place save(PlaceAddDto dto, String email) { log.info(LogMessage.IN_SAVE, dto.getName(), email); proposePlaceService.checkLocationValues(dto.getLocation()); proposePlaceService.checkInputTime(dto.getOpeningHoursList()); Place place = modelMapper.map(dto, Place.class); setUserToPlaceByEmail(email, place); place.setCategory(categoryService.findByName(dto.getCategory().getName())); proposePlaceService.saveDiscountValuesWithPlace(place.getDiscountValues(), place); proposePlaceService.savePhotosWithPlace(place.getPhotos(), place); return placeRepo.save(place); } @Autowired  PlaceServiceImpl(PlaceRepo placeRepo,
                            ModelMapper modelMapper,
                            CategoryService categoryService,
                            LocationService locationService,
                            SpecificationService specificationService,
                            UserService userService,
                            OpenHoursService openingHoursService,
                            DiscountService discountService,
                            NotificationService notificationService,
                            @Qualifier(value = "datasourceTimezone") ZoneId datasourceTimezone,
                            RabbitTemplate rabbitTemplate,
                            ProposePlaceServiceImpl proposePlaceService); @Override PageableDto<AdminPlaceDto> getPlacesByStatus(PlaceStatus placeStatus, Pageable pageable); @Transactional @Override Place save(PlaceAddDto dto, String email); @Transactional @Override Place update(PlaceUpdateDto dto); @Override void deleteById(Long id); @Transactional @Override Long bulkDelete(List<Long> ids); @Override List<Place> findAll(); @Override UpdatePlaceStatusDto updateStatus(Long id, PlaceStatus status); @Transactional @Override List<UpdatePlaceStatusDto> updateStatuses(BulkUpdatePlaceStatusDto dto); @Override Place findById(Long id); @Override Optional<Place> findByIdOptional(Long id); @Override PlaceInfoDto getInfoById(Long id); @Override PlaceUpdateDto getInfoForUpdatingById(Long id); @Override List<PlaceByBoundsDto> findPlacesByMapsBounds(@Valid FilterPlaceDto filterPlaceDto); @Override boolean existsById(Long id); @Override Double averageRate(Long id); @Override List<PlaceByBoundsDto> getPlacesByFilter(FilterPlaceDto filterDto); @Override PageableDto<AdminPlaceDto> filterPlaceBySearchPredicate(FilterPlaceDto filterDto, Pageable pageable); @Override List<PlaceStatus> getStatuses(); }
PlaceServiceImpl implements PlaceService { @Transactional @Override public Place save(PlaceAddDto dto, String email) { log.info(LogMessage.IN_SAVE, dto.getName(), email); proposePlaceService.checkLocationValues(dto.getLocation()); proposePlaceService.checkInputTime(dto.getOpeningHoursList()); Place place = modelMapper.map(dto, Place.class); setUserToPlaceByEmail(email, place); place.setCategory(categoryService.findByName(dto.getCategory().getName())); proposePlaceService.saveDiscountValuesWithPlace(place.getDiscountValues(), place); proposePlaceService.savePhotosWithPlace(place.getPhotos(), place); return placeRepo.save(place); } @Autowired  PlaceServiceImpl(PlaceRepo placeRepo,
                            ModelMapper modelMapper,
                            CategoryService categoryService,
                            LocationService locationService,
                            SpecificationService specificationService,
                            UserService userService,
                            OpenHoursService openingHoursService,
                            DiscountService discountService,
                            NotificationService notificationService,
                            @Qualifier(value = "datasourceTimezone") ZoneId datasourceTimezone,
                            RabbitTemplate rabbitTemplate,
                            ProposePlaceServiceImpl proposePlaceService); @Override PageableDto<AdminPlaceDto> getPlacesByStatus(PlaceStatus placeStatus, Pageable pageable); @Transactional @Override Place save(PlaceAddDto dto, String email); @Transactional @Override Place update(PlaceUpdateDto dto); @Override void deleteById(Long id); @Transactional @Override Long bulkDelete(List<Long> ids); @Override List<Place> findAll(); @Override UpdatePlaceStatusDto updateStatus(Long id, PlaceStatus status); @Transactional @Override List<UpdatePlaceStatusDto> updateStatuses(BulkUpdatePlaceStatusDto dto); @Override Place findById(Long id); @Override Optional<Place> findByIdOptional(Long id); @Override PlaceInfoDto getInfoById(Long id); @Override PlaceUpdateDto getInfoForUpdatingById(Long id); @Override List<PlaceByBoundsDto> findPlacesByMapsBounds(@Valid FilterPlaceDto filterPlaceDto); @Override boolean existsById(Long id); @Override Double averageRate(Long id); @Override List<PlaceByBoundsDto> getPlacesByFilter(FilterPlaceDto filterDto); @Override PageableDto<AdminPlaceDto> filterPlaceBySearchPredicate(FilterPlaceDto filterDto, Pageable pageable); @Override List<PlaceStatus> getStatuses();  }