use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class TestBinary method testBinaryDigest.
@Test
public void testBinaryDigest() {
Binary b1 = new Binary(getClass().getResourceAsStream("binary1.txt"));
Property p1 = NavajoFactory.getInstance().createProperty(null, "Binary", Property.BINARY_PROPERTY, "", 0, "", Property.DIR_IN);
Property p2 = NavajoFactory.getInstance().createProperty(null, "Binary2", Property.BINARY_PROPERTY, "", 0, "", Property.DIR_IN);
p1.setAnyValue(b1);
Assert.assertEquals(Property.BINARY_PROPERTY, p1.getType());
p2.setAnyValue(b1.getDigest());
Assert.assertEquals(Property.BINARY_DIGEST_PROPERTY, p2.getType());
}
use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class TestProperty method tesGetAllSelections.
@Test
public void tesGetAllSelections() {
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", true);
testSelectionProp.addSelection(s1);
testSelectionProp.addSelection(s2);
testSelectionProp.addSelection(s3);
Iterator<Selection> iter = testSelectionProp.getAllSelections().iterator();
int count = 3;
Set<String> set = new HashSet<>();
while (iter.hasNext()) {
Selection s = iter.next();
set.add(s.getName());
if ((s.getName().equals("firstselection") || s.getName().equals("thirdselection") || s.getName().equals("secondselection")))
count--;
}
Assert.assertEquals(3, set.size());
Assert.assertEquals(0, count);
}
use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class TestProperty method tesGetSelection.
@Test
public void tesGetSelection() {
Property testSelectionProp = NavajoFactory.getInstance().createProperty(testDoc, "testselectionproperty", "+", "mydesc", Property.DIR_IN);
Selection s = NavajoFactory.getInstance().createSelection(testDoc, "myselection", "0", true);
testSelectionProp.addSelection(s);
Selection s1 = testSelectionProp.getSelection("myselection");
Assert.assertNotNull(s1);
Assert.assertEquals(s1.getName(), s.getName());
Assert.assertEquals(s1.isSelected(), s.isSelected());
Assert.assertEquals(s1.getValue(), s.getValue());
s1 = testSelectionProp.getSelection("myselection2");
Assert.assertNotNull(s1);
Assert.assertEquals(Selection.DUMMY_SELECTION, s1.getName());
}
use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class TestProperty method tesSetName.
@Test
public void tesSetName() {
Property testProp = NavajoFactory.getInstance().createProperty(testDoc, "myprop", Property.STRING_PROPERTY, "78", 89, "mydesc", Property.DIR_IN);
testProp.setName("mypropje");
Assert.assertEquals("mypropje", testProp.getName());
}
use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class TestProperty method testDateTime.
@Test
public void testDateTime() {
Navajo n = NavajoFactory.getInstance().createNavajo(getClass().getResourceAsStream("iphone.xml"));
Property ios = n.getMessage("NewMatchEvent").getProperty("Ios");
Property correct = n.getMessage("NewMatchEvent").getProperty("Correct");
Object correctValue = correct.getTypedValue();
Object iosValue = ios.getTypedValue();
assertTrue(correctValue != null);
assertTrue(iosValue != null);
assertEquals(Date.class, correctValue.getClass());
assertEquals(Date.class, iosValue.getClass());
Date correctDate = (Date) correctValue;
Date iosDate = (Date) iosValue;
Calendar c = Calendar.getInstance();
c.setTime(correctDate);
assertFalse(c.get(Calendar.HOUR_OF_DAY) == 0);
Calendar iosCalendar = Calendar.getInstance();
iosCalendar.setTime(iosDate);
assertFalse(iosCalendar.get(Calendar.HOUR_OF_DAY) == 0);
}
Aggregations