Skip to content

Commit

Permalink
Merge branch 'eugenp:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ginjardev committed Feb 11, 2023
2 parents 72f415a + c30aea5 commit d88c8c4
Show file tree
Hide file tree
Showing 470 changed files with 10,953 additions and 2,263 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ Next, they are segregated further on the basis of the tests that we want to exec

Additionally, there are 2 profiles dedicated for JDK9 and above builds.

Therefore, we have a total of 8 profiles:
We also have a parents profile to build only parent modules.

Therefore, we have a total of 9 profiles:

| Profile | Includes | Type of test enabled |
| -------------------------- | --------------------------- | -------------------- |
Expand All @@ -45,6 +47,7 @@ Therefore, we have a total of 8 profiles:
| integration-heavy | Heavy/long running projects | *IntegrationTest |
| default-jdk9-and-above | JDK9 and above projects | *UnitTest |
| integration-jdk9-and-above | JDK9 and above projects | *IntegrationTest |
| parents | Set of parent modules | None |

Building the project
====================
Expand Down Expand Up @@ -72,6 +75,13 @@ Building a single module
To build a specific module, run the command: `mvn clean install` in the module directory.


Building modules from the root of the repository
====================
To build specific modules from the root of the repository, run the command: `mvn clean install --pl asm,atomikos -Pdefault-first` in the root directory.

Here `asm` and `atomikos` are the modules that we want to build and `default-first` is the maven profile in which these modules are present.


Running a Spring Boot module
====================
To run a Spring Boot module, run the command: `mvn spring-boot:run` in the module directory.
Expand Down
1 change: 1 addition & 0 deletions akka-modules/akka-http/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
</dependency>
</dependencies>


<properties>
<akka.http.version>10.0.11</akka.http.version>
<akka.stream.version>2.5.11</akka.stream.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
package com.baeldung.algorithms;

import org.junit.Assert;
import org.junit.Test;

import static org.junit.jupiter.api.Assertions.assertNotNull;

import org.junit.jupiter.api.Test;

import com.baeldung.algorithms.ga.ant_colony.AntColonyOptimization;

