Skip to content

Commit bcfc0f9

Browse files
committed
Merge branch 'master' into BAEL-8421
2 parents 3c24156 + 510dc41 commit bcfc0f9

File tree

759 files changed

+8074
-2098
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

759 files changed

+8074
-2098
lines changed

algorithms-modules/algorithms-miscellaneous-1/README.md

+6-5

algorithms-modules/algorithms-miscellaneous-1/pom.xml

+11
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@
3535
<artifactId>combinatoricslib3</artifactId>
3636
<version>${combinatoricslib3.version}</version>
3737
</dependency>
38+
<dependency>
39+
<groupId>jakarta.xml.bind</groupId>
40+
<artifactId>jakarta.xml.bind-api</artifactId>
41+
<version>${xml-bind-api.version}</version>
42+
</dependency>
43+
<dependency>
44+
<groupId>com.google.guava</groupId>
45+
<artifactId>guava</artifactId>
46+
<version>${guava.version}</version>
47+
</dependency>
3848
</dependencies>
3949

4050
<reporting>
@@ -59,6 +69,7 @@
5969

6070
<properties>
6171
<combinatoricslib3.version>3.3.0</combinatoricslib3.version>
72+
<xml-bind-api.version>4.0.0</xml-bind-api.version>
6273
</properties>
6374

6475
</project>
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package com.baeldung.algorithms.conversion;
22

3-
import com.google.common.io.BaseEncoding;
4-
import jakarta.xml.bind.DatatypeConverter;
3+
import java.math.BigInteger;
4+
import java.util.HexFormat;
5+
56
import org.apache.commons.codec.DecoderException;
67
import org.apache.commons.codec.binary.Hex;
78

8-
import java.math.BigInteger;
9-
import java.util.HexFormat;
9+
import com.google.common.io.BaseEncoding;
10+
11+
import jakarta.xml.bind.DatatypeConverter;
1012

