Browse Source

测试用例错误解决

haibinxiao 5 years ago
parent
commit
f5c53a8f60
1 changed files with 7 additions and 6 deletions
  1. 7 6
      hutool-dfa/src/test/java/cn/hutool/dfa/test/DfaTest.java

+ 7 - 6
hutool-dfa/src/test/java/cn/hutool/dfa/test/DfaTest.java

@@ -7,6 +7,7 @@ import org.junit.Assert;
 import org.junit.Test;
 
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * DFA单元测试
@@ -29,7 +30,7 @@ public class DfaTest {
 		// 匹配到【大】,就不再继续匹配了,因此【大土豆】不匹配
 		// 匹配到【刚出锅】,就跳过这三个字了,因此【出锅】不匹配(由于刚首先被匹配,因此长的被匹配,最短匹配只针对第一个字相同选最短)
 		List<FoundWord> matchAll = tree.matchAll(text, -1, false, false);
-		Assert.assertEquals(matchAll.stream().map(fw -> fw.getFoundWord()), CollectionUtil.newArrayList("大", "土^豆", "刚出锅"));
+		Assert.assertEquals(matchAll.stream().map(fw -> fw.getFoundWord()).collect(Collectors.toList()), CollectionUtil.newArrayList("大", "土^豆", "刚出锅"));
 	}
 
 	/**
@@ -45,7 +46,7 @@ public class DfaTest {
 		// 【大】被匹配,最短匹配原则【大土豆】被跳过,【土豆继续被匹配】
 		// 【刚出锅】被匹配,由于不跳过已经匹配的词,【出锅】被匹配
 		List<FoundWord> matchAll = tree.matchAll(text, -1, true, false);
-		Assert.assertEquals(matchAll.stream().map(fw -> fw.getFoundWord()), CollectionUtil.newArrayList("大", "土^豆", "刚出锅", "出锅"));
+		Assert.assertEquals(matchAll.stream().map(fw -> fw.getFoundWord()).collect(Collectors.toList()), CollectionUtil.newArrayList("大", "土^豆", "刚出锅", "出锅"));
 	}
 
 	/**
@@ -61,7 +62,7 @@ public class DfaTest {
 		// 匹配到【大】,由于到最长匹配,因此【大土豆】接着被匹配
 		// 由于【大土豆】被匹配,【土豆】被跳过,由于【刚出锅】被匹配,【出锅】被跳过
 		List<FoundWord> matchAll = tree.matchAll(text, -1, false, true);
-		Assert.assertEquals(matchAll.stream().map(fw -> fw.getFoundWord()), CollectionUtil.newArrayList("大", "大土^豆", "刚出锅"));
+		Assert.assertEquals(matchAll.stream().map(fw -> fw.getFoundWord()).collect(Collectors.toList()), CollectionUtil.newArrayList("大", "大土^豆", "刚出锅"));
 
 	}
 
@@ -78,7 +79,7 @@ public class DfaTest {
 		// 匹配到【大】,由于到最长匹配,因此【大土豆】接着被匹配,由于不跳过已经匹配的关键词,土豆继续被匹配
 		// 【刚出锅】被匹配,由于不跳过已经匹配的词,【出锅】被匹配
 		List<FoundWord> matchAll = tree.matchAll(text, -1, true, true);
-		Assert.assertEquals(matchAll.stream().map(fw -> fw.getFoundWord()), CollectionUtil.newArrayList("大", "大土^豆", "土^豆", "刚出锅", "出锅"));
+		Assert.assertEquals(matchAll.stream().map(fw -> fw.getFoundWord()).collect(Collectors.toList()), CollectionUtil.newArrayList("大", "大土^豆", "土^豆", "刚出锅", "出锅"));
 
 	}
 
@@ -91,7 +92,7 @@ public class DfaTest {
 		tree.addWord("tio");
 
 		List<FoundWord> all = tree.matchAll("AAAAAAAt-ioBBBBBBB");
-		Assert.assertEquals(all.stream().map(fw -> fw.getFoundWord()), CollectionUtil.newArrayList("t-io"));
+		Assert.assertEquals(all.stream().map(fw -> fw.getFoundWord()).collect(Collectors.toList()), CollectionUtil.newArrayList("t-io"));
 	}
 
 	@Test
@@ -100,7 +101,7 @@ public class DfaTest {
 		tree.addWord("women");
 		String text = "a WOMEN todo.".toLowerCase();
 		List<FoundWord> matchAll = tree.matchAll(text, -1, false, false);
-		Assert.assertEquals("[women]", matchAll.stream().map(fw -> fw.getFoundWord()).toString());
+		Assert.assertEquals("[women]", matchAll.stream().map(fw -> fw.getFoundWord()).collect(Collectors.toList()).toString());
 	}
 
 	// ----------------------------------------------------------------------------------------------------------