use of com.cinchapi.concourse.server.plugin.io.PluginSerializer in project concourse by cinchapi.
the class LazyTrackingTObjectResultDatasetTest method testSerializationRepro.
@Test
public void testSerializationRepro() {
String json = FileOps.read(Resources.getAbsolutePath("/data.json"));
List<Multimap<String, Object>> objects = Convert.anyJsonToJava(json);
for (Multimap<String, Object> object : objects) {
long entity = Time.now();
for (Entry<String, Collection<Object>> entry : object.asMap().entrySet()) {
String attribute = entry.getKey();
for (Object value : entry.getValue()) {
dataset.insert(entity, attribute, Convert.javaToThrift(value));
}
}
}
PluginSerializer serializer = new PluginSerializer();
ByteBuffer bytes = serializer.serialize(dataset);
ComplexTObject complex = ComplexTObject.fromJavaObject(bytes);
ByteBuffer bytes2 = complex.getJavaObject();
Object obj = serializer.deserialize(bytes2);
Assert.assertEquals(dataset, obj);
}
use of com.cinchapi.concourse.server.plugin.io.PluginSerializer in project concourse by cinchapi.
the class ObjectResultDatasetTest method testSerialization.
@Test
public void testSerialization() {
ObjectResultDataset dataset = new ObjectResultDataset(new TObjectResultDataset());
dataset.insert(1L, "name", "Jeff Nelson");
PluginSerializer serializer = new PluginSerializer();
ByteBuffer bytes = serializer.serialize(dataset);
ComplexTObject complex = ComplexTObject.fromJavaObject(bytes);
ByteBuffer bytes2 = complex.getJavaObject();
Object obj = serializer.deserialize(bytes2);
Assert.assertEquals(dataset, obj);
}
use of com.cinchapi.concourse.server.plugin.io.PluginSerializer in project concourse by cinchapi.
the class LazyTrackingTObjectResultDatasetTest method testSerialization.
@Test
public void testSerialization() {
dataset.insert(1L, "name", Convert.javaToThrift("Jeff Nelson"));
PluginSerializer serializer = new PluginSerializer();
ByteBuffer bytes = serializer.serialize(dataset);
ComplexTObject complex = ComplexTObject.fromJavaObject(bytes);
ByteBuffer bytes2 = complex.getJavaObject();
Object obj = serializer.deserialize(bytes2);
Assert.assertEquals(dataset, obj);
}
use of com.cinchapi.concourse.server.plugin.io.PluginSerializer in project concourse by cinchapi.
the class LazyTrackingTObjectResultDatasetTest method testTrackingEnabledWhenDeserialized.
@Test
public void testTrackingEnabledWhenDeserialized() {
dataset.put(1L, ImmutableMap.of("foo", ImmutableSet.of(Convert.javaToThrift(1), Convert.javaToThrift(2), Convert.javaToThrift(3))));
dataset.put(2L, ImmutableMap.of("foo", ImmutableSet.of(Convert.javaToThrift(1), Convert.javaToThrift(2), Convert.javaToThrift(3))));
dataset.put(3L, ImmutableMap.of("foo", ImmutableSet.of(Convert.javaToThrift(1), Convert.javaToThrift(2), Convert.javaToThrift(3))));
PluginSerializer serializer = new PluginSerializer();
ByteBuffer bytes = serializer.serialize(dataset);
Dataset<Long, String, TObject> dataset2 = serializer.deserialize(bytes);
Assert.assertNull(Reflection.get("tracking", dataset));
Assert.assertNotNull(Reflection.get("tracking", dataset2));
}
use of com.cinchapi.concourse.server.plugin.io.PluginSerializer in project concourse by cinchapi.
the class LazyTrackingTObjectResultDatasetTest method testInvertRepro.
@Test
public void testInvertRepro() {
String json = FileOps.read(Resources.getAbsolutePath("/data.json"));
List<Multimap<String, Object>> objects = Convert.anyJsonToJava(json);
for (Multimap<String, Object> object : objects) {
long entity = Time.now();
dataset.put(entity, object.asMap().entrySet().stream().collect(Collectors.toMap(Entry::getKey, e -> e.getValue().stream().map(Convert::javaToThrift).collect(Collectors.toSet()))));
}
PluginSerializer serializer = new PluginSerializer();
ByteBuffer bytes = serializer.serialize(dataset);
ComplexTObject complex = ComplexTObject.fromJavaObject(bytes);
ByteBuffer bytes2 = complex.getJavaObject();
dataset = serializer.deserialize(bytes2);
ObjectResultDataset dataset2 = new ObjectResultDataset(dataset);
Assert.assertEquals(dataset.toString(), dataset2.toString());
}
Aggregations