use of com.baidu.hugegraph.backend.store.BackendMutation in project incubator-hugegraph by apache.
the class StoreSerializerTest method testSerializeStoreCommand.
@Test
public void testSerializeStoreCommand() {
BinaryBackendEntry entry = new BinaryBackendEntry(HugeType.VERTEX, new byte[] { 1, 2 });
entry.column(new byte[] { 1 }, new byte[] { 1 });
entry.column(new byte[] { 2 }, new byte[] { 2 });
entry.column(new byte[] { 127 }, new byte[] { 127 });
BackendMutation origin = new BackendMutation();
origin.add(entry, Action.INSERT);
byte[] mutationBytes = StoreSerializer.writeMutation(origin);
StoreCommand command = new StoreCommand(StoreType.GRAPH, StoreAction.MUTATE, mutationBytes);
Assert.assertEquals(StoreAction.MUTATE, command.action());
Assert.assertArrayEquals(mutationBytes, command.data());
byte[] commandBytes = command.data();
StoreCommand actual = StoreCommand.fromBytes(commandBytes);
Assert.assertEquals(StoreType.GRAPH, command.type());
Assert.assertEquals(command.action(), actual.action());
Assert.assertArrayEquals(command.data(), actual.data());
}
Aggregations