@Test void updateStatusGivenPlaceIdNullThenThrowException() { assertThrows(NotFoundException.class, () -> { placeService.updateStatus(null, PlaceStatus.PROPOSED); }); }
@Override public UpdatePlaceStatusDto updateStatus(Long id, PlaceStatus status) { log.info(LogMessage.IN_UPDATE_PLACE_STATUS, id, status); Place updatable = findById(id); PlaceStatus oldStatus = updatable.getStatus(); checkPlaceStatuses(oldStatus, status, id); updatable.setStatus(status); updatable.setModifiedDate(ZonedDateTime.now(datasourceTimezone)); if (status.equals(PlaceStatus.APPROVED)) { notificationService.sendImmediatelyReport(updatable); } if (oldStatus.equals(PlaceStatus.PROPOSED)) { rabbitTemplate.convertAndSend(sendEmailTopic, CHANGE_PLACE_STATUS_ROUTING_KEY, new SendChangePlaceStatusEmailMessage(updatable.getAuthor().getName(), updatable.getName(), updatable.getStatus().toString().toLowerCase(), updatable.getAuthor().getEmail())); } return modelMapper.map(placeRepo.save(updatable), UpdatePlaceStatusDto.class); }
PlaceServiceImpl implements PlaceService { @Override public UpdatePlaceStatusDto updateStatus(Long id, PlaceStatus status) { log.info(LogMessage.IN_UPDATE_PLACE_STATUS, id, status); Place updatable = findById(id); PlaceStatus oldStatus = updatable.getStatus(); checkPlaceStatuses(oldStatus, status, id); updatable.setStatus(status); updatable.setModifiedDate(ZonedDateTime.now(datasourceTimezone)); if (status.equals(PlaceStatus.APPROVED)) { notificationService.sendImmediatelyReport(updatable); } if (oldStatus.equals(PlaceStatus.PROPOSED)) { rabbitTemplate.convertAndSend(sendEmailTopic, CHANGE_PLACE_STATUS_ROUTING_KEY, new SendChangePlaceStatusEmailMessage(updatable.getAuthor().getName(), updatable.getName(), updatable.getStatus().toString().toLowerCase(), updatable.getAuthor().getEmail())); } return modelMapper.map(placeRepo.save(updatable), UpdatePlaceStatusDto.class); } }
PlaceServiceImpl implements PlaceService { @Override public UpdatePlaceStatusDto updateStatus(Long id, PlaceStatus status) { log.info(LogMessage.IN_UPDATE_PLACE_STATUS, id, status); Place updatable = findById(id); PlaceStatus oldStatus = updatable.getStatus(); checkPlaceStatuses(oldStatus, status, id); updatable.setStatus(status); updatable.setModifiedDate(ZonedDateTime.now(datasourceTimezone)); if (status.equals(PlaceStatus.APPROVED)) { notificationService.sendImmediatelyReport(updatable); } if (oldStatus.equals(PlaceStatus.PROPOSED)) { rabbitTemplate.convertAndSend(sendEmailTopic, CHANGE_PLACE_STATUS_ROUTING_KEY, new SendChangePlaceStatusEmailMessage(updatable.getAuthor().getName(), updatable.getName(), updatable.getStatus().toString().toLowerCase(), updatable.getAuthor().getEmail())); } return modelMapper.map(placeRepo.save(updatable), UpdatePlaceStatusDto.class); } @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 { @Override public UpdatePlaceStatusDto updateStatus(Long id, PlaceStatus status) { log.info(LogMessage.IN_UPDATE_PLACE_STATUS, id, status); Place updatable = findById(id); PlaceStatus oldStatus = updatable.getStatus(); checkPlaceStatuses(oldStatus, status, id); updatable.setStatus(status); updatable.setModifiedDate(ZonedDateTime.now(datasourceTimezone)); if (status.equals(PlaceStatus.APPROVED)) { notificationService.sendImmediatelyReport(updatable); } if (oldStatus.equals(PlaceStatus.PROPOSED)) { rabbitTemplate.convertAndSend(sendEmailTopic, CHANGE_PLACE_STATUS_ROUTING_KEY, new SendChangePlaceStatusEmailMessage(updatable.getAuthor().getName(), updatable.getName(), updatable.getStatus().toString().toLowerCase(), updatable.getAuthor().getEmail())); } return modelMapper.map(placeRepo.save(updatable), UpdatePlaceStatusDto.class); } @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 { @Override public UpdatePlaceStatusDto updateStatus(Long id, PlaceStatus status) { log.info(LogMessage.IN_UPDATE_PLACE_STATUS, id, status); Place updatable = findById(id); PlaceStatus oldStatus = updatable.getStatus(); checkPlaceStatuses(oldStatus, status, id); updatable.setStatus(status); updatable.setModifiedDate(ZonedDateTime.now(datasourceTimezone)); if (status.equals(PlaceStatus.APPROVED)) { notificationService.sendImmediatelyReport(updatable); } if (oldStatus.equals(PlaceStatus.PROPOSED)) { rabbitTemplate.convertAndSend(sendEmailTopic, CHANGE_PLACE_STATUS_ROUTING_KEY, new SendChangePlaceStatusEmailMessage(updatable.getAuthor().getName(), updatable.getName(), updatable.getStatus().toString().toLowerCase(), updatable.getAuthor().getEmail())); } return modelMapper.map(placeRepo.save(updatable), UpdatePlaceStatusDto.class); } @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();  }