Search in sources :

Example 1 with Dispatcher

use of com.dexels.navajo.server.Dispatcher in project navajo by Dexels.

the class TestNavajoMap method testSendThroughSetTrue.

@Test
public void testSendThroughSetTrue() throws MappableException, UserException {
    Navajo inDoc = NavajoFactory.getInstance().createNavajo();
    Property property = NavajoFactory.getInstance().createProperty(inDoc, "Meaning", INTEGER_PROPERTY, "42", 0, "", "out");
    Message message = NavajoFactory.getInstance().createMessage(inDoc, "SendThrough");
    message.addProperty(property);
    inDoc.addMessage(message);
    Message global = NavajoFactory.getInstance().createMessage(inDoc, "Global");
    global.setScope(Message.MSG_SCOPE_GLOBAL);
    inDoc.addMessage(global);
    Message local = NavajoFactory.getInstance().createMessage(inDoc, "Local");
    local.setScope(Message.MSG_SCOPE_LOCAL);
    inDoc.addMessage(local);
    // Initialize the navajomap.
    DispatcherFactory.createDispatcher(new Dispatcher());
    Access access = new Access();
    access.setInDoc(inDoc);
    access.setOutputDoc(outDoc);
    map.load(access);
    map.setSendThrough(true);
    map.prepareOutDoc();
    assertTrue(map.getSendThrough());
    assertEquals("42", map.outDoc.getMessage("SendThrough").getProperty("Meaning").getValue());
    assertEquals(Message.MSG_SCOPE_GLOBAL, map.outDoc.getMessage("Global").getScope());
    assertNull(map.outDoc.getMessage("Local"));
}
Also used : Message(com.dexels.navajo.document.Message) Access(com.dexels.navajo.script.api.Access) Navajo(com.dexels.navajo.document.Navajo) Dispatcher(com.dexels.navajo.server.Dispatcher) Property(com.dexels.navajo.document.Property) Test(org.junit.Test)

Example 2 with Dispatcher

use of com.dexels.navajo.server.Dispatcher in project navajo by Dexels.

the class TestNavajoMap method testCopyInputMessage.

@Test
public void testCopyInputMessage() throws MappableException, UserException {
    final String TEST_INTEGER_1 = "6";
    final String TEST_INTEGER_2 = "3";
    // Create a message on the in doc with a test value.
    Navajo inDoc = NavajoFactory.getInstance().createNavajo();
    Property property = NavajoFactory.getInstance().createProperty(outDoc, "newProperty", INTEGER_PROPERTY, TEST_INTEGER_1, 0, "", "out");
    Message message = NavajoFactory.getInstance().createMessage(outDoc, "SimpleMessage");
    message.addProperty(property);
    inDoc.addMessage(message);
    // Initialize the navajomap.
    DispatcherFactory.createDispatcher(new Dispatcher());
    Access access = new Access();
    access.setInDoc(inDoc);
    access.setOutputDoc(outDoc);
    map.load(access);
    // Create a property on the navajomap with a different value that could be overwritten with the test value.
    map.setPropertyName("/SimpleMessage/newProperty");
    map.setPropertyType(INTEGER_PROPERTY);
    map.setProperty(TEST_INTEGER_2);
    // Test the method while copying the input message.
    map.setCopyInputMessages("SimpleMessage");
    map.prepareOutDoc();
    // Ensure that the property created on the navajomap is not overwritten.
    assertEquals(TEST_INTEGER_2, map.outDoc.getMessage("SimpleMessage").getProperty("newProperty").getValue());
}
Also used : Message(com.dexels.navajo.document.Message) Access(com.dexels.navajo.script.api.Access) Navajo(com.dexels.navajo.document.Navajo) Dispatcher(com.dexels.navajo.server.Dispatcher) Property(com.dexels.navajo.document.Property) Test(org.junit.Test)

Example 3 with Dispatcher

use of com.dexels.navajo.server.Dispatcher in project navajo by Dexels.

