use of com.dexels.navajo.document.Selection in project navajo by Dexels.
the class TestProperty method tesClearSelections.
@Test
public void tesClearSelections() {
Property testSelectionProp = NavajoFactory.getInstance().createProperty(testDoc, "testselectionproperty", "+", "", Property.DIR_IN);
Selection s1 = NavajoFactory.getInstance().createSelection(testDoc, "firstselection", "0", true);
Selection s2 = NavajoFactory.getInstance().createSelection(testDoc, "secondselection", "1", false);
Selection s3 = NavajoFactory.getInstance().createSelection(testDoc, "thirdselection", "2", false);
testSelectionProp.addSelection(s1);
testSelectionProp.addSelection(s2);
testSelectionProp.addSelection(s3);
testSelectionProp.clearSelections();
Iterator<Selection> iter = testSelectionProp.getAllSelections().iterator();
while (iter.hasNext()) {
Selection s = iter.next();
Assert.assertTrue(!s.isSelected());
}
}
use of com.dexels.navajo.document.Selection in project navajo by Dexels.
the class TestProperty method tesAddSelectionWithoutReplace.
@Test
public void tesAddSelectionWithoutReplace() {
Property testSelectionProp = NavajoFactory.getInstance().createProperty(testDoc, "testselectionproperty", "+", "", Property.DIR_IN);
Selection s1 = NavajoFactory.getInstance().createSelection(testDoc, "firstselection", "0", true);
testSelectionProp.addSelectionWithoutReplace(s1);
Selection s2 = testSelectionProp.getSelection("firstselection");
Assert.assertNotNull(s2);
Assert.assertEquals(s2.isSelected(), s1.isSelected());
Assert.assertEquals(s2.getName(), s1.getName());
Assert.assertEquals(s2.getValue(), s1.getValue());
Selection s3 = NavajoFactory.getInstance().createSelection(testDoc, "firstselection", "1", false);
testSelectionProp.addSelectionWithoutReplace(s3);
int count = 0;
List<Selection> all = testSelectionProp.getAllSelections();
for (int i = 0; i < all.size(); i++) {
if ((all.get(i)).getName().equals("firstselection"))
count++;
}
Assert.assertEquals(2, count);
}
use of com.dexels.navajo.document.Selection in project navajo by Dexels.
the class TestProperty method tesSelections.
@Test
@Deprecated
public void tesSelections() {
BaseNavajoImpl n = new BaseNavajoImpl(NavajoFactory.getInstance());
BasePropertyImpl p1 = new BasePropertyImpl(n, "Noot");
p1.setType("selection");
p1.setCardinality("1");
p1.addSelection(new BaseSelectionImpl(n, "opt1", "1", false));
p1.addSelection(new BaseSelectionImpl(n, "opt2", "2", false));
p1.addSelection(new BaseSelectionImpl(n, "opt3", "3", false));
assertEquals("___DUMMY_ELEMENT___", p1.getSelected().getValue());
// Cardinality 1
p1.setSelected("1");
assertEquals("1", p1.getSelected().getValue());
assertFalse("2".equals(p1.getSelected().getValue()));
assertFalse("3".equals(p1.getSelected().getValue()));
p1.setSelected("2");
assertEquals("2", p1.getSelected().getValue());
assertFalse("1".equals(p1.getSelected().getValue()));
assertFalse("3".equals(p1.getSelected().getValue()));
p1.setSelected("3");
assertEquals("3", p1.getSelected().getValue());
assertFalse("1".equals(p1.getSelected().getValue()));
assertFalse("2".equals(p1.getSelected().getValue()));
// Cardinality +
p1.setCardinality("+");
p1.clearSelections();
assertFalse("1".equals(p1.getSelected().getValue()));
assertFalse("2".equals(p1.getSelected().getValue()));
assertFalse("3".equals(p1.getSelected().getValue()));
p1.setSelected("1");
p1.setSelected("2");
List<Selection> all = p1.getAllSelectedSelections();
for (int i = 0; i < all.size(); i++) {
assertTrue(all.get(i).getValue().equals("1") || all.get(i).getValue().equals("2"));
assertFalse(all.get(i).getValue().equals("3"));
}
}
use of com.dexels.navajo.document.Selection in project navajo by Dexels.
the class TestProperty method tesSetSelected1.
@Test
public void tesSetSelected1() {
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);
testSelectionProp1.setSelected(new String[] { "0", "3" });
Assert.assertTrue(s1.isSelected());
Assert.assertTrue(s4.isSelected());
Assert.assertTrue(!s2.isSelected());
Assert.assertTrue(!s3.isSelected());
}
use of com.dexels.navajo.document.Selection in project navajo by Dexels.
the class TestProperty method testCopy.
@Test
public void testCopy() {
Navajo n = NavajoFactory.getInstance().createNavajo();
Selection s1 = NavajoFactory.getInstance().createSelection(n, "aap", "aap", "0");
Selection s2 = NavajoFactory.getInstance().createSelection(n, "noot", "noot", "1");
Property p = NavajoFactory.getInstance().createProperty(n, "Selectie", "+", "", "out");
p.addSelection(s1);
p.addSelection(s2);
Message m = NavajoFactory.getInstance().createMessage(n, "Soep");
n.addMessage(m);
m.addProperty(p);
Navajo n2 = NavajoFactory.getInstance().createNavajo();
p.copy(n2);
}
Aggregations