@@ -0,0 +1,1858 @@
+/*%0A * Copyright 2014 the original author or authors.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * %09http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage io.github.carlomicieli.java8;%0A%0Aimport org.junit.Test;%0A%0Aimport java.util.Optional;%0Aimport java.util.stream.Stream;%0A%0Aimport static org.hamcrest.CoreMatchers.equalTo;%0Aimport static org.hamcrest.CoreMatchers.is;%0Aimport static org.junit.Assert.assertThat;%0A%0A/**%0A * @author Carlo Micieli%0A */%0Apublic class StreamTests %7B%0A    @Test%0A    public void shouldCreateStreamsWithOnlyOneElement() %7B%0A        Stream%3CInteger%3E s = Stream.of(1);%0A        assertThat(s.count(), is(equalTo(1L)));%0A    %7D%0A%0A    @Test%0A    public void shouldCreateStreamsWithTheSpecifiedElements() %7B%0A        Stream%3CInteger%3E s = Stream.of(1, 2, 3, 4);%0A        assertThat(s.toArray(Integer%5B%5D::new), is(new Integer%5B%5D%7B1, 2, 3, 4%7D));%0A    %7D%0A%0A    @Test%0A    public void shouldGenerateInfiniteStreams() %7B%0A        Stream%3CInteger%3E s = Stream.iterate(0, n -%3E n + 1);%0A        Optional%3CInteger%3E val = s.skip(100).limit(1).findFirst();%0A%0A        int n = val.orElse(-1);%0A        assertThat(n, is(equalTo(100)));%0A    %7D%0A%0A    @Test%0A    public void shouldApplyFunctionToStreamElements() %7B%0A        Stream%3CString%3E s = Stream.of(%22home%22, %22sweet%22, %22home%22);%0A        Stream%3CString%3E s2 = s.map(String::toUpperCase);%0A%0A        assertThat(s2.toArray(String%5B%5D::new), is(new String%5B%5D%7B%22HOME%22, %22SWEET%22, %22HOME%22%7D));%0A    %7D%0A%0A%7D%0A

Add tests