private void save(long version, Id patch, Id prev) { newState(version, patch, prev); JsonObject x = stateToJson(version, patch, prev); byte[] bytes = JSONX.asBytes(x); if ( patch != null ) { // [META] // Record the basic header - (version, id, prev) - for validation. if ( keepHeaderInfo ) Zk.zkCreateSet(client, headerPath(patch), bytes); // Write version->id mapping. Zk.zkCreateSet(client, versionPath(version), patch.asBytes()); } Zk.zkSet(client, statePath, bytes); }
@Test public void id_fromBytes() { Id id1 = Id.create(); byte[] bytes = id1.asBytes(); Id id2 = Id.fromBytes(bytes); assertNotNull(id2); assertNotSame(id1, id2); assertEquals(id1, id2); }