package de.danielbasedow.prospecter.core.query.build;

import aima.core.logic.propositional.parsing.ast.Connective;
import aima.core.logic.propositional.parsing.ast.Sentence;
import de.danielbasedow.prospecter.core.query.build.*;
import junit.framework.TestCase;

import java.util.ArrayList;
import java.util.List;

public class PropositionSentenceMapperTest extends TestCase {
    public void test() {
        List<ClauseNode> conditionsA = new ArrayList<ClauseNode>();
        conditionsA.add(new Condition<Integer>("price", "gte", new Value<Integer>(100)));
        conditionsA.add(new Condition<Integer>("floor", "lt", new Value<Integer>(4)));
        Clause clauseA = new Clause(Clause.ClauseType.AND, conditionsA);

        List<ClauseNode> conditionsB = new ArrayList<ClauseNode>();
        conditionsB.add(new Condition<String>("category", "eq", new Value<String>("foo")));
        conditionsB.add(new Condition<String>("category", "eq", new Value<String>("bar")));
        Clause clauseB = new Clause(Clause.ClauseType.AND, conditionsB);

        List<ClauseNode> clauses = new ArrayList<ClauseNode>();
        clauses.add(clauseA);
        clauses.add(clauseB);

        Clause root = new Clause(Clause.ClauseType.OR, clauses);
        Sentence sentence = PropositionalSentenceMapper.map(root);
        assertEquals(Connective.OR, sentence.getConnective());
        assertEquals(2, sentence.getNumberSimplerSentences());
    }
}

@@ -212,21 +212,126 @@
 ore.
-query.build.*
+MatchCondition;%0Aimport de.danielbasedow.prospecter.core.Token;%0Aimport de.danielbasedow.prospecter.core.query.Condition
 ;%0Aim
@@ -606,25 +606,16 @@
 ondition
-%3CInteger%3E
 (%22price%22
@@ -620,37 +620,66 @@
 e%22, 
-%22gte%22, new Value%3CInteger%3E(100
+new Token%3CInteger%3E(100, MatchCondition.GREATER_THAN_EQUALS
 )));
@@ -716,25 +716,16 @@
 ondition
-%3CInteger%3E
 (%22floor%22
@@ -729,24 +729,18 @@
 or%22,
- %22lt%22,
  new 
-Value
+Token
 %3CInt
@@ -746,16 +746,42 @@
 teger%3E(4
+, MatchCondition.LESS_THAN
 )));%0A   
@@ -952,32 +952,24 @@
 ew Condition
-%3CString%3E
 (%22category%22,
@@ -973,37 +973,54 @@
 y%22, 
-%22eq%22, new Value%3CString%3E(%22foo%22
+new Token%3CString%3E(%22foo%22, MatchCondition.EQUALS
 )));
@@ -1057,24 +1057,16 @@
 ondition
-%3CString%3E
 (%22catego
@@ -1074,37 +1074,54 @@
 y%22, 
-%22eq%22, new Value%3CString%3E(%22bar%22
+new Token%3CString%3E(%22bar%22, MatchCondition.EQUALS
 )));

fix failing unit test