mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-08-06 20:25:14 +00:00
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:
@@ -27,7 +27,6 @@ package com.iluwatar.servant;
|
||||
import java.util.List;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
||||
/**
|
||||
* Servant offers some functionality to a group of classes without defining that functionality in
|
||||
* each of them. A Servant is a class whose instance provides methods that take care of a desired
|
||||
@@ -41,17 +40,13 @@ public class App {
|
||||
private static final Servant jenkins = new Servant("Jenkins");
|
||||
private static final Servant travis = new Servant("Travis");
|
||||
|
||||
/**
|
||||
* Program entry point.
|
||||
*/
|
||||
/** Program entry point. */
|
||||
public static void main(String[] args) {
|
||||
scenario(jenkins, 1);
|
||||
scenario(travis, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Can add a List with enum Actions for variable scenarios.
|
||||
*/
|
||||
/** Can add a List with enum Actions for variable scenarios. */
|
||||
public static void scenario(Servant servant, int compliment) {
|
||||
var k = new King();
|
||||
var q = new Queen();
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
*/
|
||||
package com.iluwatar.servant;
|
||||
|
||||
/**
|
||||
* King.
|
||||
*/
|
||||
/** King. */
|
||||
public class King implements Royalty {
|
||||
|
||||
private boolean isDrunk;
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
*/
|
||||
package com.iluwatar.servant;
|
||||
|
||||
/**
|
||||
* Queen.
|
||||
*/
|
||||
/** Queen. */
|
||||
public class Queen implements Royalty {
|
||||
|
||||
private boolean isDrunk = true;
|
||||
@@ -64,5 +62,4 @@ public class Queen implements Royalty {
|
||||
public void setFlirtiness(boolean f) {
|
||||
this.isFlirty = f;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
*/
|
||||
package com.iluwatar.servant;
|
||||
|
||||
/**
|
||||
* Royalty.
|
||||
*/
|
||||
/** Royalty. */
|
||||
interface Royalty {
|
||||
|
||||
void getFed();
|
||||
|
||||
@@ -26,16 +26,12 @@ package com.iluwatar.servant;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Servant.
|
||||
*/
|
||||
/** Servant. */
|
||||
public class Servant {
|
||||
|
||||
public String name;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
/** Constructor. */
|
||||
public Servant(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
@@ -52,9 +48,7 @@ public class Servant {
|
||||
r.receiveCompliments();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we will be hanged.
|
||||
*/
|
||||
/** Check if we will be hanged. */
|
||||
public boolean checkIfYouWillBeHanged(List<Royalty> tableGuests) {
|
||||
return tableGuests.stream().allMatch(Royalty::getMood);
|
||||
}
|
||||
|
||||
@@ -24,17 +24,15 @@
|
||||
*/
|
||||
package com.iluwatar.servant;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
|
||||
/**
|
||||
* Application test
|
||||
*/
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Application test */
|
||||
class AppTest {
|
||||
|
||||
@Test
|
||||
void shouldExecuteWithoutException() {
|
||||
assertDoesNotThrow(() -> App.main(new String[]{}));
|
||||
assertDoesNotThrow(() -> App.main(new String[] {}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,10 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* KingTest
|
||||
*
|
||||
*/
|
||||
/** KingTest */
|
||||
class KingTest {
|
||||
|
||||
@Test
|
||||
@@ -102,5 +99,4 @@ class KingTest {
|
||||
king.changeMood();
|
||||
assertFalse(king.getMood());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,16 +24,12 @@
|
||||
*/
|
||||
package com.iluwatar.servant;
|
||||
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* QueenTest
|
||||
*
|
||||
*/
|
||||
/** QueenTest */
|
||||
class QueenTest {
|
||||
|
||||
@Test
|
||||
@@ -67,5 +63,4 @@ class QueenTest {
|
||||
queen.changeMood();
|
||||
assertTrue(queen.getMood());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,10 +33,7 @@ import static org.mockito.Mockito.when;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* ServantTest
|
||||
*
|
||||
*/
|
||||
/** ServantTest */
|
||||
class ServantTest {
|
||||
|
||||
@Test
|
||||
@@ -80,7 +77,5 @@ class ServantTest {
|
||||
|
||||
assertTrue(new Servant("test").checkIfYouWillBeHanged(goodCompany));
|
||||
assertTrue(new Servant("test").checkIfYouWillBeHanged(badCompany));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user