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
@@ -36,16 +36,16 @@ import lombok.extern.slf4j.Slf4j;
* calculated will need to be calculated again when theyre requested. Once the results are
* re-calculated, then the bool value can be cleared.
*
* <p>There are some points that need to be considered before diving into using this pattern:-
* there are some things youll need to consider:- (1) Do you need it? This design pattern works
* well when the results to be calculated are difficult or resource intensive to compute. You want
* to save them. You also dont want to be calculating them several times in a row when only the
* last one counts. (2) When do you set the dirty flag? Make sure that you set the dirty flag within
* the class itself whenever an important property changes. This property should affect the result
* of the calculated result and by changing the property, that makes the last result invalid. (3)
* When do you clear the dirty flag? It might seem obvious that the dirty flag should be cleared
* whenever the result is calculated with up-to-date information but there are other times when you
* might want to clear the flag.
* <p>There are some points that need to be considered before diving into using this pattern:- there
* are some things youll need to consider:- (1) Do you need it? This design pattern works well when
* the results to be calculated are difficult or resource intensive to compute. You want to save
* them. You also dont want to be calculating them several times in a row when only the last one
* counts. (2) When do you set the dirty flag? Make sure that you set the dirty flag within the
* class itself whenever an important property changes. This property should affect the result of
* the calculated result and by changing the property, that makes the last result invalid. (3) When
* do you clear the dirty flag? It might seem obvious that the dirty flag should be cleared whenever
* the result is calculated with up-to-date information but there are other times when you might
* want to clear the flag.
*
* <p>In this example, the {@link DataFetcher} holds the <i>dirty flag</i>. It fetches and
* re-fetches from <i>world.txt</i> when needed. {@link World} mainly serves the data to the
@@ -54,21 +54,23 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public class App {
/**
* Program execution point.
*/
/** Program execution point. */
public void run() {
final var executorService = Executors.newSingleThreadScheduledExecutor();
executorService.scheduleAtFixedRate(new Runnable() {
final World world = new World();
executorService.scheduleAtFixedRate(
new Runnable() {
final World world = new World();
@Override
public void run() {
var countries = world.fetch();
LOGGER.info("Our world currently has the following countries:-");
countries.stream().map(country -> "\t" + country).forEach(LOGGER::info);
}
}, 0, 15, TimeUnit.SECONDS); // Run at every 15 seconds.
@Override
public void run() {
var countries = world.fetch();
LOGGER.info("Our world currently has the following countries:-");
countries.stream().map(country -> "\t" + country).forEach(LOGGER::info);
}
},
0,
15,
TimeUnit.SECONDS); // Run at every 15 seconds.
}
/**
@@ -32,10 +32,7 @@ import java.util.List;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
/**
* A mock database manager -- Fetches data from a raw file.
*
*/
/** A mock database manager -- Fetches data from a raw file. */
@Slf4j
public class DataFetcher {
@@ -27,10 +27,7 @@ package com.iluwatar.dirtyflag;
import java.util.ArrayList;
import java.util.List;
/**
* A middle-layer app that calls/passes along data from the back-end.
*
*/
/** A middle-layer app that calls/passes along data from the back-end. */
public class World {
private List<String> countries;
@@ -24,24 +24,20 @@
*/
package org.dirty.flag;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import com.iluwatar.dirtyflag.App;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
/**
* Tests that Dirty-Flag example runs without errors.
*/
/** Tests that Dirty-Flag example runs without errors. */
class AppTest {
/**
* Issue: Add at least one assertion to this test case.
* Solution: Inserted assertion to check whether the execution of the main method in {@link App#main(String[])}
* throws an exception.
* Issue: Add at least one assertion to this test case. Solution: Inserted assertion to check
* whether the execution of the main method in {@link App#main(String[])} throws an exception.
*/
@Test
void shouldExecuteApplicationWithoutException() {
assertDoesNotThrow(() -> App.main(new String[]{}));
assertDoesNotThrow(() -> App.main(new String[] {}));
}
}
@@ -28,9 +28,7 @@ import com.iluwatar.dirtyflag.DataFetcher;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
* Application test
*/
/** Application test */
class DirtyFlagTest {
@Test