Skip to content

Commit 25a64f5

Browse files
author
eugenp
committed
java 8 new tests and quick maven upgrades
1 parent 0e97dc8 commit 25a64f5

File tree

3 files changed

+51
-12
lines changed

3 files changed

+51
-12
lines changed

core-java-8/pom.xml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<dependency>
1515
<groupId>com.google.guava</groupId>
1616
<artifactId>guava</artifactId>
17-
<version>16.0.1</version>
17+
<version>17.0</version>
1818
</dependency>
1919

2020
<dependency>
@@ -26,7 +26,7 @@
2626
<dependency>
2727
<groupId>org.apache.commons</groupId>
2828
<artifactId>commons-lang3</artifactId>
29-
<version>3.1</version>
29+
<version>3.3.2</version>
3030
</dependency>
3131

3232
<!-- web -->
@@ -111,35 +111,34 @@
111111
<mysql-connector-java.version>5.1.27</mysql-connector-java.version>
112112

113113
<!-- marshalling -->
114-
<jackson.version>2.3.0</jackson.version>
114+
<jackson.version>2.4.0</jackson.version>
115115

116116
<!-- logging -->
117117
<org.slf4j.version>1.7.5</org.slf4j.version>
118118
<logback.version>1.0.11</logback.version>
119119

120120
<!-- various -->
121-
<hibernate-validator.version>5.0.1.Final</hibernate-validator.version>
121+
<hibernate-validator.version>5.1.1.Final</hibernate-validator.version>
122122

123123
<!-- util -->
124-
<guava.version>15.0</guava.version>
125-
<commons-lang3.version>3.1</commons-lang3.version>
124+
<guava.version>17.0</guava.version>
125+
<commons-lang3.version>3.3.2</commons-lang3.version>
126126

127127
<!-- testing -->
128128
<org.hamcrest.version>1.3</org.hamcrest.version>
129129
<junit.version>4.11</junit.version>
130130
<mockito.version>1.9.5</mockito.version>
131131

132-
<httpcore.version>4.3</httpcore.version>
133-
<httpclient.version>4.3.1</httpclient.version>
132+
<httpcore.version>4.3.2</httpcore.version>
133+
<httpclient.version>4.3.4</httpclient.version>
134134

135-
<rest-assured.version>2.1.0</rest-assured.version>
135+
<rest-assured.version>2.3.2</rest-assured.version>
136136

137137
<!-- maven plugins -->
138138
<maven-compiler-plugin.version>3.1</maven-compiler-plugin.version>
139139
<maven-war-plugin.version>2.4</maven-war-plugin.version>
140-
<maven-surefire-plugin.version>2.16</maven-surefire-plugin.version>
140+
<maven-surefire-plugin.version>2.17</maven-surefire-plugin.version>
141141
<maven-resources-plugin.version>2.6</maven-resources-plugin.version>
142-
<cargo-maven2-plugin.version>1.4.5</cargo-maven2-plugin.version>
143142

144143
</properties>
145144

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package org.baeldung.java8;
2+
3+
import static org.hamcrest.Matchers.hasSize;
4+
import static org.junit.Assert.assertThat;
5+
6+
import java.util.List;
7+
import java.util.stream.Collectors;
8+
9+
import org.junit.Test;
10+
11+
import com.google.common.collect.Lists;
12+
13+
public class Java8CollectionCleanupUnitTest {
14+
15+
// tests -
16+
17+
@Test
18+
public void givenListContainsNulls_whenFilteringParallel_thenCorrect() {
19+
final List<Integer> list = Lists.newArrayList(null, 1, 2, null, 3, null);
20+
final List<Integer> listWithoutNulls = list.parallelStream().filter(i -> i != null).collect(Collectors.toList());
21+
22+
assertThat(listWithoutNulls, hasSize(3));
23+
}
24+
25+
@Test
26+
public void givenListContainsNulls_whenFilteringSerial_thenCorrect() {
27+
final List<Integer> list = Lists.newArrayList(null, 1, 2, null, 3, null);
28+
final List<Integer> listWithoutNulls = list.stream().filter(i -> i != null).collect(Collectors.toList());
29+
30+
assertThat(listWithoutNulls, hasSize(3));
31+
}
32+
33+
@Test
34+
public void givenListContainsDuplicates_whenRemovingDuplicatesWithJava8_thenCorrect() {
35+
final List<Integer> listWithDuplicates = Lists.newArrayList(1, 1, 2, 2, 3, 3);
36+
final List<Integer> listWithoutDuplicates = listWithDuplicates.parallelStream().distinct().collect(Collectors.toList());
37+
38+
assertThat(listWithoutDuplicates, hasSize(3));
39+
}
40+
41+
}

core-java-8/src/test/java/org/baeldung/java8/Java8SortUnitTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.baeldung.java8;
22

3-
import static org.baeldung.java8.entity.Human.compareByNameThenAge;
43
import static org.hamcrest.Matchers.equalTo;
54

65
import java.util.Collections;

0 commit comments

Comments
 (0)