BAEL-4969: Improvement: Streams to Immutable Collections (#11026)

* add new module for java core 16

* format pom.xml
This commit is contained in:
Azhwani
2021-07-15 06:18:47 +02:00
committed by GitHub
parent 16c3110e9c
commit 3befd30ef4
3 changed files with 74 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
package com.baeldung.streams;
import java.util.List;
import java.util.stream.Stream;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class StreamToImmutableUnitTest {
@Test
public void whenUsingStreamToList_thenReturnImmutableList() {
List<String> immutableList = Stream.of("a", "b", "c", "d")
.toList();
Assertions.assertThrows(UnsupportedOperationException.class, () -> {
immutableList.add("e");
});
}
}