package com.levelup.java.util.stream;

import static org.junit.Assert.assertEquals;

import java.util.OptionalInt;
import java.util.stream.IntStream;

import org.junit.Test;

/**
 * This java example will demonstrate how to find the sum unique values from two
 * IntStreams .
 * 
 * @author Justin Musgrove
 * @see <a href=
 *      'http://www.leveluplunch.com/java/examples/sum-unique-values-two-intstream/'>Sum
 *      unique values of numeric streams</a>
 */
public class SumUniqueValsTwoIntStreams {

	@Test
	public void sum_unique_values_intstream() {

		IntStream stream1 = IntStream.of(1, 2, 3);
		IntStream stream2 = IntStream.of(1, 2, 3);

		int val = IntStream.concat(stream1, stream2).distinct().sum();

		assertEquals(6, val);

		// or
		OptionalInt sum2 = IntStream.concat(stream1, stream2).reduce(
				(a, b) -> a + b);

		assertEquals(6, sum2.getAsInt());
	}

}

@@ -403,18 +403,16 @@
 ream/'%3ES
-um
 %0A *     
@@ -412,16 +412,20 @@
  *      
+u m 
 unique v
@@ -743,16 +743,107 @@
 %09%09// or%0A
+%09%09IntStream stream3 = IntStream.of(1, 2, 3);%0A%09%09IntStream stream4 = IntStream.of(1, 2, 3);%0A%0A
 %09%09Option
@@ -878,25 +878,25 @@
 t(stream
-1
+3
 , stream
 2).reduc
@@ -891,23 +891,34 @@
 ream
-2
+4
 ).
+distinct()%0A%09%09%09%09.
 reduce(
-%0A%09%09%09%09
 (a, 

fix unit test