package com.insightfullogic.java8.test.chapter4;

import static org.junit.Assert.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.hasItems;

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

import org.junit.Test;

import com.insightfullogic.java8.answers.chapter4.PerformanceFixed;
import com.insightfullogic.java8.examples.chapter1.Artist;
import com.insightfullogic.java8.examples.chapter1.SampleData;

public class PerformanceFixedTest {

	@Test
	public void testGetAllMusicians() {

		PerformanceFixed stub = new PerformanceFixed() {

			@Override
			public String getName() {
				throw new UnsupportedOperationException();
			}

			@Override
			public Stream<Artist> getMusicians() {
				return Stream.of(SampleData.theBeatles);
			}
		};
		
		List<Artist> allMusicians=stub.getAllMusicians().collect(Collectors.toList());
		
		// ʹøõĲԷ,罫theBeatlesmembersOfTheBeatlesͨlambdaϳList
		assertThat(allMusicians, hasItem(SampleData.theBeatles));
		assertThat(allMusicians, hasItems(SampleData.membersOfTheBeatles.toArray(new Artist[0])));
	}

}

@@ -133,16 +133,175 @@
 rtThat;%0D
+%0A%0D%0A// http://www.vogella.com/tutorials/Hamcrest/article.html%0D%0A// %D6%B7%E1%B9%A9HamcrestJunit%CD%BB%C4%B0%EC%B7%A8%0D%0A// http://search.maven.org/#search%7Cga%7C1%7Cg%253Aorg.hamcrest%0D%0A// %D6%B7%E1%B9%A9hamcrest%C4%BC%C2%B7%0D
 %0Aimport 

add some comment.后续需要使用maven管理包。