the class TestNavajoMap method testSendThroughNotSet.

@Test
public void testSendThroughNotSet() throws MappableException, UserException {
    Navajo inDoc = NavajoFactory.getInstance().createNavajo();
    Property property = NavajoFactory.getInstance().createProperty(inDoc, "Meaning", INTEGER_PROPERTY, "42", 0, "", "out");
    Message message = NavajoFactory.getInstance().createMessage(inDoc, "SendThrough");
    message.addProperty(property);
    inDoc.addMessage(message);
    Message global = NavajoFactory.getInstance().createMessage(inDoc, "Global");
    global.setScope(Message.MSG_SCOPE_GLOBAL);
    inDoc.addMessage(global);
    Message local = NavajoFactory.getInstance().createMessage(inDoc, "Local");
    local.setScope(Message.MSG_SCOPE_LOCAL);
    inDoc.addMessage(local);
    // Initialize the navajomap.
    DispatcherFactory.createDispatcher(new Dispatcher());
    Access access = new Access();
    access.setInDoc(inDoc);
    access.setOutputDoc(outDoc);
    map.load(access);
    map.prepareOutDoc();
    assertFalse(map.getSendThrough());
    assertNull(map.outDoc.getMessage("SendThrough"));
    assertEquals(Message.MSG_SCOPE_GLOBAL, map.outDoc.getMessage("Global").getScope());
    assertNull(map.outDoc.getMessage("Local"));
}
Also used : Message(com.dexels.navajo.document.Message) Access(com.dexels.navajo.script.api.Access) Navajo(com.dexels.navajo.document.Navajo) Dispatcher(com.dexels.navajo.server.Dispatcher) Property(com.dexels.navajo.document.Property) Test(org.junit.Test)

Example 4 with Dispatcher

use of com.dexels.navajo.server.Dispatcher in project navajo by Dexels.

the class TestNavajoMap method testSendThroughSetFalse.

@Test
public void testSendThroughSetFalse() throws MappableException, UserException {
    Navajo inDoc = NavajoFactory.getInstance().createNavajo();
    Property property = NavajoFactory.getInstance().createProperty(inDoc, "Meaning", INTEGER_PROPERTY, "42", 0, "", "out");
    Message message = NavajoFactory.getInstance().createMessage(inDoc, "SendThrough");
    message.addProperty(property);
    inDoc.addMessage(message);
    Message global = NavajoFactory.getInstance().createMessage(inDoc, "Global");
    global.setScope(Message.MSG_SCOPE_GLOBAL);
    inDoc.addMessage(global);
    Message local = NavajoFactory.getInstance().createMessage(inDoc, "Local");
    local.setScope(Message.MSG_SCOPE_LOCAL);
    inDoc.addMessage(local);
    // Initialize the navajomap.
    DispatcherFactory.createDispatcher(new Dispatcher());
    Access access = new Access();
    access.setInDoc(inDoc);
    access.setOutputDoc(outDoc);
    map.load(access);
    map.setSendThrough(false);
    map.prepareOutDoc();
    assertFalse(map.getSendThrough());
    assertNull(map.outDoc.getMessage("SendThrough"));
    assertEquals(Message.MSG_SCOPE_GLOBAL, map.outDoc.getMessage("Global").getScope());
    assertNull(map.outDoc.getMessage("Local"));
}
Also used : Message(com.dexels.navajo.document.Message) Access(com.dexels.navajo.script.api.Access) Navajo(com.dexels.navajo.document.Navajo) Dispatcher(com.dexels.navajo.server.Dispatcher) Property(com.dexels.navajo.document.Property) Test(org.junit.Test)

Aggregations

Message (com.dexels.navajo.document.Message)4 Navajo (com.dexels.navajo.document.Navajo)4 Property (com.dexels.navajo.document.Property)4 Access (com.dexels.navajo.script.api.Access)4 Dispatcher (com.dexels.navajo.server.Dispatcher)4 Test (org.junit.Test)4