public class AntColonyOptimizationLongRunningUnitTest {
class AntColonyOptimizationLongRunningUnitTest {

@Test
public void testGenerateRandomMatrix() {
void testGenerateRandomMatrix() {
AntColonyOptimization antTSP = new AntColonyOptimization(5);
Assert.assertNotNull(antTSP.generateRandomMatrix(5));
assertNotNull(antTSP.generateRandomMatrix(5));
}

@Test
public void testStartAntOptimization() {
void testStartAntOptimization() {
AntColonyOptimization antTSP = new AntColonyOptimization(5);
Assert.assertNotNull(antTSP.solve());
assertNotNull(antTSP.solve());
}

}
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package com.baeldung.algorithms;

import org.junit.Assert;
import org.junit.Test;


import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Test;

import com.baeldung.algorithms.ga.binary.SimpleGeneticAlgorithm;

public class BinaryGeneticAlgorithmLongRunningUnitTest {
class BinaryGeneticAlgorithmLongRunningUnitTest {

@Test
public void testGA() {
void testGA() {
SimpleGeneticAlgorithm ga = new SimpleGeneticAlgorithm();
Assert.assertTrue(ga.runAlgorithm(50, "1011000100000100010000100000100111001000000100000100000000001111"));
assertTrue(ga.runAlgorithm(50, "1011000100000100010000100000100111001000000100000100000000001111"));
}

}
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package com.baeldung.algorithms;

import org.junit.Assert;
import org.junit.Test;

import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Test;

import com.baeldung.algorithms.ga.annealing.SimulatedAnnealing;

public class SimulatedAnnealingLongRunningUnitTest {
class SimulatedAnnealingLongRunningUnitTest {

@Test
public void testSimulateAnnealing() {
Assert.assertTrue(SimulatedAnnealing.simulateAnnealing(10, 1000, 0.9) > 0);
void testSimulateAnnealing() {
assertTrue(SimulatedAnnealing.simulateAnnealing(10, 1000, 0.9) > 0);
}

}
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
package com.baeldung.algorithms;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import com.baeldung.algorithms.hillclimbing.HillClimbing;
import com.baeldung.algorithms.hillclimbing.State;
import org.junit.Before;
import org.junit.Test;

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

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

public class HillClimbingAlgorithmUnitTest {
class HillClimbingAlgorithmUnitTest {
private Stack<String> initStack;
private Stack<String> goalStack;

@Before
@BeforeEach
public void initStacks() {
String blockArr[] = { "B", "C", "D", "A" };
String goalBlockArr[] = { "A", "B", "C", "D" };
Expand All @@ -30,7 +32,7 @@ public void initStacks() {
}

@Test
public void givenInitAndGoalState_whenGetPathWithHillClimbing_thenPathFound() {
void givenInitAndGoalState_whenGetPathWithHillClimbing_thenPathFound() {
HillClimbing hillClimbing = new HillClimbing();

List<State> path;
Expand All @@ -46,7 +48,7 @@ public void givenInitAndGoalState_whenGetPathWithHillClimbing_thenPathFound() {
}

@Test
public void givenCurrentState_whenFindNextState_thenBetterHeuristics() {
void givenCurrentState_whenFindNextState_thenBetterHeuristics() {
HillClimbing hillClimbing = new HillClimbing();
List<Stack<String>> initList = new ArrayList<>();
initList.add(initStack);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package com.baeldung.algorithms;

import com.baeldung.algorithms.automata.*;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Test;

import static org.junit.Assert.assertTrue;
import com.baeldung.algorithms.automata.*;

public final class RtFiniteStateMachineLongRunningUnitTest {
class RtFiniteStateMachineLongRunningUnitTest {

@Test
public void acceptsSimplePair() {
void acceptsSimplePair() {
String json = "{\"key\":\"value\"}";
FiniteStateMachine machine = this.buildJsonStateMachine();
for (int i = 0; i < json.length(); i++) {
Expand All @@ -18,7 +20,7 @@ public void acceptsSimplePair() {
}

@Test
public void acceptsMorePairs() {
void acceptsMorePairs() {
String json = "{\"key1\":\"value1\",\"key2\":\"value2\"}";
FiniteStateMachine machine = this.buildJsonStateMachine();
for (int i = 0; i < json.length(); i++) {
Expand All @@ -27,13 +29,15 @@ public void acceptsMorePairs() {
assertTrue(machine.canStop());
}

@Test(expected = IllegalArgumentException.class)
public void missingColon() {
@Test
void missingColon() {
String json = "{\"key\"\"value\"}";
FiniteStateMachine machine = this.buildJsonStateMachine();
for (int i = 0; i < json.length(); i++) {
machine = machine.switchState(String.valueOf(json.charAt(i)));
}
assertThrows(IllegalArgumentException.class, () -> {
FiniteStateMachine machine = this.buildJsonStateMachine();
for (int i = 0; i < json.length(); i++) {
machine = machine.switchState(String.valueOf(json.charAt(i)));
}
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
package com.baeldung.algorithms.kthlargest;

import static org.assertj.core.api.Assertions.*;
import static org.assertj.core.api.Assertions.assertThat;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class FindKthLargestUnitTest {
class FindKthLargestUnitTest {

private FindKthLargest findKthLargest;
private Integer[] arr = { 3, 7, 1, 2, 8, 10, 4, 5, 6, 9 };

@Before
@BeforeEach
public void setup() {
findKthLargest = new FindKthLargest();
}

@Test
public void givenIntArray_whenFindKthLargestBySorting_thenGetResult() {
void givenIntArray_whenFindKthLargestBySorting_thenGetResult() {
int k = 3;
assertThat(findKthLargest.findKthLargestBySorting(arr, k)).isEqualTo(8);
}

@Test
public void givenIntArray_whenFindKthLargestBySortingDesc_thenGetResult() {
void givenIntArray_whenFindKthLargestBySortingDesc_thenGetResult() {
int k = 3;
assertThat(findKthLargest.findKthLargestBySortingDesc(arr, k)).isEqualTo(8);
}

@Test
public void givenIntArray_whenFindKthLargestByQuickSelect_thenGetResult() {
void givenIntArray_whenFindKthLargestByQuickSelect_thenGetResult() {
int k = 3;
int kthLargest = arr.length - k;
assertThat(findKthLargest.findKthElementByQuickSelect(arr, 0, arr.length - 1, kthLargest)).isEqualTo(8);
}

@Test
public void givenIntArray_whenFindKthElementByQuickSelectIterative_thenGetResult() {
void givenIntArray_whenFindKthElementByQuickSelectIterative_thenGetResult() {
int k = 3;
int kthLargest = arr.length - k;
assertThat(findKthLargest.findKthElementByQuickSelectWithIterativePartition(arr, 0, arr.length - 1, kthLargest)).isEqualTo(8);
}

@Test
public void givenIntArray_whenFindKthSmallestByQuickSelect_thenGetResult() {
void givenIntArray_whenFindKthSmallestByQuickSelect_thenGetResult() {
int k = 3;
assertThat(findKthLargest.findKthElementByQuickSelect(arr, 0, arr.length - 1, k - 1)).isEqualTo(3);
}

@Test
public void givenIntArray_whenFindKthLargestByRandomizedQuickSelect_thenGetResult() {
void givenIntArray_whenFindKthLargestByRandomizedQuickSelect_thenGetResult() {
int k = 3;
int kthLargest = arr.length - k;
assertThat(findKthLargest.findKthElementByRandomizedQuickSelect(arr, 0, arr.length - 1, kthLargest)).isEqualTo(8);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
package com.baeldung.algorithms.minimax;

import org.junit.Before;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import static org.junit.Assert.*;
import com.baeldung.algorithms.minimax.MiniMax;
import com.baeldung.algorithms.minimax.Tree;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

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

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

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

@Test
public void givenMiniMax_whenCheckWin_thenComputeOptimal() {
void givenMiniMax_whenCheckWin_thenComputeOptimal() {
miniMax.constructTree(6);
boolean result = miniMax.checkWin();
assertTrue(result);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.baeldung.algorithms;

import org.junit.Test;


import com.baeldung.algorithms.ga.dijkstra.Dijkstra;
import com.baeldung.algorithms.ga.dijkstra.Graph;
Expand All @@ -11,7 +11,9 @@

import static org.junit.Assert.assertTrue;

public class DijkstraAlgorithmLongRunningUnitTest {
import org.junit.jupiter.api.Test;

class DijkstraAlgorithmLongRunningUnitTest {

@Test
public void whenSPPSolved_thenCorrect() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.baeldung.algorithms.astar.underground;


import static org.assertj.core.api.Assertions.assertThat;

import java.util.HashMap;
Expand All @@ -10,22 +11,22 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import com.baeldung.algorithms.astar.Graph;
import com.baeldung.algorithms.astar.RouteFinder;

import lombok.extern.slf4j.Slf4j;

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

@Slf4j
public class RouteFinderIntegrationTest {
class RouteFinderIntegrationTest {

private Graph<Station> underground;

private RouteFinder<Station> routeFinder;

@Before
@BeforeEach
public void setUp() throws Exception {
Set<Station> stations = new HashSet<>();
Map<String, Set<String>> connections = new HashMap<>();
Expand Down Expand Up @@ -641,7 +642,7 @@ public void setUp() throws Exception {
}

@Test
public void findRoute() {
void findRoute() {
List<Station> route = routeFinder.findRoute(underground.getNode("74"), underground.getNode("7"));
assertThat(route).size().isPositive();

Expand Down
Loading

0 comments on commit d88c8c4

Please sign in to comment.