use of com.dexels.navajo.document.Navajo in project navajo by Dexels.
the class TestNavajo method testMerge.
@Test
public void testMerge() {
// testmessage
Navajo extra = NavajoFactory.getInstance().createNavajo();
Message m = NavajoFactory.getInstance().createMessage(extra, "testmessage");
Property p = NavajoFactory.getInstance().createProperty(extra, "extrapropje", Property.STRING_PROPERTY, "", 0, "", "");
Property p2 = NavajoFactory.getInstance().createProperty(extra, "stringprop", Property.STRING_PROPERTY, "SUPERNAVAJO", 0, "", "");
m.addProperty(p);
m.addProperty(p2);
extra.addMessage(m);
Message m2 = NavajoFactory.getInstance().createMessage(extra, "testmessage_sub2");
m.addMessage(m2);
p = NavajoFactory.getInstance().createProperty(extra, "nogeenextrapropje", Property.STRING_PROPERTY, "", 0, "", "");
m2.addProperty(p);
m = NavajoFactory.getInstance().createMessage(extra, "testmessage_extra");
p = NavajoFactory.getInstance().createProperty(extra, "extrapropje", Property.STRING_PROPERTY, "", 0, "", "");
m.addProperty(p);
extra.addMessage(m);
// Before merge assert value of stringprop.
Assert.assertEquals("navajo", testDoc.getProperty("/testmessage/stringprop").getValue());
testDoc.merge(extra);
Property assertprop = testDoc.getProperty("/testmessage/extrapropje");
Assert.assertNotNull(assertprop);
assertprop = testDoc.getProperty("/testmessage/integerprop");
Assert.assertNotNull(assertprop);
// After merge assert value of stringprop.
Assert.assertEquals("SUPERNAVAJO", testDoc.getProperty("/testmessage/stringprop").getValue());
}
use of com.dexels.navajo.document.Navajo in project navajo by Dexels.
the class TestNavajo method testAppendDocBuffer.
@Test
public void testAppendDocBuffer() {
Navajo extra = NavajoFactory.getInstance().createNavajo();
Message m = NavajoFactory.getInstance().createMessage(extra, "appendedmessage");
Property p = NavajoFactory.getInstance().createProperty(extra, "propje", Property.STRING_PROPERTY, "", 0, "", "");
m.addProperty(p);
extra.addMessage(m);
Message m2 = NavajoFactory.getInstance().createMessage(extra, "bliep");
extra.addMessage(m2);
testDoc.appendDocBuffer(extra.getMessageBuffer());
Message result = testDoc.getMessage("appendedmessage");
Assert.assertNotNull(result);
Assert.assertEquals("appendedmessage", result.getName());
}
use of com.dexels.navajo.document.Navajo in project navajo by Dexels.
the class TestCheckTypes method createNavajoEntity.
private Navajo createNavajoEntity() {
Navajo n1 = NavajoFactory.getInstance().createNavajo();
Message m1 = NavajoFactory.getInstance().createMessage(n1, "Match");
n1.addMessage(m1);
Property p1 = NavajoFactory.getInstance().createProperty(n1, "MatchId", Property.INTEGER_PROPERTY, "", 0, "", "");
m1.addProperty(p1);
Property p2 = NavajoFactory.getInstance().createProperty(n1, "MatchName", Property.STRING_PROPERTY, "", 0, "", "");
m1.addProperty(p2);
// Add definition.
Message m2 = NavajoFactory.getInstance().createMessage(n1, "Facilities", Message.MSG_TYPE_ARRAY);
m1.addMessage(m2);
Message def = NavajoFactory.getInstance().createMessage(n1, "Facilities", Message.MSG_TYPE_DEFINITION);
Property p1c = NavajoFactory.getInstance().createProperty(n1, "FacilityName", Property.STRING_PROPERTY, "", 0, "", "");
Property p2c = NavajoFactory.getInstance().createProperty(n1, "Size", Property.STRING_PROPERTY, "", 0, "", "");
Property p3c = NavajoFactory.getInstance().createProperty(n1, "Address", Property.STRING_PROPERTY, "", 0, "", "");
def.addProperty(p1c);
def.addProperty(p2c);
def.addProperty(p3c);
m2.setDefinitionMessage(def);
Message extra = NavajoFactory.getInstance().createMessage(n1, "Extra");
m1.addMessage(extra);
return n1;
}
use of com.dexels.navajo.document.Navajo in project navajo by Dexels.
the class TestNavajoDoc method testMarteMessage.
@Test
public void testMarteMessage() {
// Unit test for ignoring message under an array message and keep the correct
// index number.
Navajo n = NavajoFactory.getInstance().createNavajo();
Message array = NavajoFactory.getInstance().createMessage(n, "Actor");
n.addMessage(array);
array.setType(Message.MSG_TYPE_ARRAY);
// creating children messages
// child 1
Message child1 = NavajoFactory.getInstance().createMessage(n, "Actor");
// child1.setIndex(0);
array.addElement(child1);
Property property1_child1 = NavajoFactory.getInstance().createProperty(n, "Id", Property.INTEGER_PROPERTY, "1", 0, "", "out");
Property property2_child1 = NavajoFactory.getInstance().createProperty(n, "FirstName", Property.STRING_PROPERTY, "Penelope", 0, "", "out");
Property property3_child1 = NavajoFactory.getInstance().createProperty(n, "LastName", Property.STRING_PROPERTY, "1", 0, "", "out");
child1.addProperty(property1_child1);
child1.addProperty(property2_child1);
child1.addProperty(property3_child1);
// child 2
Message child2 = NavajoFactory.getInstance().createMessage(n, "Actor");
// child2.setIndex(0);
array.addElement(child2);
Property property1_child2 = NavajoFactory.getInstance().createProperty(n, "Id", Property.INTEGER_PROPERTY, "2", 0, "", "out");
Property property2_child2 = NavajoFactory.getInstance().createProperty(n, "FirstName", Property.STRING_PROPERTY, "Nick", 0, "", "out");
Property property3_child2 = NavajoFactory.getInstance().createProperty(n, "LastName", Property.STRING_PROPERTY, "Wahlberg", 0, "", "out");
child2.addProperty(property1_child2);
child2.addProperty(property2_child2);
child2.addProperty(property3_child2);
// System.out.println("Array message size "+
// n.getMessage("Array").getArraySize());
n.write(System.out);
// Assert.assertEquals(1, n.getMessage("Array").getArraySize());
Assert.assertEquals(0, n.getMessage("Actor").getMessage(0).getIndex());
Assert.assertEquals(1, n.getMessage("Actor").getMessage(1).getIndex());
}
use of com.dexels.navajo.document.Navajo in project navajo by Dexels.
the class TestOperation method testOperation.
@Test
public void testOperation() {
NavajoFactory f = NavajoFactory.getInstance();
Navajo n = f.createNavajo();
Message msg = f.createMessage(n, "__Mongo__");
Operation o = f.createOperation(n, "PUT", "vla/ProcessInsertPerson", null, "Person", null);
n.addOperation(o);
o.setExtraMessage(msg);
Method m = f.createMethod(n, "vla/ProcessUpdatePerson", null);
m.addRequired("Apenoot");
n.addMethod(m);
n.write(System.err);
}
Aggregations