Skip to content

Commit 6c2ed87

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 5bd907a + e44c72f commit 6c2ed87

248 files changed

Lines changed: 34042 additions & 2650 deletions

File tree

Some content is hidden

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

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ target/
2727

2828
spring-openid/src/main/resources/application.properties
2929
.recommenders/
30+
/spring-hibernate4/nbproject/

‎algorithms/src/main/java/com/baeldung/algorithms/dijkstra/Dijkstra.java‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ public static Graph calculateShortestPathFromSource(Graph graph, Node source) {
1818
while (unsettledNodes.size() != 0) {
1919
Node currentNode = getLowestDistanceNode(unsettledNodes);
2020
unsettledNodes.remove(currentNode);
21-
for (Entry<Node, Integer> adjacencyPair : currentNode
22-
.getAdjacentNodes()
23-
.entrySet()) {
21+
for (Entry<Node, Integer> adjacencyPair : currentNode.getAdjacentNodes().entrySet()) {
2422
Node adjacentNode = adjacencyPair.getKey();
2523
Integer edgeWeigh = adjacencyPair.getValue();
2624

‎algorithms/src/test/java/algorithms/DijkstraAlgorithmTest.java‎

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,29 +55,19 @@ public void whenSPPSolved_thenCorrect() {
5555
for (Node node : graph.getNodes()) {
5656
switch (node.getName()) {
5757
case "B":
58-
assertTrue(node
59-
.getShortestPath()
60-
.equals(shortestPathForNodeB));
58+
assertTrue(node.getShortestPath().equals(shortestPathForNodeB));
6159
break;
6260
case "C":
63-
assertTrue(node
64-
.getShortestPath()
65-
.equals(shortestPathForNodeC));
61+
assertTrue(node.getShortestPath().equals(shortestPathForNodeC));
6662
break;
6763
case "D":
68-
assertTrue(node
69-
.getShortestPath()
70-
.equals(shortestPathForNodeD));
64+
assertTrue(node.getShortestPath().equals(shortestPathForNodeD));
7165
break;
7266
case "E":
73-
assertTrue(node
74-
.getShortestPath()
75-
.equals(shortestPathForNodeE));
67+
assertTrue(node.getShortestPath().equals(shortestPathForNodeE));
7668
break;
7769
case "F":
78-
assertTrue(node
79-
.getShortestPath()
80-
.equals(shortestPathForNodeF));
70+
assertTrue(node.getShortestPath().equals(shortestPathForNodeF));
8171
break;
8272
}
8373
}

‎annotations/annotation-processing/src/main/java/com/baeldung/annotation/processor/BuilderProcessor.java‎

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,20 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
2727

2828
Set<? extends Element> annotatedElements = roundEnv.getElementsAnnotatedWith(annotation);
2929

30-
Map<Boolean, List<Element>> annotatedMethods = annotatedElements.stream()
31-
.collect(Collectors.partitioningBy(element ->
32-
((ExecutableType) element.asType()).getParameterTypes().size() == 1
33-
&& element.getSimpleName().toString().startsWith("set")));
30+
Map<Boolean, List<Element>> annotatedMethods = annotatedElements.stream().collect(Collectors.partitioningBy(element -> ((ExecutableType) element.asType()).getParameterTypes().size() == 1 && element.getSimpleName().toString().startsWith("set")));
3431

3532
List<Element> setters = annotatedMethods.get(true);
3633
List<Element> otherMethods = annotatedMethods.get(false);
3734

38-
otherMethods.forEach(element ->
39-
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR,
40-
"@BuilderProperty must be applied to a setXxx method with a single argument", element));
35+
otherMethods.forEach(element -> processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "@BuilderProperty must be applied to a setXxx method with a single argument", element));
4136

4237
if (setters.isEmpty()) {
4338
continue;
4439
}
4540

4641
String className = ((TypeElement) setters.get(0).getEnclosingElement()).getQualifiedName().toString();
4742

48-
Map<String, String> setterMap = setters.stream().collect(Collectors.toMap(
49-
setter -> setter.getSimpleName().toString(),
50-
setter -> ((ExecutableType) setter.asType())
51-
.getParameterTypes().get(0).toString()
52-
));
43+
Map<String, String> setterMap = setters.stream().collect(Collectors.toMap(setter -> setter.getSimpleName().toString(), setter -> ((ExecutableType) setter.asType()).getParameterTypes().get(0).toString()));
5344

5445
try {
5546
writeBuilderFile(className, setterMap);

‎annotations/annotation-user/src/test/java/com/baeldung/annotation/PersonBuilderTest.java‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ public class PersonBuilderTest {
99
@Test
1010
public void whenBuildPersonWithBuilder_thenObjectHasPropertyValues() {
1111

12-
Person person = new PersonBuilder()
13-
.setAge(25)
14-
.setName("John")
15-
.build();
12+
Person person = new PersonBuilder().setAge(25).setName("John").build();
1613

1714
assertEquals(25, person.getAge());
1815
assertEquals("John", person.getName());

‎apache-cxf/cxf-introduction/src/main/java/com/baeldung/cxf/introduction/Server.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public static void main(String args[]) throws InterruptedException {
88
String address = "http://localhost:8080/baeldung";
99
Endpoint.publish(address, implementor);
1010
System.out.println("Server ready...");
11-
Thread.sleep(60 * 1000);
11+
Thread.sleep(60 * 1000);
1212
System.out.println("Server exiting");
1313
System.exit(0);
1414
}

‎apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/RestfulServer.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public static void main(String args[]) throws Exception {
1111
factoryBean.setResourceProvider(new SingletonResourceProvider(new CourseRepository()));
1212
factoryBean.setAddress("http://localhost:8080/");
1313
Server server = factoryBean.create();
14-
14+
1515
System.out.println("Server ready...");
1616
Thread.sleep(60 * 1000);
1717
System.out.println("Server exiting");

‎assertj/src/test/java/com/baeldung/assertj/introduction/AssertJCoreTest.java‎

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ public void whenComparingFields_thenEqual() throws Exception {
3838
public void whenCheckingForElement_thenContains() throws Exception {
3939
List<String> list = Arrays.asList("1", "2", "3");
4040

41-
assertThat(list)
42-
.contains("1");
41+
assertThat(list).contains("1");
4342
}
4443

4544
@Test
@@ -50,12 +49,7 @@ public void whenCheckingForElement_thenMultipleAssertions() throws Exception {
5049
assertThat(list).startsWith("1");
5150
assertThat(list).doesNotContainNull();
5251

53-
assertThat(list)
54-
.isNotEmpty()
55-
.contains("1")
56-
.startsWith("1")
57-
.doesNotContainNull()
58-
.containsSequence("2", "3");
52+
assertThat(list).isNotEmpty().contains("1").startsWith("1").doesNotContainNull().containsSequence("2", "3");
5953
}
6054

6155
@Test
@@ -67,11 +61,7 @@ public void whenCheckingRunnable_thenIsInterface() throws Exception {
6761
public void whenCheckingCharacter_thenIsUnicode() throws Exception {
6862
char someCharacter = 'c';
6963

70-
assertThat(someCharacter)
71-
.isNotEqualTo('a')
72-
.inUnicode()
73-
.isGreaterThanOrEqualTo('b')
74-
.isLowerCase();
64+
assertThat(someCharacter).isNotEqualTo('a').inUnicode().isGreaterThanOrEqualTo('b').isLowerCase();
7565
}
7666

7767
@Test
@@ -94,11 +84,7 @@ public void whenCheckingFile_then() throws Exception {
9484
final File someFile = File.createTempFile("aaa", "bbb");
9585
someFile.deleteOnExit();
9686

97-
assertThat(someFile)
98-
.exists()
99-
.isFile()
100-
.canRead()
101-
.canWrite();
87+
assertThat(someFile).exists().isFile().canRead().canWrite();
10288
}
10389

10490
@Test
@@ -113,29 +99,21 @@ public void whenCheckingIS_then() throws Exception {
11399
public void whenGivenMap_then() throws Exception {
114100
Map<Integer, String> map = Maps.newHashMap(2, "a");
115101

116-
assertThat(map)
117-
.isNotEmpty()
118-
.containsKey(2)
119-
.doesNotContainKeys(10)
120-
.contains(entry(2, "a"));
102+
assertThat(map).isNotEmpty().containsKey(2).doesNotContainKeys(10).contains(entry(2, "a"));
121103
}
122104

123105
@Test
124106
public void whenGivenException_then() throws Exception {
125107
Exception ex = new Exception("abc");
126108

127-
assertThat(ex)
128-
.hasNoCause()
129-
.hasMessageEndingWith("c");
109+
assertThat(ex).hasNoCause().hasMessageEndingWith("c");
130110
}
131111

132112
@Ignore // IN ORDER TO TEST, REMOVE THIS LINE
133113
@Test
134114
public void whenRunningAssertion_thenDescribed() throws Exception {
135115
Person person = new Person("Alex", 34);
136116

137-
assertThat(person.getAge())
138-
.as("%s's age should be equal to 100")
139-
.isEqualTo(100);
117+
assertThat(person.getAge()).as("%s's age should be equal to 100").isEqualTo(100);
140118
}
141119
}

‎assertj/src/test/java/com/baeldung/assertj/introduction/AssertJGuavaTest.java‎

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ public void givenTwoEmptyFiles_whenComparingContent_thenEqual() throws Exception
2626
final File temp1 = File.createTempFile("bael", "dung1");
2727
final File temp2 = File.createTempFile("bael", "dung2");
2828

29-
assertThat(Files.asByteSource(temp1))
30-
.hasSize(0)
31-
.hasSameContentAs(Files.asByteSource(temp2));
29+
assertThat(Files.asByteSource(temp1)).hasSize(0).hasSameContentAs(Files.asByteSource(temp2));
3230
}
3331

3432
@Test
@@ -37,11 +35,7 @@ public void givenMultimap_whenVerifying_thenCorrect() throws Exception {
3735
mmap.put(1, "one");
3836
mmap.put(1, "1");
3937

40-
assertThat(mmap)
41-
.hasSize(2)
42-
.containsKeys(1)
43-
.contains(entry(1, "one"))
44-
.contains(entry(1, "1"));
38+
assertThat(mmap).hasSize(2).containsKeys(1).contains(entry(1, "one")).contains(entry(1, "1"));
4539
}
4640

4741
@Test
@@ -62,31 +56,21 @@ public void givenMultimaps_whenVerifyingContent_thenCorrect() throws Exception {
6256
mmap2.put(1, "one");
6357
mmap2.put(1, "1");
6458

65-
assertThat(mmap1)
66-
.containsAllEntriesOf(mmap2)
67-
.containsAllEntriesOf(mmap1_clone)
68-
.hasSameEntriesAs(mmap1_clone);
59+
assertThat(mmap1).containsAllEntriesOf(mmap2).containsAllEntriesOf(mmap1_clone).hasSameEntriesAs(mmap1_clone);
6960
}
7061

7162
@Test
7263
public void givenOptional_whenVerifyingContent_thenShouldBeEqual() throws Exception {
7364
final Optional<String> something = Optional.of("something");
7465

75-
assertThat(something)
76-
.isPresent()
77-
.extractingValue()
78-
.isEqualTo("something");
66+
assertThat(something).isPresent().extractingValue().isEqualTo("something");
7967
}
8068

8169
@Test
8270
public void givenRange_whenVerifying_thenShouldBeCorrect() throws Exception {
8371
final Range<String> range = Range.openClosed("a", "g");
8472

85-
assertThat(range)
86-
.hasOpenedLowerBound()
87-
.isNotEmpty()
88-
.hasClosedUpperBound()
89-
.contains("b");
73+
assertThat(range).hasOpenedLowerBound().isNotEmpty().hasClosedUpperBound().contains("b");
9074
}
9175

9276
@Test
@@ -96,10 +80,7 @@ public void givenRangeMap_whenVerifying_thenShouldBeCorrect() throws Exception {
9680
map.put(Range.closed(0, 60), "F");
9781
map.put(Range.closed(61, 70), "D");
9882

99-
assertThat(map)
100-
.isNotEmpty()
101-
.containsKeys(0)
102-
.contains(MapEntry.entry(34, "F"));
83+
assertThat(map).isNotEmpty().containsKeys(0).contains(MapEntry.entry(34, "F"));
10384
}
10485

10586
@Test
@@ -109,13 +90,7 @@ public void givenTable_whenVerifying_thenShouldBeCorrect() throws Exception {
10990
table.put(1, "A", "PRESENT");
11091
table.put(1, "B", "ABSENT");
11192

112-
assertThat(table)
113-
.hasRowCount(1)
114-
.containsValues("ABSENT")
115-
.containsCell(1, "B", "ABSENT");
93+
assertThat(table).hasRowCount(1).containsValues("ABSENT").containsCell(1, "B", "ABSENT");
11694
}
11795

118-
119-
120-
12196
}

0 commit comments

Comments
 (0)