package com.insightfullogic.java8.test.chapter3;

import static org.junit.Assert.*;

import java.util.Collections;
import java.util.List;
import java.util.function.Function;

import org.junit.Test;

import com.insightfullogic.java8.answers.chapter3.*;

public class MapUsingReduceTest {
	
	@Test
	public void emptyList(){
		assertMapped(Function.<Object>identity(), Collections.<Object>emptyList(), Collections.<Object>emptyList());
	}

	private <I,O> void assertMapped(Function<I,O> mapper,List<I> input,List<O> expectedOutput){
		List<O> output=MapUsingReduce.map(input.stream(), mapper);
		assertEquals(expectedOutput, output);
	}
	
}

@@ -79,16 +79,56 @@
 sert.*;%0D
+%0Aimport static java.util.Arrays.asList;%0D
 %0A%0D%0Aimpor
@@ -333,17 +333,16 @@
 Test %7B%0D%0A
-%09
 %0D%0A%09@Test
@@ -367,16 +367,17 @@
 tyList()
+ 
 %7B%0D%0A%09%09ass
@@ -403,16 +403,17 @@
 %3CObject%3E
+ 
 identity
@@ -428,32 +428,33 @@
 ections.%3CObject%3E
+ 
 emptyList(), Col
@@ -470,16 +470,17 @@
 %3CObject%3E
+ 
 emptyLis
@@ -492,16 +492,263 @@
 %0D%0A%09%7D%0D%0A%0D%0A
+%09@Test%0D%0A%09public void identityMapsToItself() %7B%0D%0A%09%09assertMapped((Integer x) -%3E x, asList(1, 2, 3), asList(1, 2, 3));%0D%0A%09%7D%0D%0A%0D%0A%09@Test%0D%0A%09public void incrementingNumbers() %7B%0D%0A%09%09assertMapped((Integer x) -%3E x + 2, asList(1, 2, 3), asList(3, 4, 5));%0D%0A%09%7D%0D%0A%0D%0A
 %09private
@@ -751,16 +751,17 @@
 vate %3CI,
+ 
 O%3E void 
@@ -784,16 +784,17 @@
 ction%3CI,
+ 
 O%3E mappe
@@ -795,16 +795,17 @@
  mapper,
+ 
 List%3CI%3E 
@@ -810,16 +810,17 @@
 %3E input,
+ 
 List%3CO%3E 
@@ -834,16 +834,17 @@
 dOutput)
+ 
 %7B%0D%0A%09%09Lis
@@ -858,9 +858,11 @@
 tput
-=
+ = 
 MapU
@@ -946,14 +946,142 @@
 t);%0D
+%0A%0D%0A%09%09List%3CO%3E paralleOutPut = MapUsingReduce.map(input.parallelStream(), mapper);%0D%0A%09%09assertEquals(expectedOutput, paralleOutPut);%0D
 %0A%09%7D%0D%0A
-%09
 %0D%0A%7D%0D

complete test for MapUsingReduce in chapter3