mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-23 16:25:17 +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:
@@ -23,27 +23,27 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
/*
|
||||
*The MIT License
|
||||
*Copyright © 2014-2021 Ilkka Seppälä
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
*of this software and associated documentation files (the "Software"), to deal
|
||||
*in the Software without restriction, including without limitation the rights
|
||||
*to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
*copies of the Software, and to permit persons to whom the Software is
|
||||
*furnished to do so, subject to the following conditions:
|
||||
*
|
||||
*The above copyright notice and this permission notice shall be included in
|
||||
*all copies or substantial portions of the Software.
|
||||
*
|
||||
*THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
*IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
*FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
*AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
*LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
*OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
*THE SOFTWARE.
|
||||
*/
|
||||
*The MIT License
|
||||
*Copyright © 2014-2021 Ilkka Seppälä
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
*of this software and associated documentation files (the "Software"), to deal
|
||||
*in the Software without restriction, including without limitation the rights
|
||||
*to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
*copies of the Software, and to permit persons to whom the Software is
|
||||
*furnished to do so, subject to the following conditions:
|
||||
*
|
||||
*The above copyright notice and this permission notice shall be included in
|
||||
*all copies or substantial portions of the Software.
|
||||
*
|
||||
*THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
*IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
*FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
*AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
*LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
*OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
*THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.monitor;
|
||||
|
||||
@@ -55,8 +55,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@Slf4j
|
||||
public class Bank {
|
||||
|
||||
@Getter
|
||||
private final int[] accounts;
|
||||
@Getter private final int[] accounts;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -74,7 +73,7 @@ public class Bank {
|
||||
*
|
||||
* @param accountA - source account
|
||||
* @param accountB - destination account
|
||||
* @param amount - amount to be transferred
|
||||
* @param amount - amount to be transferred
|
||||
*/
|
||||
public synchronized void transfer(int accountA, int accountB, int amount) {
|
||||
if (accounts[accountA] >= amount && accountA != accountB) {
|
||||
|
||||
@@ -28,6 +28,7 @@ import java.security.SecureRandom;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Executors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* The Monitor pattern is used in concurrent algorithms to achieve mutual exclusion.
|
||||
*
|
||||
@@ -46,7 +47,7 @@ public class Main {
|
||||
/**
|
||||
* Runner to perform a bunch of transfers and handle exception.
|
||||
*
|
||||
* @param bank bank object
|
||||
* @param bank bank object
|
||||
* @param latch signal finished execution
|
||||
*/
|
||||
public static void runner(Bank bank, CountDownLatch latch) {
|
||||
|
||||
@@ -24,11 +24,12 @@
|
||||
*/
|
||||
package com.iluwatar.monitor;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.junit.jupiter.api.Assumptions.*;
|
||||
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.junit.jupiter.api.Assumptions.*;
|
||||
|
||||
class BankTest {
|
||||
|
||||
|
||||
@@ -24,10 +24,11 @@
|
||||
*/
|
||||
package com.iluwatar.monitor;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Test if the application starts without throwing an exception. */
|
||||
class MainTest {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user