Search in sources :

Example 16 with Selection

use of com.dexels.navajo.document.Selection in project navajo by Dexels.

the class TestProperty method tesSetSelected2.

@Test
public void tesSetSelected2() {
    Property testSelectionProp1 = NavajoFactory.getInstance().createProperty(testDoc, "testselectionproperty", "+", "mydesc", Property.DIR_IN);
    Selection s1 = NavajoFactory.getInstance().createSelection(testDoc, "myselection1", "0", false);
    Selection s2 = NavajoFactory.getInstance().createSelection(testDoc, "myselection2", "1", false);
    Selection s3 = NavajoFactory.getInstance().createSelection(testDoc, "myselection3", "2", false);
    Selection s4 = NavajoFactory.getInstance().createSelection(testDoc, "myselection4", "3", false);
    testSelectionProp1.addSelection(s1);
    testSelectionProp1.addSelection(s2);
    testSelectionProp1.addSelection(s3);
    testSelectionProp1.addSelection(s4);
    List<String> l = new ArrayList<>();
    l.add("0");
    l.add("3");
    testSelectionProp1.setSelected(l);
    Assert.assertTrue(s1.isSelected());
    Assert.assertTrue(s4.isSelected());
    Assert.assertTrue(!s2.isSelected());
    Assert.assertTrue(!s3.isSelected());
}
Also used : Selection(com.dexels.navajo.document.Selection) ArrayList(java.util.ArrayList) Property(com.dexels.navajo.document.Property) Test(org.junit.Test)

Example 17 with Selection

use of com.dexels.navajo.document.Selection in project navajo by Dexels.

the class TestNavajo method testClearAllSelections.

@Test
public void testClearAllSelections() {
    Property sel1 = NavajoFactory.getInstance().createProperty(testDoc, "sel1", "+", "", Property.DIR_IN);
    Property sel2 = NavajoFactory.getInstance().createProperty(testDoc, "sel2", "+", "", Property.DIR_IN);
    testDoc.getMessage("testmessage").addProperty(sel1);
    testDoc.getMessage("testmessage").getMessage("testmessage_sub1").addProperty(sel2);
    for (int i = 0; i < 5; i++) {
        Selection s = NavajoFactory.getInstance().createSelection(testDoc, "sel" + i, i + "", true);
        sel1.addSelection(s);
        Selection s2 = NavajoFactory.getInstance().createSelection(testDoc, "selectie" + i, i + "", true);
        sel2.addSelection(s2);
    }
    List<Selection> all = null;
    all = testDoc.getMessage("testmessage").getProperty("sel1").getAllSelectedSelections();
    Assert.assertEquals(5, all.size());
    all = testDoc.getMessage("testmessage").getMessage("testmessage_sub1").getProperty("sel2").getAllSelectedSelections();
    Assert.assertEquals(5, all.size());
    testDoc.clearAllSelections();
    all = testDoc.getMessage("testmessage").getProperty("sel1").getAllSelectedSelections();
    Assert.assertEquals(0, all.size());
    all = testDoc.getMessage("testmessage").getProperty("sel1").getAllSelections();
    Assert.assertEquals(5, all.size());
    all = testDoc.getMessage("testmessage").getMessage("testmessage_sub1").getProperty("sel2").getAllSelectedSelections();
    Assert.assertEquals(0, all.size());
    all = testDoc.getMessage("testmessage").getMessage("testmessage_sub1").getProperty("sel2").getAllSelections();
    Assert.assertEquals(5, all.size());
}
Also used : Selection(com.dexels.navajo.document.Selection) Property(com.dexels.navajo.document.Property) Test(org.junit.Test)

Example 18 with Selection

use of com.dexels.navajo.document.Selection in project navajo by Dexels.

the class TestSelection method testSetValue.

@Test
public void testSetValue() {
    Selection selectionRet = NavajoFactory.getInstance().createSelection(testDoc, "firstselection", "0", true);
    selectionRet.setValue("1");
    Assert.assertEquals(selectionRet.getValue(), "1");
}
Also used : Selection(com.dexels.navajo.document.Selection) Test(org.junit.Test)

Example 19 with Selection

use of com.dexels.navajo.document.Selection in project navajo by Dexels.

the class TestSelection method testIsSelectedWithInteger0.

@Test
public void testIsSelectedWithInteger0() {
    Selection selectionRet = NavajoFactory.getInstance().createSelection(testDoc, "firstselection", "0", 1);
    selectionRet.setValue("1");
    Assert.assertTrue(selectionRet.isSelected());
}
Also used : Selection(com.dexels.navajo.document.Selection) Test(org.junit.Test)

Example 20 with Selection

use of com.dexels.navajo.document.Selection in project navajo by Dexels.

the class TestSelection method testCreate.

@Test
public void testCreate() {
    Selection selectionRet = NavajoFactory.getInstance().createSelection(testDoc, "firstselection", "0", true);
    Assert.assertEquals(selectionRet.getName(), "firstselection");
    Assert.assertEquals(selectionRet.getValue(), "0");
    Assert.assertEquals(selectionRet.isSelected(), true);
}
Also used : Selection(com.dexels.navajo.document.Selection) Test(org.junit.Test)

Aggregations

Selection (com.dexels.navajo.document.Selection)78 Property (com.dexels.navajo.document.Property)36 Test (org.junit.Test)32 Message (com.dexels.navajo.document.Message)24 Navajo (com.dexels.navajo.document.Navajo)21 Access (com.dexels.navajo.script.api.Access)14 ImmutableMessage (com.dexels.immutable.api.ImmutableMessage)13 ContextExpression (com.dexels.navajo.expression.api.ContextExpression)12 TipiLink (com.dexels.navajo.expression.api.TipiLink)12 MappableTreeNode (com.dexels.navajo.script.api.MappableTreeNode)12 ArrayList (java.util.ArrayList)12 Optional (java.util.Optional)12 Operand (com.dexels.navajo.document.Operand)11 TMLExpressionException (com.dexels.navajo.expression.api.TMLExpressionException)11 List (java.util.List)8 NavajoException (com.dexels.navajo.document.NavajoException)6 UserException (com.dexels.navajo.script.api.UserException)4 Binary (com.dexels.navajo.document.types.Binary)3 FunctionClassification (com.dexels.navajo.expression.api.FunctionClassification)3 StringTokenizer (java.util.StringTokenizer)3