Skip to content

Commit e485b0d

Browse files
authored
Merge branch 'master' into BAEL-2928
2 parents c1920dd + f767e46 commit e485b0d

File tree

1,273 files changed

+16812
-4656
lines changed

Some content is hidden

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

1,273 files changed

+16812
-4656
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*/bin/*
2+
bin/
23

34
*.class
45

@@ -21,6 +22,9 @@
2122
*.iws
2223
out/
2324

25+
# VSCode
26+
.vscode/
27+
2428
# Mac
2529
.DS_Store
2630

README.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11

2-
The "REST with Spring" Classes
2+
The Courses
33
==============================
44

5-
Here's the Master Class of REST With Spring (along with the newly announced Boot 2 material): <br/>
6-
**[>> THE REST WITH SPRING - MASTER CLASS](http://www.baeldung.com/rest-with-spring-course?utm_source=github&utm_medium=social&utm_content=tutorials&utm_campaign=rws#master-class)**
75

8-
And here's the Master Class of Learn Spring Security: <br/>
9-
**[>> LEARN SPRING SECURITY - MASTER CLASS](http://www.baeldung.com/learn-spring-security-course?utm_source=github&utm_medium=social&utm_content=tutorials&utm_campaign=lss#master-class)**
6+
Here's the new "Learn Spring" course: <br/>
7+
**[>> LEARN SPRING - THE MASTER CLASS](https://www.baeldung.com/learn-spring-course?utm_source=github&utm_medium=social&utm_content=tutorials&utm_campaign=ls#master-class)**
8+
9+
Here's the Master Class of "REST With Spring" (along with the new announced Boot 2 material): <br/>
10+
**[>> THE REST WITH SPRING - MASTER CLASS](https://www.baeldung.com/rest-with-spring-course?utm_source=github&utm_medium=social&utm_content=tutorials&utm_campaign=rws#master-class)**
11+
12+
And here's the Master Class of "Learn Spring Security": <br/>
13+
**[>> LEARN SPRING SECURITY - MASTER CLASS](https://www.baeldung.com/learn-spring-security-course?utm_source=github&utm_medium=social&utm_content=tutorials&utm_campaign=lss#master-class)**
1014

1115

1216

@@ -15,7 +19,7 @@ Java and Spring Tutorials
1519

1620
This project is **a collection of small and focused tutorials** - each covering a single and well defined area of development in the Java ecosystem.
1721
A strong focus of these is, of course, the Spring Framework - Spring, Spring Boot and Spring Security.
18-
In additional to Spring, the following technologies are in focus: `core Java`, `Jackson`, `HttpClient`, `Guava`.
22+
In additional to Spring, the modules here are covering a number of aspects in Java.
1923

2024

2125
Building the project
@@ -32,8 +36,15 @@ Running a Spring Boot module
3236
====================
3337
To run a Spring Boot module run the command: `mvn spring-boot:run` in the module directory
3438

35-
#Running Tests
3639

40+
Working with the IDE
41+
====================
42+
This repo contains a large number of modules.
43+
When you're working with an individual module, there's no need to import all of them (or build all of them) - you can simply import that particular module in either Eclipse or IntelliJ.
44+
45+
46+
Running Tests
47+
=============
3748
The command `mvn clean install` will run the unit tests in a module.
3849
To run the integration tests, use the command `mvn clean install -Pintegration-lite-first`
3950

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
## Relevant articles:
1+
## Relevant Articles:
22

33
- [Java Two Pointer Technique](https://www.baeldung.com/java-two-pointer-technique)
44
- [Implementing Simple State Machines with Java Enums](https://www.baeldung.com/java-enum-simple-state-machine)
55
- [Converting Between Roman and Arabic Numerals in Java](http://www.baeldung.com/java-convert-roman-arabic)
66
- [Practical Java Examples of the Big O Notation](http://www.baeldung.com/java-algorithm-complexity)
77
- [Checking If a List Is Sorted in Java](https://www.baeldung.com/java-check-if-list-sorted)
88
- [Checking if a Java Graph has a Cycle](https://www.baeldung.com/java-graph-has-a-cycle)
9-
- [A Guide to the Folding Technique](https://www.baeldung.com/folding-hashing-technique)
9+
- [A Guide to the Folding Technique in Java](https://www.baeldung.com/folding-hashing-technique)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.baeldung.algorithms.stringsortingbynumber;
2+
3+
import java.util.Comparator;
4+
5+
public final class NaturalOrderComparators {
6+
7+
private static final String DIGIT_AND_DECIMAL_REGEX = "[^\\d.]";
8+
9+
private NaturalOrderComparators() {
10+
throw new AssertionError("Let's keep this static");
11+
}
12+
13+
public static Comparator<String> createNaturalOrderRegexComparator() {
14+
return Comparator.comparingDouble(NaturalOrderComparators::parseStringToNumber);
15+
}
16+
17+
private static double parseStringToNumber(String input){
18+
19+
final String digitsOnly = input.replaceAll(DIGIT_AND_DECIMAL_REGEX, "");
20+
21+
if("".equals(digitsOnly)) return 0;
22+
23+
try{
24+
return Double.parseDouble(digitsOnly);
25+
}catch (NumberFormatException nfe){
26+
return 0;
27+
}
28+
}
29+
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package com.baeldung.algorithms.stringsortingbynumber;
2+
3+
import com.baeldung.algorithms.stringsortingbynumber.NaturalOrderComparators;
4+
import org.junit.Test;
5+
6+
import java.util.ArrayList;
7+
import java.util.Arrays;
8+
import java.util.List;
9+
10+
import static org.junit.Assert.*;
11+
12+
public class NaturalOrderComparatorsUnitTest {
13+
14+
@Test
15+
public void givenSimpleStringsContainingIntsAndDoubles_whenSortedByRegex_checkSortingCorrect() {
16+
17+
List<String> testStrings = Arrays.asList("a1", "b3", "c4", "d2.2", "d2.4", "d2.3d");
18+
19+
testStrings.sort(NaturalOrderComparators.createNaturalOrderRegexComparator());
20+
21+
List<String> expected = Arrays.asList("a1", "d2.2", "d2.3d", "d2.4", "b3", "c4");
22+
23+
assertEquals(expected, testStrings);
24+
25+
26+
}
27+
28+
@Test
29+
public void givenSimpleStringsContainingIntsAndDoublesWithAnInvalidNumber_whenSortedByRegex_checkSortingCorrect() {
30+
31+
List<String> testStrings = Arrays.asList("a1", "b3", "c4", "d2.2", "d2.4", "d2.3.3d");
32+
33+
testStrings.sort(NaturalOrderComparators.createNaturalOrderRegexComparator());
34+
35+
List<String> expected = Arrays.asList("d2.3.3d", "a1", "d2.2", "d2.4", "b3", "c4");
36+
37+
assertEquals(expected, testStrings);
38+
39+
40+
}
41+
42+
@Test
43+
public void givenAllForseenProblems_whenSortedByRegex_checkSortingCorrect() {
44+
45+
List<String> testStrings = Arrays.asList("a1", "b3", "c4", "d2.2", "d2.f4", "d2.3.3d");
46+
47+
testStrings.sort(NaturalOrderComparators.createNaturalOrderRegexComparator());
48+
49+
List<String> expected = Arrays.asList("d2.3.3d", "a1", "d2.2", "d2.f4", "b3", "c4");
50+
51+
assertEquals(expected, testStrings);
52+
53+
54+
}
55+
56+
@Test
57+
public void givenComplexStringsContainingSeparatedNumbers_whenSortedByRegex_checkNumbersCondensedAndSorted() {
58+
59+
List<String> testStrings = Arrays.asList("a1b2c5", "b3ght3.2", "something65.thensomething5"); //125, 33.2, 65.5
60+
61+
List<String> expected = Arrays.asList("b3ght3.2", "something65.thensomething5", "a1b2c5" );
62+
63+
testStrings.sort(NaturalOrderComparators.createNaturalOrderRegexComparator());
64+
65+
assertEquals(expected, testStrings);
66+
67+
}
68+
69+
@Test
70+
public void givenStringsNotContainingNumbers_whenSortedByRegex_checkOrderNotChanged() {
71+
72+
List<String> testStrings = Arrays.asList("a", "c", "d", "e");
73+
List<String> expected = new ArrayList<>(testStrings);
74+
75+
testStrings.sort(NaturalOrderComparators.createNaturalOrderRegexComparator());
76+
77+
assertEquals(expected, testStrings);
78+
}
79+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.baeldung.algorithms.shellsort;
2+
3+
public class ShellSort {
4+
5+
public static void sort(int arrayToSort[]) {
6+
int n = arrayToSort.length;
7+
8+
for (int gap = n / 2; gap > 0; gap /= 2) {
9+
for (int i = gap; i < n; i++) {
10+
int key = arrayToSort[i];
11+
int j = i;
12+
while (j >= gap && arrayToSort[j - gap] > key) {
13+
arrayToSort[j] = arrayToSort[j - gap];
14+
j -= gap;
15+
}
16+
arrayToSort[j] = key;
17+
}
18+
}
19+
}
20+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.baeldung.algorithms.shellsort;
2+
3+
import static org.junit.Assert.*;
4+
import static org.junit.Assert.assertArrayEquals;
5+
6+
import org.junit.Test;
7+
8+
public class ShellSortUnitTest {
9+
10+
@Test
11+
public void givenUnsortedArray_whenShellSort_thenSortedAsc() {
12+
int[] input = {41, 15, 82, 5, 65, 19, 32, 43, 8};
13+
ShellSort.sort(input);
14+
int[] expected = {5, 8, 15, 19, 32, 41, 43, 65, 82};
15+
assertArrayEquals("the two arrays are not equal", expected, input);
16+
}
17+
}

apache-olingo/olingo2/pom.xml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
<name>olingo2-sample</name>
1010
<description>Sample Olingo 2 Project</description>
1111

12-
<parent>
13-
<groupId>org.springframework.boot</groupId>
14-
<artifactId>spring-boot-starter-parent</artifactId>
15-
<version>2.1.3.RELEASE</version>
16-
<relativePath /> <!-- lookup parent from repository -->
17-
</parent>
12+
<parent>
13+
<artifactId>parent-boot-2</artifactId>
14+
<groupId>com.baeldung</groupId>
15+
<version>0.0.1-SNAPSHOT</version>
16+
<relativePath>../../parent-boot-2</relativePath>
17+
</parent>
1818

1919
<dependencies>
2020
<dependency>
@@ -82,7 +82,6 @@
8282
</build>
8383

8484
<properties>
85-
<java.version>1.8</java.version>
8685
<olingo2.version>2.0.11</olingo2.version>
8786
</properties>
8887

apache-olingo/olingo2/src/test/java/org/baeldung/examples/olingo2/Olingo2SampleApplicationTests.java renamed to apache-olingo/olingo2/src/test/java/org/baeldung/examples/olingo2/Olingo2SampleApplicationUnitTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
@RunWith(SpringRunner.class)
99
@SpringBootTest
10-
public class Olingo2SampleApplicationTests {
10+
public class Olingo2SampleApplicationUnitTest {
1111

1212
@Test
1313
public void contextLoads() {

apache-pulsar/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
<version>0.0.1</version>
88
<name>apache-pulsar</name>
99

10+
<parent>
11+
<groupId>com.baeldung</groupId>
12+
<artifactId>parent-modules</artifactId>
13+
<version>1.0.0-SNAPSHOT</version>
14+
<relativePath>..</relativePath>
15+
</parent>
16+
1017
<dependencies>
1118
<dependency>
1219
<groupId>org.apache.pulsar</groupId>

0 commit comments

Comments
 (0)