1113
public class HexStringConverter {
1214

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.baeldung.algorithms.ga.dijkstra;
1+
package com.baeldung.algorithms.dijkstra;
22

33
import java.util.HashSet;
44
import java.util.LinkedList;
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.baeldung.algorithms.ga.dijkstra;
1+
package com.baeldung.algorithms.dijkstra;
22

33
import java.util.HashSet;
44
import java.util.Set;
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.baeldung.algorithms.ga.dijkstra;
1+
package com.baeldung.algorithms.dijkstra;
22

33
import java.util.HashMap;
44
import java.util.LinkedList;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.baeldung.algorithms.enumstatemachine;
2+
3+
public enum LeaveRequestState {
4+
5+
Submitted {
6+
@Override
7+
public LeaveRequestState nextState() {
8+
System.out.println("Starting the Leave Request and sending to Team Leader for approval.");
9+
return Escalated;
10+
}
11+
12+
@Override
13+
public String responsiblePerson() {
14+
return "Employee";
15+
}
16+
},
17+
Escalated {
18+
@Override
19+
public LeaveRequestState nextState() {
20+
System.out.println("Reviewing the Leave Request and escalating to Department Manager.");
21+
return Approved;
22+
}
23+
24+
@Override
25+
public String responsiblePerson() {
26+
return "Team Leader";
27+
}
28+
},
29+
Approved {
30+
@Override
31+
public LeaveRequestState nextState() {
32+
System.out.println("Approving the Leave Request.");
33+
return this;
34+
}
35+
36+
@Override
37+
public String responsiblePerson() {
38+
return "Department Manager";
39+
}
40+
};
41+
42+
public abstract String responsiblePerson();
43+
44+
public abstract LeaveRequestState nextState();
45+
46+
}
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package com.baeldung.algorithms.conversion;
22

3+
import static org.hamcrest.MatcherAssert.assertThat;
4+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
5+
import static org.junit.jupiter.api.Assertions.assertThrows;
6+
37
import org.apache.commons.codec.DecoderException;
48
import org.hamcrest.text.IsEqualIgnoringCase;
59
import org.junit.jupiter.api.BeforeEach;
610
import org.junit.jupiter.api.Test;
711

8-
import static org.hamcrest.MatcherAssert.assertThat;
9-
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
10-
import static org.junit.jupiter.api.Assertions.assertThrows;
11-
1212
class ByteArrayConverterUnitTest {
1313

1414
private HexStringConverter hexStringConverter;
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
package com.baeldung.algorithms;
1+
package com.baeldung.algorithms.dijkstra;
22

3-
import com.baeldung.algorithms.ga.dijkstra.Dijkstra;
4-
import com.baeldung.algorithms.ga.dijkstra.Graph;
5-
import com.baeldung.algorithms.ga.dijkstra.Node;
3+
import static org.junit.Assert.assertTrue;
64

75
import java.util.Arrays;
86
import java.util.List;
97

10-
import static org.junit.Assert.assertTrue;
11-
128
import org.junit.jupiter.api.Test;
139

10+
import com.baeldung.algorithms.dijkstra.Dijkstra;
11+
import com.baeldung.algorithms.dijkstra.Graph;
12+
import com.baeldung.algorithms.dijkstra.Node;
13+
1414
class DijkstraAlgorithmLongRunningUnitTest {
1515

1616
@Test
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.baeldung.algorithms.enumstatemachine;
2+
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
5+
import org.junit.jupiter.api.Test;
6+
7+
class LeaveRequestStateUnitTest {
8+
9+
@Test
10+
void givenLeaveRequest_whenStateEscalated_thenResponsibleIsTeamLeader() {
11+
LeaveRequestState state = LeaveRequestState.Escalated;
12+
13+
assertEquals( "Team Leader", state.responsiblePerson());
14+
}
15+
16+
17+
@Test
18+
void givenLeaveRequest_whenStateApproved_thenResponsibleIsDepartmentManager() {
19+
LeaveRequestState state = LeaveRequestState.Approved;
20+
21+
assertEquals( "Department Manager" , state.responsiblePerson());
22+
}
23+
24+
@Test
25+
void givenLeaveRequest_whenNextStateIsCalled_thenStateIsChanged() {
26+
LeaveRequestState state = LeaveRequestState.Submitted;
27+
28+
state = state.nextState();
29+
assertEquals(LeaveRequestState.Escalated, state);
30+
31+
state = state.nextState();
32+
assertEquals(LeaveRequestState.Approved, state);
33+
34+
state = state.nextState();
35+
assertEquals(LeaveRequestState.Approved, state);
36+
}
37+
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.baeldung.algorithms.latlondistance;
22

3-
import org.junit.jupiter.api.Test;
4-
53
import static org.junit.jupiter.api.Assertions.assertTrue;
64

5+
import org.junit.jupiter.api.Test;
6+
77
class GeoDistanceUnitTest {
88
@Test
99
public void testCalculateDistance() {
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.baeldung.algorithms.maximumsubarray;
22

3-
import org.junit.jupiter.api.Test;
4-
53
import static org.junit.jupiter.api.Assertions.assertEquals;
64

5+
import org.junit.jupiter.api.Test;
6+
77
class BruteForceAlgorithmUnitTest {
88

99
@Test
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.baeldung.algorithms.maximumsubarray;
22

3-
import org.junit.jupiter.api.Test;
4-
53
import static org.junit.jupiter.api.Assertions.assertEquals;
64

5+
import org.junit.jupiter.api.Test;
6+
77
class KadaneAlgorithmUnitTest {
88

99
@Test

algorithms-modules/algorithms-miscellaneous-2/README.md

-1

algorithms-modules/algorithms-miscellaneous-3/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
package com.baeldung.algorithms;
1+
package com.baeldung.algorithms.automata;
22

33
import static org.junit.jupiter.api.Assertions.assertThrows;
44
import static org.junit.jupiter.api.Assertions.assertTrue;
55

66
import org.junit.jupiter.api.Test;
77

8-
import com.baeldung.algorithms.automata.*;
9-
108
class RtFiniteStateMachineLongRunningUnitTest {
119

1210
@Test

algorithms-modules/algorithms-miscellaneous-4/README.md

+1-1
+3-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
package com.baeldung.algorithms;
1+
package com.baeldung.algorithms.hillclimbing;
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
44
import static org.junit.jupiter.api.Assertions.assertNotNull;
55
import static org.junit.jupiter.api.Assertions.assertTrue;
66

7-
import org.junit.jupiter.api.BeforeEach;
8-
import org.junit.jupiter.api.Test;
9-
10-
import com.baeldung.algorithms.hillclimbing.HillClimbing;
11-
import com.baeldung.algorithms.hillclimbing.State;
12-
137
import java.util.ArrayList;
148
import java.util.List;
159
import java.util.Stack;
1610

11+
import org.junit.jupiter.api.BeforeEach;
12+
import org.junit.jupiter.api.Test;
1713

1814
class HillClimbingAlgorithmUnitTest {
1915
private Stack<String> initStack;

algorithms-modules/algorithms-miscellaneous-4/src/test/java/com/baeldung/algorithms/MiddleElementLookupUnitTest.java renamed to algorithms-modules/algorithms-miscellaneous-4/src/test/java/com/baeldung/algorithms/middleelementlookup/MiddleElementLookupUnitTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.baeldung.algorithms;
1+
package com.baeldung.algorithms.middleelementlookup;
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
44
import static org.junit.jupiter.api.Assertions.assertFalse;

algorithms-modules/algorithms-miscellaneous-5/README.md

-2

algorithms-modules/algorithms-miscellaneous-5/pom.xml

-7
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@
3131
<version>${tradukisto.version}</version>
3232
</dependency>
3333

34-
<!-- API, java.xml.bind module -->
35-
<dependency>
36-
<groupId>jakarta.xml.bind</groupId>
37-
<artifactId>jakarta.xml.bind-api</artifactId>
38-
<version>${xml-bind-api.version}</version>
39-
</dependency>
4034
<!-- Runtime, com.sun.xml.bind module -->
4135
<dependency>
4236
<groupId>org.glassfish.jaxb</groupId>
@@ -59,7 +53,6 @@
5953
</build>
6054

6155
<properties>
62-
<xml-bind-api.version>4.0.0</xml-bind-api.version>
6356
<jaxb-runtime.version>4.0.0</jaxb-runtime.version>
6457
</properties>
6558

algorithms-modules/algorithms-miscellaneous-7/README.md

-1

algorithms-modules/algorithms-miscellaneous-9/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.baledung.algorithms.countoccurence;
1+
package com.baeldung.algorithms.countoccurence;
22

33
import java.util.Arrays;
44
import java.util.HashMap;
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.baledung.algorithms.successivepairs;
1+
package com.baeldung.algorithms.successivepairs;
22

33
import java.util.AbstractMap.SimpleEntry;
44
import java.util.ArrayList;

algorithms-modules/algorithms-miscellaneous-9/src/test/java/com/baeldung/algorithms/countoccurence/CountOccurrenceUnitTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.baeldung.algorithms.countoccurence;
22

3-
import static com.baledung.algorithms.countoccurence.CountOccurrence.countOccurrencesWithCounter;
4-
import static com.baledung.algorithms.countoccurence.CountOccurrence.countOccurrencesWithMap;
5-
import static com.baledung.algorithms.countoccurence.CountOccurrence.countOccurrencesWithStream;
3+
import static com.baeldung.algorithms.countoccurence.CountOccurrence.countOccurrencesWithCounter;
4+
import static com.baeldung.algorithms.countoccurence.CountOccurrence.countOccurrencesWithMap;
5+
import static com.baeldung.algorithms.countoccurence.CountOccurrence.countOccurrencesWithStream;
66
import static org.junit.jupiter.api.Assertions.assertEquals;
77

88
import java.util.Map;

0 commit comments

Comments
 (0)