Search in sources :

Example 96 with Property

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());
}
Also used : Binary(com.dexels.navajo.document.types.Binary) Property(com.dexels.navajo.document.Property) Test(org.junit.Test)

Example 97 with Property

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);
}
Also used : Selection(com.dexels.navajo.document.Selection) Property(com.dexels.navajo.document.Property) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 98 with Property

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());
}
Also used : Selection(com.dexels.navajo.document.Selection) Property(com.dexels.navajo.document.Property) Test(org.junit.Test)

Example 99 with Property

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());
}
Also used : Property(com.dexels.navajo.document.Property) Test(org.junit.Test)

Example 100 with Property

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);
}
Also used : Calendar(java.util.Calendar) Navajo(com.dexels.navajo.document.Navajo) Property(com.dexels.navajo.document.Property) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Property (com.dexels.navajo.document.Property)253 Message (com.dexels.navajo.document.Message)148 Test (org.junit.Test)88 Navajo (com.dexels.navajo.document.Navajo)84 Selection (com.dexels.navajo.document.Selection)36 NavajoException (com.dexels.navajo.document.NavajoException)30 TMLExpressionException (com.dexels.navajo.expression.api.TMLExpressionException)17 ArrayList (java.util.ArrayList)17 ImmutableMessage (com.dexels.immutable.api.ImmutableMessage)16 Binary (com.dexels.navajo.document.types.Binary)16 UserException (com.dexels.navajo.script.api.UserException)16 Access (com.dexels.navajo.script.api.Access)15 StringWriter (java.io.StringWriter)13 List (java.util.List)11 Operand (com.dexels.navajo.document.Operand)10 MappableException (com.dexels.navajo.script.api.MappableException)9 IOException (java.io.IOException)9 Writer (java.io.Writer)9 StringTokenizer (java.util.StringTokenizer)9 JSONTML (com.dexels.navajo.document.json.JSONTML)8