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
@@ -28,10 +28,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* <p>The Special Case Pattern is a software design pattern that encapsulates particular cases
* into subclasses that provide special behaviors.</p>
* The Special Case Pattern is a software design pattern that encapsulates particular cases into
* subclasses that provide special behaviors.
*
* <p>In this example ({@link ReceiptViewModel}) encapsulates all particular cases.</p>
* <p>In this example ({@link ReceiptViewModel}) encapsulates all particular cases.
*/
public class App {
@@ -44,13 +44,13 @@ public class App {
private static final String ITEM_CAR = "car";
private static final String ITEM_COMPUTER = "computer";
/**
* Program entry point.
*/
/** Program entry point. */
public static void main(String[] args) {
// DB seeding
LOGGER.info("Db seeding: " + "1 user: {\"ignite1771\", amount = 1000.0}, "
+ "2 products: {\"computer\": price = 800.0, \"car\": price = 20000.0}");
LOGGER.info(
"Db seeding: "
+ "1 user: {\"ignite1771\", amount = 1000.0}, "
+ "2 products: {\"computer\": price = 800.0, \"car\": price = 20000.0}");
Db.getInstance().seedUser(TEST_USER_1, 1000.0);
Db.getInstance().seedItem(ITEM_COMPUTER, 800.0);
Db.getInstance().seedItem(ITEM_CAR, 20000.0);
@@ -24,9 +24,7 @@
*/
package com.iluwatar.specialcase;
/**
* ApplicationServices interface to demonstrate special case pattern.
*/
/** ApplicationServices interface to demonstrate special case pattern. */
public interface ApplicationServices {
ReceiptViewModel loggedInUserPurchase(String userName, String itemName);
@@ -24,9 +24,7 @@
*/
package com.iluwatar.specialcase;
/**
* Implementation of special case pattern.
*/
/** Implementation of special case pattern. */
public class ApplicationServicesImpl implements ApplicationServices {
private DomainServicesImpl domain = new DomainServicesImpl();
@@ -29,9 +29,7 @@ import java.util.Map;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
/**
* DB class for seeding user info.
*/
/** DB class for seeding user info. */
public class Db {
private static Db instance;
@@ -118,9 +116,7 @@ public class Db {
return itemName2Product.get(itemName);
}
/**
* User class to store user info.
*/
/** User class to store user info. */
@RequiredArgsConstructor
@Getter
public class User {
@@ -132,9 +128,7 @@ public class Db {
}
}
/**
* Account info.
*/
/** Account info. */
@RequiredArgsConstructor
@Getter
public static class Account {
@@ -155,9 +149,7 @@ public class Db {
}
}
/**
* Product info.
*/
/** Product info. */
@RequiredArgsConstructor
@Getter
public static class Product {
@@ -24,8 +24,5 @@
*/
package com.iluwatar.specialcase;
/**
* DomainServices interface.
*/
public interface DomainServices {
}
/** DomainServices interface. */
public interface DomainServices {}
@@ -24,9 +24,7 @@
*/
package com.iluwatar.specialcase;
/**
* Implementation of DomainServices for special case.
*/
/** Implementation of DomainServices for special case. */
public class DomainServicesImpl implements DomainServices {
/**
@@ -47,9 +45,8 @@ public class DomainServicesImpl implements DomainServices {
}
/**
* Domain purchase with user, account and itemName,
* with validation for whether product is out of stock
* and whether user has insufficient funds in the account.
* Domain purchase with user, account and itemName, with validation for whether product is out of
* stock and whether user has insufficient funds in the account.
*
* @param user in Db
* @param account in Db
@@ -27,9 +27,7 @@ package com.iluwatar.specialcase;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Down for Maintenance view for the ReceiptViewModel.
*/
/** Down for Maintenance view for the ReceiptViewModel. */
public class DownForMaintenance implements ReceiptViewModel {
private static final Logger LOGGER = LoggerFactory.getLogger(DownForMaintenance.class);
@@ -26,9 +26,7 @@ package com.iluwatar.specialcase;
import lombok.extern.slf4j.Slf4j;
/**
* View representing insufficient funds.
*/
/** View representing insufficient funds. */
@Slf4j
public class InsufficientFunds implements ReceiptViewModel {
@@ -51,7 +49,12 @@ public class InsufficientFunds implements ReceiptViewModel {
@Override
public void show() {
LOGGER.info("Insufficient funds: " + amount + " of user: " + userName
+ " for buying item: " + itemName);
LOGGER.info(
"Insufficient funds: "
+ amount
+ " of user: "
+ userName
+ " for buying item: "
+ itemName);
}
}
@@ -27,9 +27,7 @@ package com.iluwatar.specialcase;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Receipt View representing invalid user.
*/
/** Receipt View representing invalid user. */
public class InvalidUser implements ReceiptViewModel {
private static final Logger LOGGER = LoggerFactory.getLogger(InvalidUser.class);
@@ -28,17 +28,14 @@ import lombok.Getter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Acquire lock on the DB for maintenance.
*/
/** Acquire lock on the DB for maintenance. */
public class MaintenanceLock {
private static final Logger LOGGER = LoggerFactory.getLogger(MaintenanceLock.class);
private static MaintenanceLock instance;
@Getter
private boolean lock = true;
@Getter private boolean lock = true;
/**
* Get the instance of MaintenanceLock.
@@ -26,9 +26,7 @@ package com.iluwatar.specialcase;
import lombok.RequiredArgsConstructor;
/**
* Represents the money transaction taking place at a given moment.
*/
/** Represents the money transaction taking place at a given moment. */
@RequiredArgsConstructor
public class MoneyTransaction {
@@ -27,9 +27,7 @@ package com.iluwatar.specialcase;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Receipt view for showing out of stock message.
*/
/** Receipt view for showing out of stock message. */
public class OutOfStock implements ReceiptViewModel {
private static final Logger LOGGER = LoggerFactory.getLogger(OutOfStock.class);
@@ -29,9 +29,7 @@ import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Receipt view representing the transaction recceipt.
*/
/** Receipt view representing the transaction recceipt. */
@RequiredArgsConstructor
@Getter
public class ReceiptDto implements ReceiptViewModel {
@@ -24,9 +24,7 @@
*/
package com.iluwatar.specialcase;
/**
* ReceiptViewModel interface.
*/
/** ReceiptViewModel interface. */
public interface ReceiptViewModel {
void show();
@@ -28,13 +28,11 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import org.junit.jupiter.api.Test;
/**
* Application test.
*/
/** Application test. */
class AppTest {
@Test
void shouldExecuteWithoutException() {
assertDoesNotThrow(() -> App.main(new String[]{}));
assertDoesNotThrow(() -> App.main(new String[] {}));
}
}
@@ -26,19 +26,17 @@ package com.iluwatar.specialcase;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.BeforeAll;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.read.ListAppender;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.slf4j.LoggerFactory;
/**
* Special cases unit tests. (including the successful scenario {@link ReceiptDto})
*/
/** Special cases unit tests. (including the successful scenario {@link ReceiptDto}) */
class SpecialCasesTest {
private static ApplicationServices applicationServices;
private static ReceiptViewModel receipt;
@@ -102,8 +100,8 @@ class SpecialCasesTest {
receipt.show();
List<ILoggingEvent> loggingEventList = listAppender.list;
assertEquals("Out of stock: tv for user = ignite1771 to buy"
, loggingEventList.get(0).getMessage());
assertEquals(
"Out of stock: tv for user = ignite1771 to buy", loggingEventList.get(0).getMessage());
assertEquals(Level.INFO, loggingEventList.get(0).getLevel());
}
@@ -119,8 +117,9 @@ class SpecialCasesTest {
receipt.show();
List<ILoggingEvent> loggingEventList = listAppender.list;
assertEquals("Insufficient funds: 1000.0 of user: ignite1771 for buying item: car"
, loggingEventList.get(0).getMessage());
assertEquals(
"Insufficient funds: 1000.0 of user: ignite1771 for buying item: car",
loggingEventList.get(0).getMessage());
assertEquals(Level.INFO, loggingEventList.get(0).getLevel());
}
@@ -136,8 +135,7 @@ class SpecialCasesTest {
receipt.show();
List<ILoggingEvent> loggingEventList = listAppender.list;
assertEquals("Receipt: 800.0 paid"
, loggingEventList.get(0).getMessage());
assertEquals("Receipt: 800.0 paid", loggingEventList.get(0).getMessage());
assertEquals(Level.INFO, loggingEventList.get(0).getLevel());
}
}