Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge #1

Merged
merged 201 commits into from
Dec 26, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
201 commits
Select commit Hold shift + click to select a range
0c6237c
Type object pattern #555 (#848)
AnaghaSasikumar Jul 24, 2019
17bfc91
Change Travis CI build env. to Trusty (#911)
ptrax Jul 28, 2019
c6ecf58
508 : sonar qube critical issue fixes (#852)
kanwarpreet25 Jul 28, 2019
f7e22a1
508 : Sonar qube critical Issue Fix (#854)
kanwarpreet25 Jul 28, 2019
a113de6
Add licenses
iluwatar Jul 28, 2019
d9a567c
Commander pattern #505 (#857)
AnaghaSasikumar Jul 29, 2019
2757b21
Best practice when compare enum (#869)
hoangnam2261 Jul 29, 2019
aaabc8f
Fix the dependency conflict issue (#872)
HelloCoCooo Jul 29, 2019
b497d41
Modify Observer pattern UML (#877)
dRadest Jul 29, 2019
3454941
Typo coresponding -> corresponding (#879)
pierDipi Jul 29, 2019
36e80c4
fixed failing tests (#860) (#880)
id4us Jul 29, 2019
517c209
Added one more Credit/Article about the benefits of Repository patter…
tomrlh Jul 29, 2019
6daaeec
Remove the transitive dependency(junit-jupiter-api) (#916)
hoangnam2261 Jul 30, 2019
ccb257d
fixed bug #883 (#885)
ranjeet-floyd Aug 4, 2019
61ef59d
fix code example containing syntax error (#890)
makaravind Aug 11, 2019
085e47b
Update SonarCloud badge
iluwatar Aug 21, 2019
11c0550
Create .sonarcloud.properties
iluwatar Aug 21, 2019
7f6067f
Added priority queue design pattern (#888)
ranjeet-floyd Aug 31, 2019
318f811
Bytecode pattern #553 (#896)
pzawitowski Sep 3, 2019
35dc25d
MInor bug fix Issue #895 -> Code comment change (https://github.com/i…
saksham93 Sep 7, 2019
c653edf
fix must override a superclass method (#919)
anancds Sep 7, 2019
8c865e6
clean code (#910)
ibrahimAlii Sep 7, 2019
f141033
Fix issue #761: ThreadSafeDoubleCheckLocking.java: Instantiating by R…
Azureyjt Sep 7, 2019
88fae07
Fix broken links #915 (#921)
snehalatapandit Sep 7, 2019
9bf7a05
Java Design Patterns v1.21.0
iluwatar Sep 8, 2019
b874adc
Set version for next development iteration
iluwatar Sep 8, 2019
019abc9
Add license headers
iluwatar Sep 10, 2019
5f39f7f
Updating README.md file to update doc as suggested in issue#925 (#926)
hbothra15 Sep 20, 2019
6b297b7
Data Locality pattern #559 (#889)
ranjeet-floyd Sep 30, 2019
06fa92a
Removing the dead link to resove automagic issue as mentioned in issu…
hbothra15 Sep 30, 2019
3d62e02
fixed bug #929: close async service before the main thread finishes (…
npczwh Sep 30, 2019
b03e0b8
Fix for BallThreadTest#testResume (#935)
anirudh708 Oct 1, 2019
823c58b
added new information (#937)
dignat Oct 2, 2019
05d0f0b
#834 Fix dependency management issue for POM files (#940)
perwramdemark Oct 3, 2019
218ba44
Upgrade of maven plugins (#951)
perwramdemark Oct 5, 2019
364c43a
Get rid of build warnings WARNING about problems found when building …
perwramdemark Oct 5, 2019
933de30
Add JXR plugin to get rid of WARNING Unable to locate Source XRef to …
perwramdemark Oct 5, 2019
60171e3
Fix for Issue #549 : Update Exception Handling Code in Aggregator Mic…
jarpit96 Oct 6, 2019
94ca254
Fix for issue #954 : Add external Dependencies to run with Java11 (#957)
jarpit96 Oct 6, 2019
2b1c09a
Fix link in Acyclic Visitor
iluwatar Oct 7, 2019
f5455f9
update buggy dependencies (#968)
Scuilion Oct 7, 2019
84c4b03
Fix: Github reports security vulnerabilities #933 (#960)
gaurav9822 Oct 8, 2019
f903d7e
#496 Pipeline pattern (#967)
jjjimenez100 Oct 8, 2019
41b8d80
Close #969 (#972)
erikgajdos1997 Oct 8, 2019
90ea450
Leader Election Pattern (#923)
Azureyjt Oct 8, 2019
795b6be
Configure Travis to build on JDK8 and JDK11
iluwatar Oct 11, 2019
71f26c3
Fix Travis xvfb
iluwatar Oct 11, 2019
e36bbbb
Maven profiles to support jdk 11 builds. #948 (#975)
lbroman Oct 11, 2019
6faec99
Bump java language to 11 (#980)
lbroman Oct 12, 2019
fcc1c0a
[mvn] - Remove maven-pmd-plugin from the project (#977) (#979)
Shumyk Oct 12, 2019
9ebbc42
Update license headers
iluwatar Oct 12, 2019
72b1746
#996 Fix SonarCloud analysis failure (#997)
iluwatar Oct 13, 2019
cfdfedb
#970 single logging framework should be enforced (#982)
jjjimenez100 Oct 13, 2019
47d92bb
#996 set sonar host url
iluwatar Oct 14, 2019
088bb76
#996 disable sonar analysis for pull requests (#999)
iluwatar Oct 14, 2019
7e698a9
Fix for issue #413: Circuit Breaker Pattern (#986)
PalAditya Oct 14, 2019
e6c71b6
988: Replaced all of the Apache HttpClients with Java's java.net.http…
oconnelc Oct 15, 2019
dd5997b
993: Fixed the pipeines project layout so that it will load in Eclips…
oconnelc Oct 15, 2019
c438ec0
Intermittent test failure in Spatial Partition pattern #1001 (#1006)
afflato Oct 15, 2019
27c131c
#1001 fix intermittent test failure (#1008)
Smirne Oct 15, 2019
a5646b6
#554: Subclass Sandbox pattern (#998)
Azureyjt Oct 16, 2019
880b234
Fixes #1007 by updating JUnit to 5.5.2 (#1015)
kaiwinter Oct 17, 2019
c308ca0
1011: Fixed all of the SonarCloud blocking errors (#1017)
oconnelc Oct 18, 2019
2982db4
Update README.md
iluwatar Oct 18, 2019
a204383
init repo for role object
Oct 19, 2019
c365610
add to init
Oct 19, 2019
0c60a95
Switched to embedded Google checkstyle rules (#1018)
kaiwinter Oct 19, 2019
8a48447
Remove obsolete file
iluwatar Oct 19, 2019
7c5d5f6
1010: Fixed all of the blocking and critical Sonarcloud errors (#1020)
oconnelc Oct 19, 2019
f09a7eb
add to init
Oct 19, 2019
f671f03
Update FAQ metadata
iluwatar Oct 19, 2019
82f9a6c
1010: Fixed the two remaining SonarCloud errors (#1023)
oconnelc Oct 20, 2019
2217fbc
Issue#550: double buffer pattern (#1024)
Azureyjt Oct 20, 2019
f00ebe1
#984 local variable inference changes (#1025)
Anurag870 Oct 20, 2019
20b4195
add first impl
Oct 20, 2019
5fc03ee
improve grammar of README (#945)
jonlaokan Oct 20, 2019
c81c3ff
Use local variable type inference (#995)
zbeach Oct 21, 2019
4904d7e
#1021: Fix checkstyle warnings by changing the license header templat…
vanogrid Oct 22, 2019
acaa6cd
local variable type inference changes (#1028)
gvsharma Oct 23, 2019
630532c
add pattern
Oct 24, 2019
9403d53
add license
Oct 24, 2019
1b6cecd
Update keywords
iluwatar Oct 24, 2019
1cb1bdc
https://github.com/iluwatar/java-design-patterns/issues/1009 - remove…
akrystian Oct 25, 2019
6aeafcf
https://github.com/iluwatar/java-design-patterns/issues/1016 - decrea…
akrystian Oct 26, 2019
70ddeaa
Create FUNDING.yml
iluwatar Oct 26, 2019
f7a53f2
service-layer local type inference changes (#1034)
gvsharma Oct 26, 2019
58d8fa1
local variable type inference changes (#1035)
gvsharma Oct 26, 2019
0b8d78e
local variable type inference changes (#1036)
gvsharma Oct 26, 2019
12f13a6
local variable infere changes (#1038)
gvsharma Oct 26, 2019
349d8ed
local variable type inference changes (#1039)
gvsharma Oct 26, 2019
af8c5ed
local variable type inference changes (#1040)
gvsharma Oct 26, 2019
03e1e92
local variable type inference changes (#1041)
gvsharma Oct 26, 2019
954e730
local variable type inference changes (#1043)
gvsharma Oct 26, 2019
c7fee7b
local variable type inference changes (#1042)
gvsharma Oct 26, 2019
fadad43
#984 for unitofwork, tolerantreader, twin (#1044)
Anurag870 Oct 26, 2019
e382794
add changes
Oct 26, 2019
d01a3a6
Update Github token
iluwatar Oct 26, 2019
5d47488
Fix error when building from a submodule directory (#1045)
vanogrid Oct 26, 2019
d1767bb
The pattern Role object (#1031)
besok Oct 26, 2019
9f7e3fe
Update license headers
iluwatar Oct 26, 2019
b50189e
Fix Role Object front matter
iluwatar Oct 26, 2019
63fb8dc
Add java 11 (#1048)
leonmak Oct 27, 2019
6bb3438
Add java 11 (#1049)
leonmak Oct 27, 2019
dd971d8
Use java 11 (#1050)
leonmak Oct 28, 2019
c8a481b
Add java 11 support for #987 (o-t) (#1051)
leonmak Oct 29, 2019
a65a601
Update web site logic
iluwatar Oct 29, 2019
ccc1a63
Update script
iluwatar Oct 29, 2019
ff52848
Update script
iluwatar Oct 29, 2019
91a085d
Update script
iluwatar Oct 30, 2019
fca7e9c
https://github.com/iluwatar/java-design-patterns/issues/1021 - decrea…
akrystian Oct 30, 2019
a9dfd7e
Update license header
iluwatar Oct 30, 2019
cdb80b8
Issue 893 (#1014)
hbothra15 Oct 30, 2019
cc85c73
Move faq.md to java-design-patterns-web repository
iluwatar Oct 30, 2019
1eb1961
Remove presentations
iluwatar Oct 30, 2019
3b1a281
decrease number of checkstyle errors in singleton, strategy and visit…
leonorader Oct 31, 2019
55b0341
Fix remaining Checkstyle errors for Singleton
iluwatar Oct 31, 2019
1d4a768
Fix for Issue #549 : Add Fallbacks in Aggregator Service (#971)
jarpit96 Nov 1, 2019
a8c7771
#1021 style changes for Specification
iluwatar Nov 1, 2019
768e647
add saga init dsc
Nov 2, 2019
564cf12
add init saga dsc
Nov 2, 2019
7ac47b2
add changes to dsc
Nov 2, 2019
0b17abd
#590 Add explanation for Specification pattern
iluwatar Nov 2, 2019
c4c37d7
add
Nov 2, 2019
3a4677c
add orchestrator
Nov 2, 2019
1b32e23
add ch
Nov 3, 2019
ffeee2f
separate pkgs
Nov 3, 2019
fbcfeb0
add info
Nov 3, 2019
7dc47da
#1021 Checkstyle fixes for Composite pattern
iluwatar Nov 5, 2019
47ae477
#1021 Checkstyle changes for Factory Method
iluwatar Nov 5, 2019
8ecdee4
#1021 Checkstyle fixes for Layers
iluwatar Nov 5, 2019
50986fa
#590 arrange Layers into packages and add explanation
iluwatar Nov 5, 2019
1fa8a60
Sharding Pattern (#1056)
Azureyjt Nov 8, 2019
09b4663
add choreogr
Nov 9, 2019
8f85353
merge changes
Nov 9, 2019
74c7273
rem space
Nov 9, 2019
6d1c0b1
Resolves checkstyle errors for ambassador, async-method-invocation, b…
anuragagarwal561994 Nov 9, 2019
efc17fc
Resolves checkstyle errors for business-delegate, bytecode, caching (…
anuragagarwal561994 Nov 9, 2019
31f27a7
Resolves checkstyle errors for callback, chain, circuit-breaker (#1060)
anuragagarwal561994 Nov 9, 2019
2f49648
Resolves checkstyle errors for collection-pipeline, command, commande…
anuragagarwal561994 Nov 9, 2019
de56cbb
change according to cgeckstyle
Nov 10, 2019
4f9ee01
Resolves checkstyle errors for converter, cqrs (#1063)
anuragagarwal561994 Nov 10, 2019
dda0953
Resolves checkstyle errors for guarded-suspension, half-sync-half-asy…
anuragagarwal561994 Nov 10, 2019
7f06f3b
Resolves checkstyle errors for intercepting-filter, interpreter, iter…
anuragagarwal561994 Nov 10, 2019
eae09fc
Resolves checkstyle errors for api-gateway, lazy-loading, leader-elec…
anuragagarwal561994 Nov 10, 2019
01e489c
Resolves checkstyle errors for dao data-bus data-locality data-mapper…
anuragagarwal561994 Nov 10, 2019
f2c91eb
Resolves checkstyle errors for delegation dependency-injection dirty-…
anuragagarwal561994 Nov 10, 2019
7c888e8
Resolves checkstyle errors for eip-* (#1069)
anuragagarwal561994 Nov 10, 2019
5ae2ce6
Resolves checkstyle errors for event-* (#1070)
anuragagarwal561994 Nov 10, 2019
4dae1fa
Resolves checkstyle errors for execute-around extension-objects (#1071)
anuragagarwal561994 Nov 10, 2019
9c8ad44
Resolves checkstyle errors for patterns starting with letter r (#1072)
anuragagarwal561994 Nov 10, 2019
b92eb52
Resolves checkstyle errors for template-method thread-pool throttling…
anuragagarwal561994 Nov 10, 2019
f0f0143
Resolves checkstyle errors for trampoline twin typeobjectpattern unit…
anuragagarwal561994 Nov 10, 2019
c441831
Java 11 migration: ambassador async-method-invocation balking bridge …
anuragagarwal561994 Nov 11, 2019
329479d
#984 update Ambassador readme
iluwatar Nov 11, 2019
0272d71
#984 update Bridge readme
iluwatar Nov 11, 2019
2628cc0
#984 update Builder readme
iluwatar Nov 11, 2019
c954a43
Resolves checkstyle errors for facade factory-kit spatial-partition s…
anuragagarwal561994 Nov 11, 2019
37599eb
Resolves checkstyle errors for feature-toggle fluentinterface flux fl…
anuragagarwal561994 Nov 11, 2019
3907951
Resolves checkstyle issues for semaphore servant serverless service-l…
anuragagarwal561994 Nov 11, 2019
1e76d91
Resolves checkstyle errors for abstract-document abstract-factory acy…
anuragagarwal561994 Nov 11, 2019
6ef840f
Resolves checkstyle errors for naked-objects null-object object-mothe…
anuragagarwal561994 Nov 12, 2019
33ea733
Java 11 migration: patterns (remaining b-c) (#1081)
anuragagarwal561994 Nov 12, 2019
3c57bf7
#984 #987 update readmes
iluwatar Nov 12, 2019
f04fc3c
Java 11 migration: patterns starting with a (#1084)
anuragagarwal561994 Nov 13, 2019
160b737
Add another real world example for Builder
iluwatar Nov 13, 2019
87af122
add changes according to google style
Nov 13, 2019
50467c9
Java 11 migration: patterns (t-v) (#1085)
anuragagarwal561994 Nov 14, 2019
51b444d
Merge branch 'master' of https://github.com/besok/java-design-patterns
iluwatar Nov 14, 2019
cc571f4
Saga pattern (#1062)
besok Nov 14, 2019
df8a4e3
Adding parameterized specification (Issue#1055) (#1088)
MaVdbussche Nov 16, 2019
3ccc9ba
Game Loop Pattern (#1083)
Azureyjt Nov 16, 2019
1fdc650
Resolves checkstyle errors for remaining m (#1090)
anuragagarwal561994 Nov 16, 2019
26f4aa8
Merge branch 'master' of https://github.com/iluwatar/java-design-patt…
iluwatar Nov 16, 2019
271d7ae
Resolves checkstyle errors for remaining p (#1091)
anuragagarwal561994 Nov 16, 2019
9e58edf
Merge branch 'master' of https://github.com/iluwatar/java-design-patt…
iluwatar Nov 16, 2019
8747f1f
#1021 enforce Checkstyle rules in the build
iluwatar Nov 16, 2019
cc4b990
#590 Add explanation for Converter pattern
iluwatar Nov 16, 2019
63c707f
Add game-loop to parent pom.xml
iluwatar Nov 16, 2019
19b129c
Fix several frontmatter issues
iluwatar Nov 16, 2019
73f9b8b
Adding composite specification (Issue#1093) (#1094)
MaVdbussche Nov 17, 2019
7d84550
Java Design Patterns 1.22.0
iluwatar Nov 17, 2019
6941e65
Set version for next development iteration
iluwatar Nov 17, 2019
8037495
Add some formatting to Specification pattern readme
iluwatar Nov 17, 2019
7e4d0b4
Changes aggregation to composition (as described in issue #1095) (#1096)
dgruntz Nov 18, 2019
d4b2496
Update App.java (#1098)
dgruntz Nov 18, 2019
515b7e7
Changes the implementation of the prototype pattern (#1103)
dgruntz Nov 19, 2019
e0b728c
Package patterns into executable jars setup (#1092)
hbothra15 Nov 19, 2019
1fbe9bb
Changes the description of the template method pattern (as discussed …
dgruntz Nov 19, 2019
a9c3df7
Changes the description of the prototype pattern (#1102)
dgruntz Nov 19, 2019
05e582c
Pattern combinator (#1105)
besok Nov 26, 2019
55769e9
Update Method pattern (#1106)
Azureyjt Dec 1, 2019
0685a50
#1113 Add uml-reverse-mapper plugin
iluwatar Dec 7, 2019
b09b100
#1113 Link uml-reverse-mapper created class diagrams to readme, where…
iluwatar Dec 7, 2019
fb2c026
Java 11 migrate remaining e (#1112)
anuragagarwal561994 Dec 9, 2019
0335c61
Fix Acyclic Visitor readme layout
iluwatar Dec 13, 2019
b2b1ba9
https://github.com/iluwatar/java-design-patterns-web/issues/8 Update …
iluwatar Dec 13, 2019
5681684
https://github.com/iluwatar/java-design-patterns-web/issues/8 Fix typ…
iluwatar Dec 13, 2019
ea57934
Java 11 migrate c-d (remaining) (#1111)
anuragagarwal561994 Dec 14, 2019
7d0a5c0
Issue 989 batch-2 (#1108)
hbothra15 Dec 18, 2019
f835d3d
Java 11 migrate remaining (g,h,i) (#1116)
anuragagarwal561994 Dec 20, 2019
670c4e4
Java 11 migrate 7 remaining f (#1115)
anuragagarwal561994 Dec 22, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Java 11 migrate remaining (g,h,i) (iluwatar#1116)
* Moves game-loop to Java 11

* Moves guarded-suspension to Java 11

* Moves half-sync-half-async to Java 11

* Moves hexagonal to Java 11

* Moves intercepting-filter to Java 11

* Moves interpreter to Java 11

* Moves iterator to Java 11
  • Loading branch information
anuragagarwal561994 authored and iluwatar committed Dec 20, 2019
commit f835d3d516e833092da091567310933952367de4
4 changes: 2 additions & 2 deletions game-loop/src/main/java/com/iluwatar/gameloop/GameLoop.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void stop() {
* @return {@code true} if the game is running.
*/
public boolean isGameRunning() {
return status == GameStatus.RUNNING ? true : false;
return status == GameStatus.RUNNING;
}

/**
Expand All @@ -80,7 +80,7 @@ public boolean isGameRunning() {
*/
protected void processInput() {
try {
int lag = new Random().nextInt(200) + 50;
var lag = new Random().nextInt(200) + 50;
Thread.sleep(lag);
} catch (InterruptedException e) {
logger.error(e.getMessage());
Expand Down
3 changes: 1 addition & 2 deletions game-loop/src/test/java/com/iluwatar/gameloop/AppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public class AppTest {

@Test
public void testMain() {
String[] args = {};
new App().main(args);
new App().main(new String[]{});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void testStop() {

@Test
public void testIsGameRunning() {
Assert.assertEquals(false, gameLoop.isGameRunning());
Assert.assertFalse(gameLoop.isGameRunning());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

package com.iluwatar.guarded.suspension;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

Expand All @@ -45,14 +44,11 @@ public class App {
* @param args - command line args
*/
public static void main(String[] args) {
GuardedQueue guardedQueue = new GuardedQueue();
ExecutorService executorService = Executors.newFixedThreadPool(3);
var guardedQueue = new GuardedQueue();
var executorService = Executors.newFixedThreadPool(3);

//here we create first thread which is supposed to get from guardedQueue
executorService.execute(() -> {
guardedQueue.get();
}
);
executorService.execute(guardedQueue::get);

// here we wait two seconds to show that the thread which is trying
// to get from guardedQueue will be waiting
Expand All @@ -63,10 +59,7 @@ public static void main(String[] args) {
}
// now we execute second thread which will put number to guardedQueue
// and notify first thread that it could get
executorService.execute(() -> {
guardedQueue.put(20);
}
);
executorService.execute(() -> guardedQueue.put(20));
executorService.shutdown();
try {
executorService.awaitTermination(30, TimeUnit.SECONDS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@

package com.iluwatar.guarded.suspension;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;

/**
* Test for Guarded Queue
Expand All @@ -39,8 +37,8 @@ public class GuardedQueueTest {

@Test
public void testGet() {
GuardedQueue g = new GuardedQueue();
ExecutorService executorService = Executors.newFixedThreadPool(2);
var g = new GuardedQueue();
var executorService = Executors.newFixedThreadPool(2);
executorService.submit(() -> value = g.get());
executorService.submit(() -> g.put(10));
executorService.shutdown();
Expand All @@ -54,7 +52,7 @@ public void testGet() {

@Test
public void testPut() {
GuardedQueue g = new GuardedQueue();
var g = new GuardedQueue();
g.put(12);
assertEquals(Integer.valueOf(12), g.get());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class App {
* @param args command line args
*/
public static void main(String[] args) {
AsynchronousService service = new AsynchronousService(new LinkedBlockingQueue<>());
var service = new AsynchronousService(new LinkedBlockingQueue<>());
/*
* A new task to calculate sum is received but as this is main thread, it should not block. So
* it passes it to the asynchronous task layer to compute and proceeds with handling other
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@

import org.junit.jupiter.api.Test;

import java.util.concurrent.ExecutionException;

/**
*
* Application test
*
*/
public class AppTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ public void setUp() {

@Test
public void testPerfectExecution() throws Exception {
final Object result = new Object();
final var result = new Object();
when(task.call()).thenReturn(result);
service.execute(task);

verify(task, timeout(2000)).onPostCall(eq(result));

final InOrder inOrder = inOrder(task);
final var inOrder = inOrder(task);
inOrder.verify(task, times(1)).onPreCall();
inOrder.verify(task, times(1)).call();
inOrder.verify(task, times(1)).onPostCall(eq(result));
Expand All @@ -73,13 +73,13 @@ public void testPerfectExecution() throws Exception {

@Test
public void testCallException() throws Exception {
final IOException exception = new IOException();
final var exception = new IOException();
when(task.call()).thenThrow(exception);
service.execute(task);

verify(task, timeout(2000)).onError(eq(exception));

final InOrder inOrder = inOrder(task);
final var inOrder = inOrder(task);
inOrder.verify(task, times(1)).onPreCall();
inOrder.verify(task, times(1)).call();
inOrder.verify(task, times(1)).onError(exception);
Expand All @@ -89,13 +89,13 @@ public void testCallException() throws Exception {

@Test
public void testPreCallException() {
final IllegalStateException exception = new IllegalStateException();
final var exception = new IllegalStateException();
doThrow(exception).when(task).onPreCall();
service.execute(task);

verify(task, timeout(2000)).onError(eq(exception));

final InOrder inOrder = inOrder(task);
final var inOrder = inOrder(task);
inOrder.verify(task, times(1)).onPreCall();
inOrder.verify(task, times(1)).onError(exception);

Expand Down
7 changes: 3 additions & 4 deletions hexagonal/src/main/java/com/iluwatar/hexagonal/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
package com.iluwatar.hexagonal;

import com.google.inject.Guice;
import com.google.inject.Injector;
import com.iluwatar.hexagonal.domain.LotteryAdministration;
import com.iluwatar.hexagonal.domain.LotteryService;
import com.iluwatar.hexagonal.module.LotteryTestingModule;
Expand Down Expand Up @@ -63,14 +62,14 @@ public class App {
*/
public static void main(String[] args) {

Injector injector = Guice.createInjector(new LotteryTestingModule());
var injector = Guice.createInjector(new LotteryTestingModule());

// start new lottery round
LotteryAdministration administration = injector.getInstance(LotteryAdministration.class);
var administration = injector.getInstance(LotteryAdministration.class);
administration.resetLottery();

// submit some lottery tickets
LotteryService service = injector.getInstance(LotteryService.class);
var service = injector.getInstance(LotteryService.class);
SampleData.submitTickets(service, 20);

// perform lottery
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
package com.iluwatar.hexagonal.administration;

import com.google.inject.Guice;
import com.google.inject.Injector;
import com.iluwatar.hexagonal.domain.LotteryAdministration;
import com.iluwatar.hexagonal.domain.LotteryService;
import com.iluwatar.hexagonal.module.LotteryModule;
Expand All @@ -46,17 +45,16 @@ public class ConsoleAdministration {
*/
public static void main(String[] args) {
MongoConnectionPropertiesLoader.load();
Injector injector = Guice.createInjector(new LotteryModule());
LotteryAdministration administration = injector.getInstance(LotteryAdministration.class);
LotteryService service = injector.getInstance(LotteryService.class);
var injector = Guice.createInjector(new LotteryModule());
var administration = injector.getInstance(LotteryAdministration.class);
var service = injector.getInstance(LotteryService.class);
SampleData.submitTickets(service, 20);
ConsoleAdministrationSrv consoleAdministration =
new ConsoleAdministrationSrvImpl(administration, LOGGER);
try (Scanner scanner = new Scanner(System.in)) {
boolean exit = false;
var consoleAdministration = new ConsoleAdministrationSrvImpl(administration, LOGGER);
try (var scanner = new Scanner(System.in)) {
var exit = false;
while (!exit) {
printMainMenu();
String cmd = readString(scanner);
var cmd = readString(scanner);
if ("1".equals(cmd)) {
consoleAdministration.getAllSubmittedTickets();
} else if ("2".equals(cmd)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void getAllSubmittedTickets() {

@Override
public void performLottery() {
LotteryNumbers numbers = administration.performLottery();
var numbers = administration.performLottery();
logger.info("The winning numbers: {}", numbers.getNumbersAsString());
logger.info("Time to reset the database for next round, eh?");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.model.UpdateOptions;
import java.util.ArrayList;
import java.util.List;
import org.bson.Document;

/**
Expand Down Expand Up @@ -107,30 +106,31 @@ public MongoCollection<Document> getAccountsCollection() {

@Override
public void setFunds(String bankAccount, int amount) {
Document search = new Document("_id", bankAccount);
Document update = new Document("_id", bankAccount).append("funds", amount);
accountsCollection
.updateOne(search, new Document("$set", update), new UpdateOptions().upsert(true));
var search = new Document("_id", bankAccount);
var update = new Document("_id", bankAccount).append("funds", amount);
var updateOptions = new UpdateOptions().upsert(true);
accountsCollection.updateOne(search, new Document("$set", update), updateOptions);
}

@Override
public int getFunds(String bankAccount) {
Document search = new Document("_id", bankAccount);
List<Document> results = accountsCollection.find(search).limit(1).into(new ArrayList<>());
if (results.size() > 0) {
return results.get(0).getInteger("funds");
} else {
return 0;
}
return accountsCollection
.find(new Document("_id", bankAccount))
.limit(1)
.into(new ArrayList<>())
.stream()
.findFirst()
.map(x -> x.getInteger("funds"))
.orElse(0);
}

@Override
public boolean transferFunds(int amount, String sourceAccount, String destinationAccount) {
int sourceFunds = getFunds(sourceAccount);
var sourceFunds = getFunds(sourceAccount);
if (sourceFunds < amount) {
return false;
} else {
int destFunds = getFunds(destinationAccount);
var destFunds = getFunds(destinationAccount);
setFunds(sourceAccount, sourceFunds - amount);
setFunds(destinationAccount, destFunds + amount);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,12 @@ public class InMemoryTicketRepository implements LotteryTicketRepository {

@Override
public Optional<LotteryTicket> findById(LotteryTicketId id) {
LotteryTicket ticket = tickets.get(id);
if (ticket == null) {
return Optional.empty();
} else {
return Optional.of(ticket);
}
return Optional.ofNullable(tickets.get(id));
}

@Override
public Optional<LotteryTicketId> save(LotteryTicket ticket) {
LotteryTicketId id = new LotteryTicketId();
var id = new LotteryTicketId();
tickets.put(id, ticket);
return Optional.of(id);
}
Expand Down
Loading