use of com.dexels.replication.api.ReplicationMessage in project navajo by Dexels.
the class JsonTmlConverterImpl method toFlatNavajo.
@Override
public Navajo toFlatNavajo(String name, ReplicationMessage message) {
Navajo rootNavajo = NavajoFactory.getInstance().createNavajo();
Message root = toMessage(name, message.message(), rootNavajo);
Property timestamp = NavajoFactory.getInstance().createProperty(rootNavajo, "Timestamp", Property.LONG_PROPERTY, message.timestamp() + "", 0, "", Property.DIR_OUT);
root.addProperty(timestamp);
rootNavajo.addMessage(root);
return rootNavajo;
}
use of com.dexels.replication.api.ReplicationMessage in project navajo by Dexels.
the class TestJsonConversion method testConversion.
@Test
public void testConversion() throws IOException {
InputStream resource = TestJsonConversion.class.getResourceAsStream("testtml.xml");
Navajo base = NavajoFactory.getInstance().createNavajo(resource);
Message m = base.getMessage("Pool");
ObjectNode on = JsonTmlFactory.getInstance().toNode(m, "ble");
JSONReplicationMessageParserImpl parser = new JSONReplicationMessageParserImpl();
ReplicationMessage rmsg = parser.parseJson(Optional.empty(), on);
ObjectMapper mapper = new ObjectMapper();
logger.info("Before:\n");
StringWriter sw = new StringWriter();
mapper.writerWithDefaultPrettyPrinter().writeValue(sw, on);
logger.info("Value: {}", sw);
Optional<List<ImmutableMessage>> r = rmsg.subMessages("Standings");
Assert.assertTrue(r.isPresent());
Assert.assertEquals(12, r.get().size());
Navajo rr = JsonTmlFactory.getInstance().toReplicationNavajo(rmsg, "Tenant", "Table", Optional.of("Datasource"));
Assert.assertEquals(10, rr.getMessage("Transaction/Columns").getArraySize());
}
use of com.dexels.replication.api.ReplicationMessage in project navajo by Dexels.
the class TestTMLReplicationConversion method testReplToMessage.
@Test
public void testReplToMessage() {
ReplicationMessage rm = ReplicationFactory.empty().with("Monkey", "Koko", "string");
Navajo n = NavajoFactory.getInstance().createNavajo();
n.addMessage(StreamDocument.replicationToMessage(rm.message(), "Message", false));
n.write(System.err);
String mn = (String) n.getMessage("Message").getProperty("Monkey").getTypedValue();
Assert.assertEquals("Koko", mn);
}
Aggregations