package com.insightfullogic.java8.test.chapter3;

import static org.junit.Assert.*;

import java.util.List;
import java.util.function.Predicate;

import org.junit.Test;

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

public class FilterUsingReduceTest {

	@Test
	public void test() {
		fail("Not yet implemented");
	}

	private <I> void assertFiltered(Predicate<I> predicate, List<I> input, List<I> exceptedOutput) {
		List<I> output = FilterUsingReduce.filter(input.stream(), predicate);
		assertEquals(exceptedOutput, output);

		List<I> parallelOutput = FilterUsingReduce.filter(input.parallelStream(), predicate);
		assertEquals(exceptedOutput, output);
	}

}

@@ -80,16 +80,87 @@
 ert.*;%0D%0A
+import static java.util.Arrays.asList;%0D%0A%0D%0Aimport java.util.Collections;
 %0D%0Aimport
@@ -376,18 +376,23 @@
 ic void 
-t
 e
+mptyLi
 st() %7B%0D%0A
@@ -397,34 +397,347 @@
 %0D%0A%09%09
-fail(%22Not yet implemented%22
+assertFiltered(x -%3E false, Collections.%3CObject%3E emptyList(), Collections.%3CObject%3E emptyList());%0D%0A%09%7D%0D%0A%0D%0A%09@Test%0D%0A%09public void trueReturnsEverything() %7B%0D%0A%09%09assertFiltered((Integer x) -%3E true, asList(1, 2, 3), asList(1, 2, 3));%0D%0A%09%7D%0D%0A%0D%0A%09@Test%0D%0A%09public void filterPartOfList() %7B%0D%0A%09%09assertFiltered((Integer x) -%3E x %3E 2, asList(1, 2, 3), asList(3)
 );%0D%0A

complete test for FilterUsingReduce in chapter3