use of com.dexels.replication.impl.json.JSONReplicationMessageParserImpl in project navajo by Dexels.
the class TestProtobufConversion method testConversion.
@Test
public void testConversion() throws JsonGenerationException, JsonMappingException, IOException {
ReplicationMessage createReplicationMessage = createReplicationMessage();
// convert to protobuf
byte[] serializedMessage = ReplicationFactory.getInstance().serialize(createReplicationMessage);
System.out.println(new String(serializedMessage));
assertNotNull(serializedMessage);
// parse protobuf
ReplicationMessage rmsg = ReplicationFactory.getInstance().parseBytes(Optional.empty(), serializedMessage);
System.err.println("Rescribe: " + new String(rmsg.toBytes(new JSONReplicationMessageParserImpl())));
Navajo rr = JsonTmlFactory.getInstance().toReplicationNavajo(rmsg, "Tenant", "Table", Optional.of("Datasource"));
rr.write(System.out);
// Check
Assert.assertEquals(6, rr.getMessage("Transaction/Columns").getArraySize());
}
use of com.dexels.replication.impl.json.JSONReplicationMessageParserImpl 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.impl.json.JSONReplicationMessageParserImpl in project navajo by Dexels.
the class TestSerializeReplicationMessage method testRepl.
@Test
public void testRepl() {
ReplicationMessageParser parser = new JSONReplicationMessageParserImpl();
ImmutableMessage m = parser.parseStream(this.getClass().getClassLoader().getResourceAsStream("person.json")).message();
StreamDocument.replicationMessageToStreamEvents("Person", m, false).compose(StreamDocument.inNavajo("TestService", Optional.empty(), Optional.empty())).lift(StreamDocument.serialize()).lift(StreamDocument.decode("UTF-8")).blockingForEach(e -> {
System.err.print(e);
});
}
Aggregations