Skip to content

Commit

Permalink
increase test coverage for js rule kie
Browse files Browse the repository at this point in the history
  • Loading branch information
cschen1205 committed May 9, 2017
1 parent 6271c46 commit 55d0cdc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Expand Up @@ -153,7 +153,7 @@ protected boolean fireRule(List<Rule> conflictingRules){
@Override public List<Clause> getFactsAboutVariable(String variable){
List<Clause> facts = new ArrayList<>();
for(Clause c : memory.getFacts()){
if(c.getVariable().contains(variable)){
if(c.getVariable().equalsIgnoreCase(variable)){
facts.add(c);
}
}
Expand Down
@@ -1,14 +1,17 @@
package com.github.cschen1205.ess.js;

import com.github.cschen1205.ess.engine.Clause;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

import javax.script.ScriptException;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
* Created by cschen on 28/4/17.
Expand All @@ -22,6 +25,11 @@ public void setup() throws ScriptException {

}

@Test
public void testLoadFileWithException() throws ScriptException {
engine.loadFile("/tmp/rules-new.js");
}

@Test
public void testLoadFile() throws IOException, ScriptException {
String jsContent = IOUtil.readToEnd("js/vehicle-rules.js");
Expand Down Expand Up @@ -51,6 +59,9 @@ public void testLoadFile() throws IOException, ScriptException {
System.out.println(engine.getKnowledgeBase());
System.out.println();

List<Clause> facts = engine.getFacts("vehicle");
facts.forEach(f -> System.out.println(f));

}


Expand Down

0 comments on commit 55d0cdc

Please sign in to comment.