/*
 *  Copyright (C) 2011-2012 The Animo Project
 *  http://animotron.org
 *  	
 *  This file is part of Animotron.
 *  
 *  Animotron is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Affero General Public License as 
 *  published by the Free Software Foundation, either version 3 of 
 *  the License, or (at your option) any later version.
 *  
 *  Animotron is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Affero General Public License for more details.
 *  
 *  You should have received a copy of 
 *  the GNU Affero General Public License along with Animotron.  
 *  If not, see <http://www.gnu.org/licenses/>.
 */
package org.animotron.statement.operator;

import org.animotron.ATest;
import org.animotron.expression.Expression;
import org.animotron.expression.JExpression;
import org.junit.Ignore;
import org.junit.Test;

import static org.animotron.expression.AnimoExpression.__;
import static org.animotron.expression.JExpression._;

/**
 * @author <a href="mailto:shabanovd@gmail.com">Dmitriy Shabanov</a>
 * @author <a href="mailto:gazdovsky@gmail.com">Evgeny Gazdovsky</a>
 *
 */
public class DefTest extends ATest {
	
    @Test
    @Ignore
    public void testDEF() throws Throwable {

        JExpression A = new JExpression(
            _(DEF._, "A", _(DEF._, "B", _(DEF._, "C")))
        );
        assertAnimoResult(A, "def A the B the C.");
        assertAnimo(A, "def A the B the C.");
    }

	@Test
 	public void testREV() throws Throwable {
//        Expression e;
//        e = testAnimo("def e 1.");
//        String uuid1 = (String) UUID.getDef(e);
//        e = testAnimo("def e 2.");
//        String uuid2 = (String) UUID.getDef(e);
//        Relationship rev1 = e.getEndNode().getSingleRelationship(REV, OUTGOING);
//        Assert.assertNotNull(rev1);
//        Assert.assertEquals("", UUID.getDef(rev1), uuid1);
//        e = testAnimo("def e 3.");
//        String uuid3 = (String) UUID.getDef(e);
//        Relationship rev2 = e.getEndNode().getSingleRelationship(REV, OUTGOING).getEndNode().getSingleRelationship(REV, OUTGOING);
//        Assert.assertNotNull(rev2);
//        Assert.assertEquals("", UUID.getDef(rev2), uuid1);
//        Assert.assertFalse(uuid1.equals(uuid2));
//        Assert.assertFalse(uuid2.equals(uuid3));
	}

	@Test
 	public void testREV_00() throws Throwable {
        testAnimo("def e 1.");
        testAnimo("def e 2.");
        testAnimo("def e 3.");
        testAnimo("def e 1.");
	}

	@Test
 	public void testREV_01() throws Throwable {
		Expression e;
		
		e = testAnimo("def e name (lang-en \"name\") (lang-ru \"исправленное имя\").");

        e = testAnimo("def e name (lang-en \"corrected name\") (lang-ru \"исправленное имя\").");
	}
	
	@Test
 	public void testREV_02() throws Throwable {
		Expression e;
		
		e = testAnimo("def e name (lang-en \"name\") (lang-ru \"исправленное имя\").");

        e = testAnimo("def e name (lang-en \"corrected name\") (lang-ru \"исправленное имя\").");

		e = testAnimo("def e name (lang-en \"name\") (lang-ru \"исправленное имя\").");
	}

	@Test
 	public void testREV_10() throws Throwable {
        testAnimo("def e 1.");
        testAnimo("def e 2.");
        assertAnimoResultOneStep("e", "e 2."); //UNDERSTAND: is it correct, missing DEF at beginning?

        testAnimo("def e 1.");
        assertAnimoResultOneStep("e", "e 1."); //UNDERSTAND: is it correct, missing DEF at beginning?
	}

    @Test
    public void test_11() throws Throwable {

        __(
	        "def item (goods aaa) (qty (1) (kg)) (cost (10) (USD))."
        );

        assertAnimoResult(
            "get cost item",
            "cost 10 (USD)."
        );

        __(
	        "def item (goods aaa) (qty (1) (kg)) (cost (5) (USD))."
        );

        assertAnimoResult(
            "get cost item",
            "cost 5 (USD)."
		);
    }
}
@@ -873,52 +873,8 @@
 st;%0A
-import org.animotron.expression.Expression;%0A
 impo
@@ -2637,39 +2637,16 @@
 ble %7B%0A%09%09
-Expression e;%0A%09%09%0A%09%09e = 
 testAnim
@@ -2713,36 +2713,32 @@
 %5C%22).%22);%0A%0A       
- e =
  testAnimo(%22def 
@@ -2872,31 +2872,8 @@
 %7B%0A%09%09
-Expression e;%0A%09%09%0A%09%09e = 
 test
@@ -2948,28 +2948,24 @@
 %22);%0A%0A       
- e =
  testAnimo(%22
@@ -3042,20 +3042,16 @@
 .%22);%0A%0A%09%09
-e = 
 testAnim
@@ -3696,21 +3696,15 @@
    %22
-cost 10 (
+10. 
 USD
-)
 .%22%0A 

update test