dependencies: #2449 bump maven-checkstyle-plugin from 3.1.0 to 3.2.0 + resolve chec… (#2464)

* #2449 bump maven-checkstyle-plugin from 3.1.0 to 3.2.0 + resolve checkstyle issues

* remove FileSelectorJFrame.java to resolve checkstyle issue

* remove FileSelectorJFrame.java to resolve checkstyle issue

* remove FileSelectorJFrame.java to resolve checkstyle issue

* add refactored file with correct filename to resolve checkstyle issue

* add the test data

* change filenames from JFrame to Jframe for checkstyle

* fix code smell from  sonar report

* add new testcases to improve the test coverage

* remove code smell
This commit is contained in:
Rahul Raj
2023-02-04 22:50:54 +05:30
committed by GitHub
parent dbecffacab
commit fb7ec9b375
147 changed files with 487 additions and 289 deletions
@@ -27,7 +27,7 @@ package com.iluwatar.cqrs.commandes;
/**
* This interface represents the commands of the CQRS pattern.
*/
public interface ICommandService {
public interface CommandService {
void authorCreated(String username, String name, String email);
@@ -30,10 +30,10 @@ import com.iluwatar.cqrs.util.HibernateUtil;
import org.hibernate.SessionFactory;
/**
* This class is an implementation of {@link ICommandService} interface. It uses Hibernate as an api
* This class is an implementation of {@link CommandService} interface. It uses Hibernate as an api
* for persistence.
*/
public class CommandServiceImpl implements ICommandService {
public class CommandServiceImpl implements CommandService {
private final SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
@@ -32,7 +32,7 @@ import java.util.List;
/**
* This interface represents the query methods of the CQRS pattern.
*/
public interface IQueryService {
public interface QueryService {
Author getAuthorByUsername(String username);
@@ -34,51 +34,51 @@ import org.hibernate.SessionFactory;
import org.hibernate.query.Query;
/**
* This class is an implementation of {@link IQueryService}. It uses Hibernate native queries to
* This class is an implementation of {@link QueryService}. It uses Hibernate native queries to
* return DTOs from the database.
*/
public class QueryServiceImpl implements IQueryService {
public class QueryServiceImpl implements QueryService {
private final SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
@Override
public Author getAuthorByUsername(String username) {
Author authorDTo;
Author authorDto;
try (var session = sessionFactory.openSession()) {
Query<Author> sqlQuery = session.createQuery(
"select new com.iluwatar.cqrs.dto.Author(a.name, a.email, a.username)"
+ " from com.iluwatar.cqrs.domain.model.Author a where a.username=:username");
sqlQuery.setParameter(AppConstants.USER_NAME, username);
authorDTo = sqlQuery.uniqueResult();
authorDto = sqlQuery.uniqueResult();
}
return authorDTo;
return authorDto;
}
@Override
public Book getBook(String title) {
Book bookDTo;
Book bookDto;
try (var session = sessionFactory.openSession()) {
Query<Book> sqlQuery = session.createQuery(
"select new com.iluwatar.cqrs.dto.Book(b.title, b.price)"
+ " from com.iluwatar.cqrs.domain.model.Book b where b.title=:title");
sqlQuery.setParameter("title", title);
bookDTo = sqlQuery.uniqueResult();
bookDto = sqlQuery.uniqueResult();
}
return bookDTo;
return bookDto;
}
@Override
public List<Book> getAuthorBooks(String username) {
List<Book> bookDTos;
List<Book> bookDtos;
try (var session = sessionFactory.openSession()) {
Query<Book> sqlQuery = session.createQuery(
"select new com.iluwatar.cqrs.dto.Book(b.title, b.price)"
+ " from com.iluwatar.cqrs.domain.model.Author a, com.iluwatar.cqrs.domain.model.Book b "
+ "where b.author.id = a.id and a.username=:username");
sqlQuery.setParameter(AppConstants.USER_NAME, username);
bookDTos = sqlQuery.list();
bookDtos = sqlQuery.list();
}
return bookDTos;
return bookDtos;
}
@Override
@@ -30,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import com.iluwatar.cqrs.commandes.CommandServiceImpl;
import com.iluwatar.cqrs.dto.Author;
import com.iluwatar.cqrs.dto.Book;
import com.iluwatar.cqrs.queries.IQueryService;
import com.iluwatar.cqrs.queries.QueryService;
import com.iluwatar.cqrs.queries.QueryServiceImpl;
import java.math.BigInteger;
import org.junit.jupiter.api.BeforeAll;
@@ -41,7 +41,7 @@ import org.junit.jupiter.api.Test;
*/
class IntegrationTest {
private static IQueryService queryService;
private static QueryService queryService;
@BeforeAll
static void initializeAndPopulateDatabase() {