Search in sources :

Example 76 with Navajo

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

Example 77 with Navajo

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

the class TestProperty method tesSetAnyValue.

@Test
public void tesSetAnyValue() {
    Navajo n = NavajoFactory.getInstance().createNavajo();
    Property p1 = NavajoFactory.getInstance().createProperty(n, "Aap", "", "", "");
    // String
    p1.setAnyValue("Apenoot");
    assertEquals("string", p1.getType());
    assertEquals("Apenoot", p1.getValue());
    assertTrue(p1.getTypedValue().equals("Apenoot"));
    // Integer
    p1.setAnyValue(Integer.valueOf(50));
    assertEquals("integer", p1.getType());
    assertEquals("50", p1.getValue());
    assertTrue(p1.getTypedValue().equals(Integer.valueOf(50)));
    // Double
    p1.setAnyValue(Double.valueOf(50));
    assertEquals("float", p1.getType());
    assertEquals("50.0", p1.getValue());
    assertTrue(p1.getTypedValue().equals(Double.valueOf(50)));
    // Float
    p1.setAnyValue(Float.valueOf(50));
    assertEquals("float", p1.getType());
    assertEquals("50.0", p1.getValue());
    assertTrue(p1.getTypedValue().equals(Double.valueOf(50)));
    // Date
    Date d = new java.util.Date();
    p1.setAnyValue(d);
    String expectedFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SS").format(d);
    assertEquals("date", p1.getType());
    assertEquals(expectedFormat, p1.getValue());
    assertTrue(p1.getTypedValue().equals(d));
    // Long
    p1.setAnyValue(Long.valueOf(10));
    assertEquals("long", p1.getType());
    assertEquals("10", p1.getValue());
    assertTrue(p1.getTypedValue().equals(Long.valueOf(10)));
    // Boolean
    p1.setAnyValue(Boolean.TRUE);
    assertEquals("boolean", p1.getType());
    assertEquals("true", p1.getValue());
    assertTrue(p1.getTypedValue().equals(Boolean.TRUE));
    // Binary
    Binary b = new Binary("Mooie array".getBytes());
    p1.setAnyValue(b);
    assertEquals("binary", p1.getType());
    Binary b1 = (Binary) p1.getTypedValue();
    String expected = new String(b1.getData());
    assertEquals("Mooie array", expected);
    // Money
    p1.setAnyValue(new Money(5000));
    assertEquals("money", p1.getType());
    assertEquals("5000.00", p1.getValue());
    assertTrue(p1.getTypedValue().equals(new Money(5000)));
    // ClockTime
    Date d1 = new java.util.Date();
    ClockTime ct = new ClockTime(d1);
    String expectedFormat2 = ct.toString();
    p1.setAnyValue(ct);
    assertEquals("clocktime", p1.getType());
    assertEquals(expectedFormat2, p1.getValue());
    assertTrue(p1.getTypedValue().equals(new ClockTime(d1)));
    // StopwatchTime
    Date d2 = new java.util.Date();
    String format = new SimpleDateFormat("HH:mm:ss:SSS").format(d2);
    StopwatchTime swt = new StopwatchTime(format);
    p1.setAnyValue(swt);
    assertEquals("stopwatchtime", p1.getType());
    logger.info("FORM: {} val: {}", format, p1.getValue());
    assertEquals(format, p1.getValue());
    assertTrue(p1.getTypedValue().equals(new StopwatchTime(format)));
    // Percentage
    Percentage p = new Percentage(50);
    p1.setAnyValue(p);
    assertEquals("percentage", p1.getType());
    assertEquals("50.0", p1.getValue());
    assertTrue(p1.getTypedValue().equals(new Percentage(50)));
}
Also used : StopwatchTime(com.dexels.navajo.document.types.StopwatchTime) Money(com.dexels.navajo.document.types.Money) Percentage(com.dexels.navajo.document.types.Percentage) Navajo(com.dexels.navajo.document.Navajo) Binary(com.dexels.navajo.document.types.Binary) ClockTime(com.dexels.navajo.document.types.ClockTime) Property(com.dexels.navajo.document.Property) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Test(org.junit.Test)

Example 78 with Navajo

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

the class PerformanceTest method testSearchClub.

@Test
public void testSearchClub() throws ClientException {
    int count = 5;
    for (int i = 0; i < count; i++) {
        Navajo init = client.doSimpleSend(null, "club/InitSearchClub");
        init.getProperty("ClubSearch/ClubName").setAnyValue(randomString(3));
        Navajo process = client.doSimpleSend(init, "club/ProcessSearchClub");
        process.write(System.out);
    }
}
Also used : Navajo(com.dexels.navajo.document.Navajo) Test(org.junit.Test)

Example 79 with Navajo

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

the class ScriptTestCase method setUp.

@Before
protected void setUp() throws Exception {
    if (skipAllTests) {
        return;
    }
    Navajo input = null;
    input = acquireInput();
    if (input == null) {
        String inputName = getInputName();
        if (inputName == null) {
            input = NavajoFactory.getInstance().createNavajo();
        } else {
            System.err.println("Input found: " + inputName);
            input = ScriptTestContext.getInstance().getInput(inputName);
        }
    }
    prepareInput(input);
    String scriptName = getScriptName();
    Navajo result = ScriptTestContext.getInstance().getScriptResult(scriptName);
    if (result == null) {
        result = ScriptTestContext.getInstance().callService(scriptName, input);
    }
}
Also used : Navajo(com.dexels.navajo.document.Navajo) Before(org.junit.Before)

Example 80 with Navajo

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

the class RDShapeImport method storeBinaryShapeRecord.

private void storeBinaryShapeRecord(String shapeId, File recordFile) {
    try {
        Binary data = new Binary(recordFile);
        Navajo pms = NavajoClientFactory.getClient().doSimpleSend(null, "geospatial/InitInsertCBSPolyPoint");
        Message params = pms.getMessage("Parameters");
        if (params != null) {
            params.getProperty("ShapeId").setValue(shapeId);
            params.getProperty("ShapeData").setValue(data);
            NavajoClientFactory.getClient().doSimpleSend(params.getRootDoc(), "geospatial/ProcessInsertCBSPolyPoint");
        }
    } catch (Exception e) {
        logger.error("Error: ", e);
    }
}
Also used : Message(com.dexels.navajo.document.Message) Binary(com.dexels.navajo.document.types.Binary) Navajo(com.dexels.navajo.document.Navajo)

Aggregations

Navajo (com.dexels.navajo.document.Navajo)258 Message (com.dexels.navajo.document.Message)131 Test (org.junit.Test)109 Property (com.dexels.navajo.document.Property)86 NavajoException (com.dexels.navajo.document.NavajoException)31 Access (com.dexels.navajo.script.api.Access)30 IOException (java.io.IOException)28 StringWriter (java.io.StringWriter)27 TMLExpressionException (com.dexels.navajo.expression.api.TMLExpressionException)26 FunctionInterface (com.dexels.navajo.expression.api.FunctionInterface)25 ImmutableMessage (com.dexels.immutable.api.ImmutableMessage)22 Selection (com.dexels.navajo.document.Selection)22 Header (com.dexels.navajo.document.Header)20 Operand (com.dexels.navajo.document.Operand)20 InputStream (java.io.InputStream)17 UserException (com.dexels.navajo.script.api.UserException)16 Optional (java.util.Optional)16 FatalException (com.dexels.navajo.script.api.FatalException)14 SystemException (com.dexels.navajo.script.api.SystemException)14 ContextExpression (com.dexels.navajo.expression.api.ContextExpression)13