deps: Refactor dependencies (#3224)

* remove spring dep
move junit, logging, mockito under dep mgmt

* upgrade anti-corruption-layer deps

* async method invocation

* balking, bloc

* bridge to bytecode

* caching

* callback - cqrs

* component - health check

* hexagonal - metadata mapping

* rest of the patterns

* remove checkstyle, take spotless into use
This commit is contained in:
Ilkka Seppälä
2025-03-29 19:34:27 +02:00
committed by GitHub
parent 371439aeaa
commit 0ca162a55c
1863 changed files with 14408 additions and 17637 deletions
@@ -62,8 +62,8 @@ public class App {
commands.bookAddedToAuthor("Effective Java", 40.54, AppConstants.J_BLOCH);
commands.bookAddedToAuthor("Java Puzzlers", 39.99, AppConstants.J_BLOCH);
commands.bookAddedToAuthor("Java Concurrency in Practice", 29.40, AppConstants.J_BLOCH);
commands.bookAddedToAuthor("Patterns of Enterprise"
+ " Application Architecture", 54.01, AppConstants.M_FOWLER);
commands.bookAddedToAuthor(
"Patterns of Enterprise" + " Application Architecture", 54.01, AppConstants.M_FOWLER);
commands.bookAddedToAuthor("Domain Specific Languages", 48.89, AppConstants.M_FOWLER);
commands.authorNameUpdated(AppConstants.E_EVANS, "Eric J. Evans");
@@ -86,5 +86,4 @@ public class App {
HibernateUtil.getSessionFactory().close();
}
}
@@ -24,9 +24,7 @@
*/
package com.iluwatar.cqrs.commandes;
/**
* This interface represents the commands of the CQRS pattern.
*/
/** This interface represents the commands of the CQRS pattern. */
public interface CommandService {
void authorCreated(String username, String name, String email);
@@ -42,5 +40,4 @@ public interface CommandService {
void bookTitleUpdated(String oldTitle, String newTitle);
void bookPriceUpdated(String title, double price);
}
@@ -140,5 +140,4 @@ public class CommandServiceImpl implements CommandService {
session.getTransaction().commit();
}
}
}
@@ -24,14 +24,11 @@
*/
package com.iluwatar.cqrs.constants;
/**
* Class to define the constants.
*/
/** Class to define the constants. */
public class AppConstants {
public static final String E_EVANS = "eEvans";
public static final String J_BLOCH = "jBloch";
public static final String M_FOWLER = "mFowler";
public static final String USER_NAME = "username";
}
@@ -32,9 +32,7 @@ import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* This is an Author entity. It is used by Hibernate for persistence.
*/
/** This is an Author entity. It is used by Hibernate for persistence. */
@ToString
@Getter
@Setter
@@ -43,6 +41,7 @@ public class Author {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
private String username;
private String name;
private String email;
@@ -51,8 +50,8 @@ public class Author {
* Constructor.
*
* @param username username of the author
* @param name name of the author
* @param email email of the author
* @param name name of the author
* @param email email of the author
*/
public Author(String username, String name, String email) {
this.username = username;
@@ -60,7 +59,5 @@ public class Author {
this.email = email;
}
protected Author() {
}
protected Author() {}
}
@@ -45,16 +45,16 @@ public class Book {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
private String title;
private double price;
@ManyToOne
private Author author;
@ManyToOne private Author author;
/**
* Constructor.
*
* @param title title of the book
* @param price price of the book
* @param title title of the book
* @param price price of the book
* @param author author of the book
*/
public Book(String title, double price, Author author) {
@@ -63,7 +63,5 @@ public class Book {
this.author = author;
}
protected Book() {
}
protected Book() {}
}
@@ -30,9 +30,7 @@ import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;
/**
* This is a DTO (Data Transfer Object) author, contains only useful information to be returned.
*/
/** This is a DTO (Data Transfer Object) author, contains only useful information to be returned. */
@ToString
@EqualsAndHashCode
@Getter
@@ -43,5 +41,4 @@ public class Author {
private String name;
private String email;
private String username;
}
@@ -30,9 +30,7 @@ import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;
/**
* This is a DTO (Data Transfer Object) book, contains only useful information to be returned.
*/
/** This is a DTO (Data Transfer Object) book, contains only useful information to be returned. */
@ToString
@EqualsAndHashCode
@Getter
@@ -42,5 +40,4 @@ public class Book {
private String title;
private double price;
}
@@ -29,9 +29,7 @@ import com.iluwatar.cqrs.dto.Book;
import java.math.BigInteger;
import java.util.List;
/**
* This interface represents the query methods of the CQRS pattern.
*/
/** This interface represents the query methods of the CQRS pattern. */
public interface QueryService {
Author getAuthorByUsername(String username);
@@ -43,5 +41,4 @@ public interface QueryService {
BigInteger getAuthorBooksCount(String username);
BigInteger getAuthorsCount();
}
@@ -45,9 +45,10 @@ public class QueryServiceImpl implements QueryService {
public Author getAuthorByUsername(String username) {
Author authorDto;
try (var session = sessionFactory.openSession()) {
Query<Author> sqlQuery = session.createQuery(
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");
+ " from com.iluwatar.cqrs.domain.model.Author a where a.username=:username");
sqlQuery.setParameter(AppConstants.USER_NAME, username);
authorDto = sqlQuery.uniqueResult();
}
@@ -58,9 +59,10 @@ public class QueryServiceImpl implements QueryService {
public Book getBook(String title) {
Book bookDto;
try (var session = sessionFactory.openSession()) {
Query<Book> sqlQuery = session.createQuery(
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");
+ " from com.iluwatar.cqrs.domain.model.Book b where b.title=:title");
sqlQuery.setParameter("title", title);
bookDto = sqlQuery.uniqueResult();
}
@@ -71,10 +73,11 @@ public class QueryServiceImpl implements QueryService {
public List<Book> getAuthorBooks(String username) {
List<Book> bookDtos;
try (var session = sessionFactory.openSession()) {
Query<Book> sqlQuery = session.createQuery(
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");
+ " 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();
}
@@ -85,9 +88,11 @@ public class QueryServiceImpl implements QueryService {
public BigInteger getAuthorBooksCount(String username) {
BigInteger bookcount;
try (var session = sessionFactory.openSession()) {
var sqlQuery = session.createNativeQuery(
"SELECT count(b.title)" + " FROM Book b, Author a"
+ " where b.author_id = a.id and a.username=:username");
var sqlQuery =
session.createNativeQuery(
"SELECT count(b.title)"
+ " FROM Book b, Author a"
+ " where b.author_id = a.id and a.username=:username");
sqlQuery.setParameter(AppConstants.USER_NAME, username);
bookcount = (BigInteger) sqlQuery.uniqueResult();
}
@@ -103,5 +108,4 @@ public class QueryServiceImpl implements QueryService {
}
return authorcount;
}
}
@@ -54,5 +54,4 @@ public class HibernateUtil {
public static SessionFactory getSessionFactory() {
return SESSIONFACTORY;
}
}
@@ -36,9 +36,7 @@ import java.math.BigInteger;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
/**
* Integration test of IQueryService and ICommandService with h2 data
*/
/** Integration test of IQueryService and ICommandService with h2 data */
class IntegrationTest {
private static QueryService queryService;
@@ -64,7 +62,6 @@ class IntegrationTest {
commandService.bookAddedToAuthor("title2", 20, "username1");
commandService.bookPriceUpdated("title2", 30);
commandService.bookTitleUpdated("title2", "new_title2");
}
@Test
@@ -80,7 +77,6 @@ class IntegrationTest {
var author = queryService.getAuthorByUsername("new_username2");
var expectedAuthor = new Author("new_name2", "new_email2", "new_username2");
assertEquals(expectedAuthor, author);
}
@Test
@@ -109,5 +105,4 @@ class IntegrationTest {
var authorCount = queryService.getAuthorsCount();
assertEquals(new BigInteger("2"), authorCount);
}
}