use of org.janusgraph.graphdb.serializer.attributes.THashMapSerializer in project janusgraph by JanusGraph.
the class SerializerTest method customHashMapSerializeTest.
@Test
public void customHashMapSerializeTest() {
serialize.registerClass(1, HashMap.class, new THashMapSerializer());
DataOutput out = serialize.getDataOutput(128);
final String property1 = "property1";
final String value1 = "value1";
final HashMap<String, Object> hashMapIn = new HashMap<>();
hashMapIn.put(property1, value1);
out.writeObjectNotNull(hashMapIn);
ReadBuffer b = out.getStaticBuffer().asReadBuffer();
if (printStats)
log.debug(bufferStats(b));
final HashMap<String, Object> hashMapOut = serialize.readObjectNotNull(b, HashMap.class);
assertNotNull(hashMapOut);
assertEquals(2, hashMapOut.size());
assertEquals(value1, hashMapOut.get(property1));
// THashMapSerializer adds this
assertTrue(hashMapOut.containsKey(THashMapSerializer.class.getName()));
}
Aggregations