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 14403 additions and 17632 deletions
@@ -101,6 +101,5 @@ public class App {
repository.deleteAll();
context.close();
}
}
@@ -60,9 +60,7 @@ public class AppConfig {
return basicDataSource;
}
/**
* Factory to create a specific instance of Entity Manager.
*/
/** Factory to create a specific instance of Entity Manager. */
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
var entityManager = new LocalContainerEntityManagerFactoryBean();
@@ -73,9 +71,7 @@ public class AppConfig {
return entityManager;
}
/**
* Properties for Jpa.
*/
/** Properties for Jpa. */
private static Properties jpaProperties() {
var properties = new Properties();
properties.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
@@ -83,9 +79,7 @@ public class AppConfig {
return properties;
}
/**
* Get transaction manager.
*/
/** Get transaction manager. */
@Bean
public JpaTransactionManager transactionManager() {
var transactionManager = new JpaTransactionManager();
@@ -145,7 +139,5 @@ public class AppConfig {
persons.stream().map(Person::toString).forEach(LOGGER::info);
context.close();
}
}
@@ -33,9 +33,7 @@ import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
/**
* Person entity.
*/
/** Person entity. */
@ToString
@EqualsAndHashCode
@Setter
@@ -44,20 +42,15 @@ import lombok.ToString;
@NoArgsConstructor
public class Person {
@Id
@GeneratedValue
private Long id;
@Id @GeneratedValue private Long id;
private String name;
private String surname;
private int age;
/**
* Constructor.
*/
/** Constructor. */
public Person(String name, String surname, int age) {
this.name = name;
this.surname = surname;
this.age = age;
}
}
@@ -29,9 +29,7 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
/**
* Person repository.
*/
/** Person repository. */
@Repository
public interface PersonRepository
extends CrudRepository<Person, Long>, JpaSpecificationExecutor<Person> {
@@ -30,14 +30,10 @@ import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;
import org.springframework.data.jpa.domain.Specification;
/**
* Helper class, includes vary Specification as the abstraction of sql query criteria.
*/
/** Helper class, includes vary Specification as the abstraction of sql query criteria. */
public class PersonSpecifications {
/**
* Specifications stating the Between (From - To) Age Specification.
*/
/** Specifications stating the Between (From - To) Age Specification. */
public static class AgeBetweenSpec implements Specification<Person> {
private final int from;
@@ -53,12 +49,9 @@ public class PersonSpecifications {
public Predicate toPredicate(Root<Person> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
return cb.between(root.get("age"), from, to);
}
}
/**
* Name specification.
*/
/** Name specification. */
public static class NameEqualSpec implements Specification<Person> {
public final String name;
@@ -67,12 +60,9 @@ public class PersonSpecifications {
this.name = name;
}
/**
* Get predicate.
*/
/** Get predicate. */
public Predicate toPredicate(Root<Person> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
return cb.equal(root.get("name"), this.name);
}
}
}
@@ -28,8 +28,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import jakarta.annotation.Resource;
import java.util.List;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -45,8 +45,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
@SpringBootTest(classes = {AppConfig.class})
class AnnotationBasedRepositoryTest {
@Resource
private PersonRepository repository;
@Resource private PersonRepository repository;
private final Person peter = new Person("Peter", "Sagan", 17);
private final Person nasta = new Person("Nasta", "Kuzminova", 25);
@@ -55,9 +54,7 @@ class AnnotationBasedRepositoryTest {
private final List<Person> persons = List.of(peter, nasta, john, terry);
/**
* Prepare data for test
*/
/** Prepare data for test */
@BeforeEach
void setup() {
repository.saveAll(persons);
@@ -114,5 +111,4 @@ class AnnotationBasedRepositoryTest {
void cleanup() {
repository.deleteAll();
}
}
@@ -36,27 +36,20 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.transaction.annotation.Transactional;
/**
* This case is Just for test the Annotation Based configuration
*/
/** This case is Just for test the Annotation Based configuration */
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = {AppConfig.class})
class AppConfigTest {
@Autowired
DataSource dataSource;
@Autowired DataSource dataSource;
/**
* Test for bean instance
*/
/** Test for bean instance */
@Test
void testDataSource() {
assertNotNull(dataSource);
}
/**
* Test for correct query execution
*/
/** Test for correct query execution */
@Test
@Transactional
void testQuery() throws SQLException {
@@ -24,17 +24,15 @@
*/
package com.iluwatar.repository;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
/**
* Tests that Repository example runs without errors.
*/
import org.junit.jupiter.api.Test;
/** Tests that Repository example runs without errors. */
class AppTest {
@Test
void shouldExecuteWithoutException() {
assertDoesNotThrow(() -> App.main(new String[]{}));
assertDoesNotThrow(() -> App.main(new String[] {}));
}
}
@@ -28,8 +28,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import jakarta.annotation.Resource;
import java.util.List;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -45,8 +45,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
@SpringBootTest(properties = {"locations=classpath:applicationContext.xml"})
class RepositoryTest {
@Resource
private PersonRepository repository;
@Resource private PersonRepository repository;
private final Person peter = new Person("Peter", "Sagan", 17);
private final Person nasta = new Person("Nasta", "Kuzminova", 25);
@@ -55,9 +54,7 @@ class RepositoryTest {
private final List<Person> persons = List.of(peter, nasta, john, terry);
/**
* Prepare data for test
*/
/** Prepare data for test */
@BeforeEach
void setup() {
repository.saveAll(persons);
@@ -114,5 +111,4 @@ class RepositoryTest {
void cleanup() {
repository.deleteAll();
}
}