package com.qiwu.chatbotbackend; import com.qiwu.chatbotbackend.processing.ActionMatcher; import org.junit.Test; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import static org.junit.Assert.assertEquals; public class PremiseTests { @Test public void testpremise() throws Exception { Map curInfoPoint = new HashMap() { { put("testCondition", "cc:瑞娜"); put("testCondition2", "数量:蓝色药水"); put("testCondition3", "瑞娜:友好度"); put("testCondition4", "瑞娜:友好度"); put("testCondition5", " :瑞娜"); } }; Map hisInfoPoint = new HashMap() { { put("site", "海边"); } }; String keyword1 = "+2+1+3+4+6+5+7"; HashSet keywordSet1 = new HashSet(){ { add("1"); add("2"); } }; String keyword2 = "+2+1+3+4+6+5+7"; HashSet keywordSet2 = new HashSet(){ { add("1"); add("2"); add("10"); } }; String keyword3 = "+2+1+3+4+6+5+7"; HashSet keywordSet3 = new HashSet(){ { add("10"); add("2"); } }; HashSet keywordSet4 = new HashSet(){ { add(""); } }; String exculdeTestKeywords = ""; ActionMatcher matcher = new ActionMatcher(); Boolean result1 = matcher.premiseSatisfy(keyword1, "match-Have", keywordSet1); Boolean result2 = matcher.premiseSatisfy(keyword2, "match-Have", keywordSet2); Boolean result3 = matcher.premiseSatisfy(exculdeTestKeywords, "match-Exlucde", keywordSet2); Boolean result4 = matcher.premiseSatisfy(keyword3, "match-NotHave", keywordSet3); Boolean result5 = matcher.premiseSatisfy(keyword3, "match-Any", keywordSet3); Boolean result6 = matcher.premiseSatisfy("", "match-Any", keywordSet4); //result = controller.worldOperation(gameEnv, "goods_query", "queryAroundGoodsByClassName:testCondition4", curInfoPoint, hisInfoPoint); assertEquals(true, result1); assertEquals(false, result2); assertEquals(false, result3); assertEquals(false, result4); assertEquals(true, result5); assertEquals(false, result6); } }