Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
140de5b
Spring Data Injection Demo
hmantri05 May 22, 2017
aeb33fe
Adding test cases
hmantri05 May 24, 2017
4771dc4
Follow BDD Naming Convention
hmantri05 May 24, 2017
7f80810
Adding new Project : Spring check if a property is null
hmantri05 Jun 5, 2017
bc5e87c
Adding new project : Spring check if a property is null
hmantri05 Jun 5, 2017
7cf3afb
Renaming the project
hmantri05 Jun 5, 2017
5b9a125
Move null check logic to separate method
hmantri05 Jun 6, 2017
1aaa774
test
buddhini81 Jun 20, 2017
2a65085
BAEL-835 New project folder
buddhini81 Jun 20, 2017
55892db
Delete
buddhini81 Jun 20, 2017
970d955
test file
buddhini81 Jun 20, 2017
08628a0
Create test3.txt
buddhini81 Jun 20, 2017
8a99c5e
Create test33.txt
buddhini81 Jun 20, 2017
36a3d11
BAEL-835 code files
buddhini81 Jun 20, 2017
b4de7a5
Delete test33.txt
buddhini81 Jun 20, 2017
81b6322
Delete test3.txt
buddhini81 Jun 20, 2017
cc5dd5b
Delete test2.txt
buddhini81 Jun 20, 2017
8b85c02
Delete test.txt
buddhini81 Jun 20, 2017
06d375b
BAEL-835 sample code
buddhini81 Jun 20, 2017
e5dc539
Adding collection utils guide
hmantri05 Jun 20, 2017
94d9626
Merge pull request #1 from hmantri05/spring-check-property-is-null-2
hmantri05 Jun 20, 2017
e5f050a
Merge pull request #2 from hmantri05/add-collectionutils-guide
hmantri05 Jun 20, 2017
376a21b
Minor modification BAEL-835
buddhini81 Jun 29, 2017
641671d
Minor change BAEL-835
buddhini81 Jun 29, 2017
cfb7e88
Changing test names and updating maven dependency
hmantri05 Jun 29, 2017
97acf0c
Merge branch 'master' of https://github.com/buddhini81/tutorials into…
slavisa-baeldung Jun 29, 2017
342c356
BAEL-835 - code rerfactor
slavisa-baeldung Jun 30, 2017
2e2bfec
Merge remote-tracking branch 'origin/master' into bael-835-gc-limit-e…
slavisa-baeldung Jun 30, 2017
6f198df
BAEL-965 - CollectionUtil
slavisa-baeldung Jun 30, 2017
03c7ee9
BAEL-965 - CollectionUtil
slavisa-baeldung Jun 30, 2017
37360b9
Spring Security for a Java EE Application (#2185)
Euniceadu Jul 1, 2017
6e99424
BAEL-809: Moved mockito-kotlin to existing mockito module (#2191)
felipe-gdr Jul 2, 2017
ef34fc6
Vavr refactor 02 07 (#2193)
pivovarit Jul 2, 2017
716e7c2
Disable kotlin and spring-5 (#2192)
pivovarit Jul 2, 2017
612b9a1
Updated guest article (#2189)
maibin Jul 2, 2017
ad5696a
Spring Security for a Java EE Application (#2195)
Euniceadu Jul 2, 2017
806c17b
BAEL-878 [2] (#2194)
andrewtobilko Jul 3, 2017
d288004
Spring Web Contexts (BAEL-82) (#2113)
Jul 3, 2017
469495d
BAEL-965 - removing deprecated methods
slavisa-baeldung Jul 3, 2017
0f49c26
Merge branch 'master' into bael-965
slavisa-baeldung Jul 3, 2017
84f0d7d
Merge pull request #2197 from eugenp/bael-965-collection-util
slavisa-baeldung Jul 3, 2017
7c6a087
Merge pull request #2182 from eugenp/bael-835-gc-limit-exceed
slavisa-baeldung Jul 3, 2017
20669dc
semaphores (#2198)
Doha2012 Jul 3, 2017
aecdf6d
Semaphores refactor
pivovarit Jul 3, 2017
bbad26d
including the sso module into the build
Jul 3, 2017
f04ceab
Merge pull request #2199 from eugenp/semaphone_ref
Doha2012 Jul 3, 2017
1a73061
BAEL-922 Type Erasure Explained (#2100)
ocheja Jul 3, 2017
70ae331
BAEL-798 - Apache Camel with Spring Boot (#1761)
dcassiani Jul 3, 2017
db2bb25
BAEL-509 (#2114)
Thoughtscript Jul 4, 2017
7a77016
BAEL-965 - adding changes as per Grzegorz comments
slavisa-baeldung Jul 4, 2017
27b119a
Merge remote-tracking branch 'origin/master' into bael-965-collection…
slavisa-baeldung Jul 4, 2017
172c6c9
Merge pull request #2201 from eugenp/bael-965-collection-util
slavisa-baeldung Jul 4, 2017
a0d82c2
Review Comment Incorporation
Jul 4, 2017
76e2c35
BAEL-902: Migrating from JUnit 4 to JUnit5 (#2202)
Sgitario Jul 4, 2017
5d7e0bc
Review Comment Incorporation
Jul 4, 2017
75c9345
Merge branch 'master' of https://github.com/half-wit4u/tutorials.git
Jul 4, 2017
2f83bec
BAEL-1004 (#2206)
parthkaria Jul 5, 2017
1943994
BAEL-804 - minor code refactors
slavisa-baeldung Jul 5, 2017
8a8e650
Moving Address into Customer
hmantri05 Jul 5, 2017
da56de8
Merge branch 'master' into half-wit4u-master
slavisa-baeldung Jul 5, 2017
5921641
BAEL-804 - fixing wrong pom.xml
slavisa-baeldung Jul 5, 2017
79d9649
Merge pull request #2209 from eugenp/half-wit4u-master
slavisa-baeldung Jul 5, 2017
8746b52
Merge pull request #2208 from hmantri05/master
slavisa-baeldung Jul 5, 2017
c03ca0e
BAEL-951 Self-Healing Services with Spring Cloud - C1
ahamedm Jun 16, 2017
0021df4
BAEL-951 Self-Healing Services with Spring Cloud - C2
ahamedm Jun 20, 2017
fb4ba02
BAEL-951 Self-Healing Services with Spring Cloud - C3
ahamedm Jun 21, 2017
e495a51
BAEL-951 adding @Repository stereotype
slavisa-baeldung Jul 5, 2017
026c971
Merge pull request #2211 from eugenp/bael-951-responsive-services
slavisa-baeldung Jul 5, 2017
178af4e
Money fix (#2210)
pivovarit Jul 5, 2017
8ea3154
Code Snippet for BidiMap BAEL-963 (#2204)
SeunMatt Jul 5, 2017
a57103d
BAEL-509: Uses @GetMapping (#2215)
KevinGilmore Jul 6, 2017
d6d5386
Feature/kotlin list to map (#2216)
Jul 6, 2017
c99bb7f
Minimax refactor (#2212)
pivovarit Jul 6, 2017
b9b230f
Build optimization 6.07 (#2219)
pivovarit Jul 6, 2017
20b9f1b
BAEL-861 Introduction to Awaitlity (#2150)
retroq Jul 7, 2017
896c719
BAEL-965 - removing unncessary modules
slavisa-baeldung Jul 7, 2017
6726159
Merge pull request #2221 from eugenp/cleaning-unnecessary-modules
slavisa-baeldung Jul 7, 2017
f3c99a7
BAEL-974 - Cleverson Santos | cleverson.ssantos1008@gmail.com (#2213)
Jul 7, 2017
5a184d4
BAEL-871 What is serialVersionUID? (#2203)
ashsokkar Jul 7, 2017
2863d0c
Feature/kotlin map examples (#2220)
Jul 7, 2017
7bfceb3
URI, URL BAEL-864. Article renamed and extended URI part. (#2217)
hariprasad108 Jul 7, 2017
9e64135
deleted OpenNLP (#2223)
jboadas Jul 7, 2017
a6ba135
BAEL-579 Spring Cloud Bus (#2218)
iaforek Jul 7, 2017
50054a2
fix configuration (#2225)
Doha2012 Jul 8, 2017
98633dc
Beal 1006 rate limmiter (#2224)
tomekl007 Jul 8, 2017
fdd26c7
Refactor awaitility (#2226)
pivovarit Jul 8, 2017
647455b
BAEL-994 - TemporalAdjuster in Java (#2227)
Jul 8, 2017
94ee35b
BAEL-965 - reverting to anonymous classes
slavisa-baeldung Jul 8, 2017
c598b93
RateLimiter fix (#2229)
pivovarit Jul 8, 2017
edda728
Merge pull request #2230 from eugenp/BAEL-965-removing-lambda
slavisa-baeldung Jul 8, 2017
d191622
Ratelimiter fix (#2231)
pivovarit Jul 8, 2017
57279a1
BAEL-1005 bloom filter code (#2171)
tomekl007 Jul 8, 2017
1957750
How to zip two collections in Java? (#2176)
daveRanjan Jul 8, 2017
9ad123a
Versions update (#2234)
pivovarit Jul 9, 2017
fe2d2a6
Dependency clash resolved (#2235)
pivovarit Jul 9, 2017
62254d9
Serenity build fox (#2236)
pivovarit Jul 9, 2017
f876c6d
vavr's either (#2180)
AbhinabKanrar Jul 9, 2017
13eec7e
BAEL-994 - TemporalAdjuster in Java (#2232)
Jul 9, 2017
e704d29
BAEL-79 Intro to Activiti with Spring (#2127)
mansi2392 Jul 9, 2017
a219184
BAEL-1004 changes in variable names (#2238)
parthkaria Jul 9, 2017
e422eda
Either refactor (#2237)
pivovarit Jul 9, 2017
fc33d62
kotlin collection (#2241)
Doha2012 Jul 9, 2017
2e119a5
BAEL-557 Spring Remoting with RMI (#2240)
danidemi Jul 9, 2017
2f3398b
add more collection examples (#2243)
Doha2012 Jul 10, 2017
2e5cae0
BAEL-964 - map util test
slavisa-baeldung Jul 10, 2017
b844db5
Merge remote-tracking branch 'origin/master' into bael-964-map-util
slavisa-baeldung Jul 10, 2017
c2a0fba
BAEL-964 - fixing version variable in maven
slavisa-baeldung Jul 10, 2017
ecac42f
Merge pull request #2244 from eugenp/bael-964-map-util
slavisa-baeldung Jul 10, 2017
54c6928
Introduction to Vaadin (#2247)
jboadas Jul 10, 2017
1b9353c
Bael 806 lazy (#2248)
tomekl007 Jul 10, 2017
9c643cd
BAEL-970 A Guide to Apache Commons DbUtils (#2125)
juarezjaramillo Jul 11, 2017
2f651dd
BAEL-1005: README (#2246)
KevinGilmore Jul 11, 2017
e6a0bbe
BAEL-1010 HLL article code (#2188)
tomekl007 Jul 11, 2017
dfae145
junit 5 extensions (#2233)
lor6 Jul 11, 2017
5767ff1
BAEL-509 README (#2250)
KevinGilmore Jul 11, 2017
de93039
BAEL-964 - removing assertion from print formatted map
slavisa-baeldung Jul 11, 2017
e5abeb4
Merge pull request #2251 from eugenp/bael-964-map-util
slavisa-baeldung Jul 11, 2017
8495699
Build optimization (#2253)
pivovarit Jul 12, 2017
78de955
BAEL-995: resolved merge issues (#2255)
aliraza995 Jul 13, 2017
24b14e5
BAEL-787 AWS S3 with Java (#2179)
ramansahasi Jul 13, 2017
8ca38e1
Github11.07 (#2254)
cody756 Jul 13, 2017
835d981
Update README.md (#2252)
yetanotherallisonf Jul 13, 2017
7df3f24
Update README.md (#2249)
yetanotherallisonf Jul 13, 2017
3718dfd
Bael 1010 hll (#2256)
tomekl007 Jul 13, 2017
4233d90
Remove vaadin tests (#2257)
pivovarit Jul 13, 2017
26fdeaa
vavr spring data (#2242)
lor6 Jul 14, 2017
1acbe9b
#BAEL-1007 (#2264)
aietcn Jul 15, 2017
3e2d766
Refactor TemporalAdjusters (#2266)
pivovarit Jul 15, 2017
470ac0c
BAEL-861 README update (#2267)
KevinGilmore Jul 15, 2017
8739094
minor upgrade (#2259)
Doha2012 Jul 15, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,11 @@ spring-openid/src/main/resources/application.properties
spring-security-openid/src/main/resources/application.properties

spring-all/*.log

*.jar

SpringDataInjectionDemo/.mvn/wrapper/maven-wrapper.properties

spring-call-getters-using-reflection/.mvn/wrapper/maven-wrapper.properties

spring-check-if-a-property-is-null/.mvn/wrapper/maven-wrapper.properties
2 changes: 2 additions & 0 deletions algorithms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
- [Validating Input With Finite Automata in Java](http://www.baeldung.com/finite-automata-java)
- [Introduction to Jenetics Library](http://www.baeldung.com/jenetics)
- [Check If a Number Is Prime in Java](http://www.baeldung.com/java-prime-numbers)
- [Example of Hill Climbing Algorithm](http://www.baeldung.com/java-hill-climbing-algorithm)
- [Monte Carlo Tree Search for Tic-Tac-Toe Game](http://www.baeldung.com/java-monte-carlo-tree-search)
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,4 @@ public int getHeuristicsValueForStack(Stack<String> stack, List<Stack<String>> c
return stackHeuristics;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ public int getHeuristics() {
public void setHeuristics(int heuristics) {
this.heuristics = heuristics;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.baeldung.algorithms.minimax;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

class GameOfBones {
static List<Integer> getPossibleStates(int noOfBonesInHeap) {
return IntStream.rangeClosed(1, 3).boxed()
.map(i -> noOfBonesInHeap - i)
.filter(newHeapCount -> newHeapCount >= 0)
.collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.baeldung.algorithms.minimax;

import java.util.Comparator;
import java.util.List;
import java.util.NoSuchElementException;

public class MiniMax {
private Tree tree;

public Tree getTree() {
return tree;
}

public void constructTree(int noOfBones) {
tree = new Tree();
Node root = new Node(noOfBones, true);
tree.setRoot(root);
constructTree(root);
}

private void constructTree(Node parentNode) {
List<Integer> listofPossibleHeaps = GameOfBones.getPossibleStates(parentNode.getNoOfBones());
boolean isChildMaxPlayer = !parentNode.isMaxPlayer();
listofPossibleHeaps.forEach(n -> {
Node newNode = new Node(n, isChildMaxPlayer);
parentNode.addChild(newNode);
if (newNode.getNoOfBones() > 0) {
constructTree(newNode);
}
});
}

public boolean checkWin() {
Node root = tree.getRoot();
checkWin(root);
return root.getScore() == 1;
}

private void checkWin(Node node) {
List<Node> children = node.getChildren();
boolean isMaxPlayer = node.isMaxPlayer();
children.forEach(child -> {
if (child.getNoOfBones() == 0) {
child.setScore(isMaxPlayer ? 1 : -1);
} else {
checkWin(child);
}
});
Node bestChild = findBestChild(isMaxPlayer, children);
node.setScore(bestChild.getScore());
}

private Node findBestChild(boolean isMaxPlayer, List<Node> children) {
Comparator<Node> byScoreComparator = Comparator.comparing(Node::getScore);

return children.stream()
.max(isMaxPlayer ? byScoreComparator : byScoreComparator.reversed())
.orElseThrow(NoSuchElementException::new);
}
}
42 changes: 42 additions & 0 deletions algorithms/src/main/java/com/baeldung/algorithms/minimax/Node.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.baeldung.algorithms.minimax;

import java.util.ArrayList;
import java.util.List;

public class Node {
private int noOfBones;
private boolean isMaxPlayer;
private int score;
private List<Node> children;

public Node(int noOfBones, boolean isMaxPlayer) {
this.noOfBones = noOfBones;
this.isMaxPlayer = isMaxPlayer;
children = new ArrayList<>();
}

int getNoOfBones() {
return noOfBones;
}

boolean isMaxPlayer() {
return isMaxPlayer;
}

int getScore() {
return score;
}

void setScore(int score) {
this.score = score;
}

List<Node> getChildren() {
return children;
}

void addChild(Node newNode) {
children.add(newNode);
}

}
16 changes: 16 additions & 0 deletions algorithms/src/main/java/com/baeldung/algorithms/minimax/Tree.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.baeldung.algorithms.minimax;

public class Tree {
private Node root;

Tree() {
}

Node getRoot() {
return root;
}

void setRoot(Node root) {
this.root = root;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ public void givenCurrentState_whenFindNextState_thenBetterHeuristics() {
State nextState = hillClimbing.findNextState(currentState, goalStack);
assertTrue(nextState.getHeuristics() > currentState.getHeuristics());
}
}
}
92 changes: 92 additions & 0 deletions algorithms/src/test/java/algorithms/MCTSTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package algorithms;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.util.List;

import org.junit.Before;
import org.junit.Test;

import com.baeldung.algorithms.mcts.montecarlo.MonteCarloTreeSearch;
import com.baeldung.algorithms.mcts.montecarlo.State;
import com.baeldung.algorithms.mcts.montecarlo.UCT;
import com.baeldung.algorithms.mcts.tictactoe.Board;
import com.baeldung.algorithms.mcts.tictactoe.Position;
import com.baeldung.algorithms.mcts.tree.Tree;

public class MCTSTest {
Tree gameTree;
MonteCarloTreeSearch mcts;

@Before
public void initGameTree() {
gameTree = new Tree();
mcts = new MonteCarloTreeSearch();
}

@Test
public void givenStats_whenGetUCTForNode_thenUCTMatchesWithManualData() {
double uctValue = 15.79;
assertEquals(UCT.uctValue(600, 300, 20), uctValue, 0.01);
}

@Test
public void giveninitBoardState_whenGetAllPossibleStates_thenNonEmptyList() {
State initState = gameTree.getRoot().getState();
List<State> possibleStates = initState.getAllPossibleStates();
assertTrue(possibleStates.size() > 0);
}

@Test
public void givenEmptyBoard_whenPerformMove_thenLessAvailablePossitions() {
Board board = new Board();
int initAvailablePositions = board.getEmptyPositions().size();
board.performMove(Board.P1, new Position(1, 1));
int availablePositions = board.getEmptyPositions().size();
assertTrue(initAvailablePositions > availablePositions);
}

@Test
public void givenEmptyBoard_whenSimulateInterAIPlay_thenGameDraw() {
Board board = new Board();

int player = Board.P1;
int totalMoves = Board.DEFAULT_BOARD_SIZE * Board.DEFAULT_BOARD_SIZE;
for (int i = 0; i < totalMoves; i++) {
board = mcts.findNextMove(board, player);
if (board.checkStatus() != -1) {
break;
}
player = 3 - player;
}
int winStatus = board.checkStatus();
assertEquals(winStatus, Board.DRAW);
}

@Test
public void givenEmptyBoard_whenLevel1VsLevel3_thenLevel3WinsOrDraw() {
Board board = new Board();
MonteCarloTreeSearch mcts1 = new MonteCarloTreeSearch();
mcts1.setLevel(1);
MonteCarloTreeSearch mcts3 = new MonteCarloTreeSearch();
mcts3.setLevel(3);

int player = Board.P1;
int totalMoves = Board.DEFAULT_BOARD_SIZE * Board.DEFAULT_BOARD_SIZE;
for (int i = 0; i < totalMoves; i++) {
if (player == Board.P1)
board = mcts3.findNextMove(board, player);
else
board = mcts1.findNextMove(board, player);

if (board.checkStatus() != -1) {
break;
}
player = 3 - player;
}
int winStatus = board.checkStatus();
assertTrue(winStatus == Board.DRAW || winStatus == Board.P1);
}

}
36 changes: 36 additions & 0 deletions algorithms/src/test/java/algorithms/minimax/MinimaxTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package algorithms.minimax;

import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.*;
import com.baeldung.algorithms.minimax.MiniMax;
import com.baeldung.algorithms.minimax.Tree;

public class MinimaxTest {
private Tree gameTree;
private MiniMax miniMax;

@Before
public void initMiniMaxUtility() {
miniMax = new MiniMax();
}

@Test
public void givenMiniMax_whenConstructTree_thenNotNullTree() {
assertNull(gameTree);
miniMax.constructTree(6);
gameTree = miniMax.getTree();
assertNotNull(gameTree);
}

@Test
public void givenMiniMax_whenCheckWin_thenComputeOptimal() {
miniMax.constructTree(6);
boolean result = miniMax.checkWin();
assertTrue(result);
miniMax.constructTree(8);
result = miniMax.checkWin();
assertFalse(result);
}
}
32 changes: 32 additions & 0 deletions aws/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,41 @@
<aws-lambda-java-events.version>1.3.0</aws-lambda-java-events.version>
<aws-lambda-java-core.version>1.1.0</aws-lambda-java-core.version>
<gson.version>2.8.0</gson.version>
<aws-java-sdk.version>1.11.154</aws-java-sdk.version>
<junit.version>4.12</junit.version>
<mockito-core.version>2.8.9</mockito-core.version>
<assertj-core.version>3.8.0</assertj-core.version>
</properties>

<dependencies>

<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>${aws-java-sdk.version}</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito-core.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj-core.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-core</artifactId>
Expand Down
Loading