package extensions.java.util.stream.Stream;

import org.junit.Test;

import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static org.junit.Assert.assertEquals;

public class ManifoldStreamExtTest {

    @Test
    public void embellishments(){

        // embellishments
        Stream<String> stream = stream("a", "aa", "aaa");
        assertEquals(stream, stream.toList());
        assertEquals(new HashSet<>(stream.toList()), stream.toSet());
        assertEquals(new TreeSet<>(stream.toList()), stream.toSortedSet());

        Map<Integer, String> byLen = stream.toMap(String::length);
        assertEquals("a", byLen.get(1));
        assertEquals("aaa", byLen.get(3));

        Map<Integer, Integer> hashCodeByLen = stream.toMap(String::length, String::hashCode);
        assertEquals((Integer) "a".hashCode(), hashCodeByLen.get(1));
        assertEquals((Integer) "aaa".hashCode(), hashCodeByLen.get(3));

        Map<Integer, List<String>> stringsByLength = stream("a", "b", "aa", "ab", "abc").groupingBy(String::length);
        assertEquals(2, stringsByLength.get(1).size());
        assertEquals(2, stringsByLength.get(2).size());
        assertEquals(1, stringsByLength.get(3).size());
        assertEquals(null, stringsByLength.get(4));
    }

    private <T> Stream<T> stream(T... args) {
        return Arrays.asList(args).stream();
    }
}

@@ -86,44 +86,8 @@
 .*;%0A
-import java.util.stream.Collectors;%0A
 impo
@@ -278,22 +278,20 @@
         
-Stream
+List
 %3CString%3E
@@ -296,22 +296,33 @@
 g%3E s
-tream = stream
+ampleList = Arrays.asList
 (%22a%22
@@ -337,16 +337,17 @@
 %22aaa%22);%0A
+%0A
         
@@ -363,22 +363,39 @@
 als(
-stream, stream
+ sampleList, stream(sampleList)
 .toL
@@ -398,24 +398,25 @@
 .toList());%0A
+%0A
         asse
@@ -420,24 +420,25 @@
 ssertEquals(
+ 
 new HashSet%3C
@@ -437,32 +437,44 @@
 HashSet%3C%3E(stream
+(sampleList)
 .toList()), stre
@@ -471,24 +471,36 @@
 t()), stream
+(sampleList)
 .toSet());%0A 
@@ -494,24 +494,25 @@
 ).toSet());%0A
+%0A
         asse
@@ -520,16 +520,17 @@
 tEquals(
+ 
 new Tree
@@ -541,16 +541,28 @@
 %3E(stream
+(sampleList)
 .toList(
@@ -571,16 +571,28 @@
 , stream
+(sampleList)
 .toSorte
@@ -636,39 +636,52 @@
 %3E byLen = stream
+(sampleList)
 .toMap(
+ 
 String::length);
@@ -818,23 +818,36 @@
 = stream
+(sampleList)
 .toMap(
+ 
 String::
@@ -1076,16 +1076,30 @@
  stream(
+Arrays.asList(
 %22a%22, %22b%22
@@ -1118,16 +1118,17 @@
 , %22abc%22)
+)
 .groupin
@@ -1412,17 +1412,23 @@
 eam(
-T... args
+Collection%3CT%3E c
 ) %7B%0A
@@ -1446,27 +1446,9 @@
 urn 
-Arrays.asList(args)
+c
 .str

fix tests