minor cleanup
This commit is contained in:
parent
5deb5311f8
commit
201d616c6b
@ -5,16 +5,14 @@
|
|||||||
*/
|
*/
|
||||||
package com.baeldung.nullsafecollectionstreams;
|
package com.baeldung.nullsafecollectionstreams;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.AfterClass;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -22,8 +20,7 @@ import static org.junit.Assert.*;
|
|||||||
*/
|
*/
|
||||||
public class NullSafeCollectionStreamsUsingJava8OptionalContainerUnitTest {
|
public class NullSafeCollectionStreamsUsingJava8OptionalContainerUnitTest {
|
||||||
|
|
||||||
private final NullSafeCollectionStreamsUsingJava8OptionalContainer instance =
|
private final NullSafeCollectionStreamsUsingJava8OptionalContainer instance = new NullSafeCollectionStreamsUsingJava8OptionalContainer();
|
||||||
new NullSafeCollectionStreamsUsingJava8OptionalContainer();
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenCollectionIsNull_thenExpectAnEmptyStream() {
|
public void whenCollectionIsNull_thenExpectAnEmptyStream() {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.baeldung.util;
|
package com.baeldung.util;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import java.time.Clock;
|
import java.time.Clock;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
@ -10,8 +9,6 @@ import java.time.LocalTime;
|
|||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.time.temporal.ChronoField;
|
import java.time.temporal.ChronoField;
|
||||||
|
|
||||||
import org.joda.time.DateTime;
|
|
||||||
import org.joda.time.DateTimeUtils;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class CurrentDateTimeUnitTest {
|
public class CurrentDateTimeUnitTest {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.baeldung</groupId>
|
|
||||||
<artifactId>java-streams</artifactId>
|
<artifactId>java-streams</artifactId>
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
<version>0.1.0-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
package com.baeldung.stream;
|
package com.baeldung.stream;
|
||||||
|
|
||||||
import org.junit.Test;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
public class PrimitiveStreamsUnitTest {
|
public class PrimitiveStreamsUnitTest {
|
||||||
|
|
||||||
@ -66,19 +65,14 @@ public class PrimitiveStreamsUnitTest {
|
|||||||
@Test
|
@Test
|
||||||
public void givenAnArrayWhenSumIsCalledThenTheCorrectSumIsReturned() {
|
public void givenAnArrayWhenSumIsCalledThenTheCorrectSumIsReturned() {
|
||||||
|
|
||||||
int sum = Stream.of(33,45)
|
int sum = Stream.of(33, 45).mapToInt(i -> i).sum();
|
||||||
.mapToInt(i -> i)
|
|
||||||
.sum();
|
|
||||||
|
|
||||||
assertEquals(78, sum);
|
assertEquals(78, sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenAnIntStreamThenGetTheEvenIntegers() {
|
public void givenAnIntStreamThenGetTheEvenIntegers() {
|
||||||
List<Integer> evenInts = IntStream.rangeClosed(1, 10)
|
List<Integer> evenInts = IntStream.rangeClosed(1, 10).filter(i -> i % 2 == 0).boxed().collect(Collectors.toList());
|
||||||
.filter(i -> i % 2 == 0)
|
|
||||||
.boxed()
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
List<Integer> expected = IntStream.of(2, 4, 6, 8, 10).boxed().collect(Collectors.toList());
|
List<Integer> expected = IntStream.of(2, 4, 6, 8, 10).boxed().collect(Collectors.toList());
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user