forked from Sanders/TelegaBot
Fix imports
This commit is contained in:
@@ -2,7 +2,6 @@ package ru.cathub.telegabot;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
|
||||
@SpringBootApplication
|
||||
public class TelegaBotApplication {
|
||||
|
||||
@@ -1,14 +1,7 @@
|
||||
package ru.cathub.telegabot.bot;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.telegram.telegrambots.longpolling.util.TelegramOkHttpClientFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.telegram.telegrambots.client.okhttp.OkHttpTelegramClient;
|
||||
import org.telegram.telegrambots.longpolling.BotSession;
|
||||
@@ -16,24 +9,13 @@ import org.telegram.telegrambots.longpolling.interfaces.LongPollingUpdateConsume
|
||||
import org.telegram.telegrambots.longpolling.starter.AfterBotRegistration;
|
||||
import org.telegram.telegrambots.longpolling.starter.SpringLongPollingBot;
|
||||
import org.telegram.telegrambots.longpolling.util.LongPollingSingleThreadUpdateConsumer;
|
||||
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
|
||||
import org.telegram.telegrambots.meta.api.objects.File;
|
||||
import org.telegram.telegrambots.meta.api.objects.Update;
|
||||
import org.telegram.telegrambots.meta.api.objects.User;
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboardMarkup;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
|
||||
import org.telegram.telegrambots.meta.generics.TelegramClient;
|
||||
import ru.cathub.telegabot.exception.ServiceException;
|
||||
import ru.cathub.telegabot.model.BotUser;
|
||||
import ru.cathub.telegabot.service.BookManageService;
|
||||
import ru.cathub.telegabot.service.DataService;
|
||||
import ru.cathub.telegabot.service.TelegramBotService;
|
||||
import ru.cathub.telegabot.service.TelegramClientService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class TelegaBot implements SpringLongPollingBot, LongPollingSingleThreadUpdateConsumer {
|
||||
|
||||
@@ -3,11 +3,10 @@ package ru.cathub.telegabot.configuration;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.cache.caffeine.CaffeineCacheManager;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import org.springframework.cache.caffeine.CaffeineCacheManager;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Configuration
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
package ru.cathub.telegabot.configuration;
|
||||
|
||||
import io.hypersistence.utils.hibernate.query.QueryStackTraceLogger;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.springframework.boot.autoconfigure.orm.jpa.HibernatePropertiesCustomizer;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
//
|
||||
//@Configuration
|
||||
//public class HibernateConfig implements HibernatePropertiesCustomizer {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package ru.cathub.telegabot.configuration;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
|
||||
@@ -1,17 +1,10 @@
|
||||
package ru.cathub.telegabot.configuration;
|
||||
|
||||
import io.hypersistence.utils.hibernate.query.QueryStackTraceLogger;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.orm.jpa.HibernatePropertiesCustomizer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.telegram.telegrambots.client.okhttp.OkHttpTelegramClient;
|
||||
import org.telegram.telegrambots.meta.generics.TelegramClient;
|
||||
import ru.cathub.telegabot.bot.TelegaBot;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Configuration
|
||||
public class TelegramConfig {
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package ru.cathub.telegabot.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.sql.Date;
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package ru.cathub.telegabot.model;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
package ru.cathub.telegabot.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@Entity
|
||||
@Table(name = "messages")
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
package ru.cathub.telegabot.repository;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import ru.cathub.telegabot.model.Book;
|
||||
import ru.cathub.telegabot.model.BotUser;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package ru.cathub.telegabot.service;
|
||||
|
||||
import ru.cathub.telegabot.exception.ServiceException;
|
||||
import ru.cathub.telegabot.model.BookCreationCache;
|
||||
import ru.cathub.telegabot.model.BotUser;
|
||||
|
||||
public interface BookManageService {
|
||||
|
||||
@@ -2,6 +2,7 @@ package ru.cathub.telegabot.service;
|
||||
|
||||
import ru.cathub.telegabot.exception.OpenRouterException;
|
||||
import ru.cathub.telegabot.model.TextRole;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package ru.cathub.telegabot.service;
|
||||
|
||||
import ru.cathub.telegabot.model.BotUser;
|
||||
import ru.cathub.telegabot.exception.ServiceException;
|
||||
import ru.cathub.telegabot.model.BotUser;
|
||||
|
||||
public interface ProfileService {
|
||||
void enterProfileEditingMode(BotUser user);
|
||||
|
||||
@@ -2,14 +2,13 @@ package ru.cathub.telegabot.service.impl;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import ru.cathub.telegabot.model.Book;
|
||||
import ru.cathub.telegabot.model.BookCreationCache;
|
||||
import ru.cathub.telegabot.model.BotUser;
|
||||
import ru.cathub.telegabot.model.TextRole;
|
||||
import ru.cathub.telegabot.repository.BookRepository;
|
||||
import ru.cathub.telegabot.model.BotUser;
|
||||
import ru.cathub.telegabot.repository.UserRepository;
|
||||
import ru.cathub.telegabot.service.*;
|
||||
import ru.cathub.telegabot.utils.Constants;
|
||||
@@ -20,9 +19,8 @@ import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
import static ru.cathub.telegabot.model.BookEditStateCache.BookEditState.*;
|
||||
import static ru.cathub.telegabot.utils.BookFormatUtils.*;
|
||||
import static ru.cathub.telegabot.utils.Constants.*;
|
||||
import static ru.cathub.telegabot.utils.Constants.ADD_BOOK;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
|
||||
@@ -1,26 +1,25 @@
|
||||
package ru.cathub.telegabot.service.impl;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.cathub.telegabot.bot.KeyboardHelper;
|
||||
import ru.cathub.telegabot.exception.ServiceException;
|
||||
import ru.cathub.telegabot.model.Book;
|
||||
import ru.cathub.telegabot.model.BookEditStateCache;
|
||||
import ru.cathub.telegabot.model.BotUser;
|
||||
import ru.cathub.telegabot.repository.BookRepository;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Optional;
|
||||
|
||||
import ru.cathub.telegabot.repository.UserRepository;
|
||||
import ru.cathub.telegabot.service.BookCacheService;
|
||||
import ru.cathub.telegabot.service.BookEditingService;
|
||||
import ru.cathub.telegabot.service.TelegramClientService;
|
||||
import ru.cathub.telegabot.utils.Constants;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Optional;
|
||||
|
||||
import static ru.cathub.telegabot.bot.KeyboardHelper.getEditOptions;
|
||||
import static ru.cathub.telegabot.utils.Constants.ERROR_DELETE_BOOKS;
|
||||
|
||||
|
||||
@@ -5,22 +5,20 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.cathub.telegabot.model.Book;
|
||||
import ru.cathub.telegabot.model.BookEditStateCache;
|
||||
import ru.cathub.telegabot.model.BookListCache;
|
||||
import ru.cathub.telegabot.repository.BookRepository;
|
||||
import static ru.cathub.telegabot.bot.KeyboardHelper.getBookListKeyboard;
|
||||
import static ru.cathub.telegabot.utils.Constants.EMPTY_STAR;
|
||||
import static ru.cathub.telegabot.utils.Constants.FULL_STAR;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.cathub.telegabot.model.BotUser;
|
||||
import ru.cathub.telegabot.repository.BookRepository;
|
||||
import ru.cathub.telegabot.service.BookCacheService;
|
||||
import ru.cathub.telegabot.service.BookListingService;
|
||||
import ru.cathub.telegabot.service.TelegramClientService;
|
||||
import ru.cathub.telegabot.utils.BookFormatUtils;
|
||||
import ru.cathub.telegabot.utils.Constants;
|
||||
|
||||
import static ru.cathub.telegabot.bot.KeyboardHelper.getBookListKeyboard;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
|
||||
@@ -2,22 +2,15 @@ package ru.cathub.telegabot.service.impl;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.cathub.telegabot.bot.KeyboardHelper;
|
||||
import ru.cathub.telegabot.model.BookEditStateCache;
|
||||
import ru.cathub.telegabot.model.BookCreationCache;
|
||||
import ru.cathub.telegabot.model.*;
|
||||
import ru.cathub.telegabot.model.BookEditStateCache;
|
||||
import ru.cathub.telegabot.model.BotUser;
|
||||
import ru.cathub.telegabot.repository.BookRepository;
|
||||
import ru.cathub.telegabot.repository.UserRepository;
|
||||
import ru.cathub.telegabot.service.*;
|
||||
import ru.cathub.telegabot.utils.Constants;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import static ru.cathub.telegabot.bot.KeyboardHelper.*;
|
||||
import static ru.cathub.telegabot.utils.Constants.*;
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package ru.cathub.telegabot.service.impl;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package ru.cathub.telegabot.utils;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.caffeine.CaffeineCacheManager;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
//
|
||||
//public class CacheUtils {
|
||||
// @Bean
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package ru.cathub.telegabot;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
@@ -13,7 +13,8 @@ import ru.cathub.telegabot.exception.OpenRouterException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package ru.cathub.telegabot.service;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -17,7 +16,8 @@ import ru.cathub.telegabot.service.impl.OpenRouterServiceImpl;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
||||
@@ -8,8 +8,6 @@ import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import ru.cathub.telegabot.model.Book;
|
||||
import ru.cathub.telegabot.model.BookCreationCache;
|
||||
import ru.cathub.telegabot.model.BotUser;
|
||||
@@ -18,11 +16,11 @@ import ru.cathub.telegabot.service.BookCacheService;
|
||||
import ru.cathub.telegabot.service.BookCommonService;
|
||||
import ru.cathub.telegabot.service.TelegramClientService;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static ru.cathub.telegabot.model.BookCreationCache.CreationState.*;
|
||||
import static ru.cathub.telegabot.utils.Constants.*;
|
||||
import static ru.cathub.telegabot.model.BookCreationCache.CreationState.ADDING_TITLE;
|
||||
import static ru.cathub.telegabot.utils.Constants.ADD_BOOK;
|
||||
|
||||
@Nested
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
|
||||
@@ -7,7 +7,6 @@ import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import ru.cathub.telegabot.model.Book;
|
||||
import ru.cathub.telegabot.model.BookCreationCache;
|
||||
import ru.cathub.telegabot.model.BookEditStateCache;
|
||||
import ru.cathub.telegabot.model.BotUser;
|
||||
import ru.cathub.telegabot.repository.BookRepository;
|
||||
@@ -16,10 +15,11 @@ import ru.cathub.telegabot.service.TelegramClientService;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static ru.cathub.telegabot.model.BookEditStateCache.BookEditState.*;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static ru.cathub.telegabot.model.BookEditStateCache.BookEditState.EDITING_TITLE;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class BookEditingServiceImplTest {
|
||||
|
||||
@@ -8,7 +8,6 @@ import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import ru.cathub.telegabot.model.Book;
|
||||
import ru.cathub.telegabot.model.BotUser;
|
||||
@@ -18,12 +17,12 @@ import ru.cathub.telegabot.service.TelegramClientService;
|
||||
import ru.cathub.telegabot.utils.BookFormatUtils;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class BookListingServiceImplTest {
|
||||
|
||||
@@ -7,15 +7,15 @@ import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboardMarkup;
|
||||
import ru.cathub.telegabot.model.BookCreationCache;
|
||||
import ru.cathub.telegabot.model.BotUser;
|
||||
import ru.cathub.telegabot.repository.UserRepository;
|
||||
import ru.cathub.telegabot.service.*;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static ru.cathub.telegabot.utils.Constants.*;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static ru.cathub.telegabot.utils.Constants.ADD_BOOK;
|
||||
import static ru.cathub.telegabot.utils.Constants.LIST_BOOKS;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class BookManageServiceImplTest {
|
||||
|
||||
Reference in New Issue
Block a user