Skip to content

Commit

Permalink
dependencies: iluwatar#2449 bump maven-checkstyle-plugin from 3.1.0 t…
Browse files Browse the repository at this point in the history
…o 3.2.0 + resolve chec… (iluwatar#2464)

* iluwatar#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
  • Loading branch information
rahul-raj authored Feb 4, 2023
1 parent dbecffa commit fb7ec9b
Show file tree
Hide file tree
Showing 147 changed files with 486 additions and 288 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
package com.iluwatar.abstractdocument;

import org.junit.jupiter.api.Test;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import com.iluwatar.abstractdocument.domain.Part;
import com.iluwatar.abstractdocument.domain.enums.Property;
import org.junit.jupiter.api.Test;

import java.util.List;
import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
import lombok.Getter;
import lombok.Setter;

/**
* Helper class to manufacture {@link KingdomFactory} beans.
*/
@Getter
@Setter
public class Kingdom {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -77,8 +76,8 @@ protected ActiveCreature(String name) {
*/
public void eat() throws InterruptedException {
requests.put(() -> {
logger.info("{} is eating!",name());
logger.info("{} has finished eating!",name());
logger.info("{} is eating!", name());
logger.info("{} has finished eating!", name());
});
}

Expand All @@ -88,7 +87,7 @@ public void eat() throws InterruptedException {
*/
public void roam() throws InterruptedException {
requests.put(() ->
logger.info("{} has started to roam in the wastelands.",name())
logger.info("{} has started to roam in the wastelands.", name())
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -58,7 +57,7 @@ public static void main(String[] args) {
public void run() {
List<ActiveCreature> creatures = new ArrayList<>();
try {
for (int i = 0;i < NUM_CREATURES;i++) {
for (int i = 0; i < NUM_CREATURES; i++) {
creatures.add(new Orc(Orc.class.getSimpleName() + i));
creatures.get(i).eat();
creatures.get(i).roam();
Expand All @@ -68,7 +67,7 @@ public void run() {
logger.error(e.getMessage());
Thread.currentThread().interrupt();
} finally {
for (int i = 0;i < NUM_CREATURES;i++) {
for (int i = 0; i < NUM_CREATURES; i++) {
creatures.get(i).kill(0);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.HashMap;
import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
package com.iluwatar.business.delegate;

import org.junit.jupiter.api.Test;

import java.io.IOException;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
Expand Down
2 changes: 0 additions & 2 deletions caching/src/main/java/com/iluwatar/caching/AppManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
package com.iluwatar.caching;

import com.iluwatar.caching.database.DbManager;

import java.util.Optional;

import lombok.extern.slf4j.Slf4j;

/**
Expand Down
1 change: 0 additions & 1 deletion caching/src/main/java/com/iluwatar/caching/CacheStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

import lombok.extern.slf4j.Slf4j;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class MongoDb implements DbManager {
private MongoClient client;
private MongoDatabase db;

void setDB(MongoDatabase db) {
void setDb(MongoDatabase db) {
this.db = db;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
package com.iluwatar.caching.database;

import com.iluwatar.caching.UserAccount;

import java.util.HashMap;
import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class MongoDbTest {
@BeforeEach
void init() {
db = mock(MongoDatabase.class);
mongoDb.setDB(db);
mongoDb.setDb(db);
userAccount = new UserAccount(ID, NAME, ADDITIONAL_INFO);
}

Expand Down
1 change: 1 addition & 0 deletions checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
<suppress checks="[a-zA-Z0-9]*" files="[\\/]src[\\/]main[\\/]resources[\\/]" />
<suppress checks="LineLength" files="." />
<suppress checks="EmptyLineSeparator" files="." />
<suppress checks="RequireEmptyLineBeforeBlockTagGroup" files=".*\.java"/>
</suppressions>
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;

import java.util.LinkedList;
import java.util.Queue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;

import java.util.LinkedList;
import java.util.Queue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
package com.iluwatar.commander;

import com.iluwatar.commander.exceptions.DatabaseUnavailableException;

import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Hashtable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import com.iluwatar.commander.Database;
import com.iluwatar.commander.Order;
import com.iluwatar.commander.exceptions.DatabaseUnavailableException;

import java.util.HashMap;
import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@
import com.iluwatar.commander.queue.QueueDatabase;
import com.iluwatar.commander.shippingservice.ShippingDatabase;
import com.iluwatar.commander.shippingservice.ShippingService;

import org.junit.jupiter.api.Test;
import org.junit.platform.commons.util.StringUtils;

import java.util.ArrayList;
import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import jakarta.servlet.http.HttpServletResponse;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

import java.io.PrintWriter;
import java.io.StringWriter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@

import lombok.Getter;

/**
* Layer A in the context object pattern.
*/
@Getter
public class LayerA {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@

import lombok.Getter;

/**
* Layer B in the context object pattern.
*/
@Getter
public class LayerB {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@

import lombok.Getter;

/**
* Layer C in the context object pattern.
*/
@Getter
public class LayerC {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/**
* This interface represents the commands of the CQRS pattern.
*/
public interface ICommandService {
public interface CommandService {

void authorCreated(String username, String name, String email);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
/**
* This interface represents the query methods of the CQRS pattern.
*/
public interface IQueryService {
public interface QueryService {

Author getAuthorByUsername(String username);

Expand Down
22 changes: 11 additions & 11 deletions cqrs/src/main/java/com/iluwatar/cqrs/queries/QueryServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,51 +34,51 @@
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
Expand Down
4 changes: 2 additions & 2 deletions cqrs/src/test/java/com/iluwatar/cqrs/IntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
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;
Expand All @@ -41,7 +41,7 @@
*/
class IntegrationTest {

private static IQueryService queryService;
private static QueryService queryService;

@BeforeAll
static void initializeAndPopulateDatabase() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import java.time.LocalDate;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

import java.util.ArrayList;
import java.util.List;

import com.iluwatar.datatransfer.customer.CustomerDto;
import com.iluwatar.datatransfer.customer.CustomerResource;
import org.junit.jupiter.api.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;
import org.slf4j.LoggerFactory;

import java.util.LinkedList;
import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.sql.SQLException;
import java.time.LocalDate;
import javax.sql.DataSource;

import org.h2.jdbcx.JdbcDataSource;
import org.joda.money.Money;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import lombok.Builder;
import lombok.Getter;
import lombok.NonNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
import java.sql.SQLException;
import java.util.Optional;

/**
* DAO interface for customer transactions.
*/
public interface CustomerDao {

Optional<Customer> findByName(String name) throws SQLException;
Expand Down
Loading

0 comments on commit fb7ec9b

Please sign in to comment.