final byte[] rowKey = Bytes.toBytes(UNUSUAL_STRING_EID);
final byte[] hash = Hasher.hash(Bytes.toBytes(UNUSUAL_STRING_EID));
final byte[] hbaseRowKey = new byte[rowKey.length + 2];
System.arraycopy(hash, 0, hbaseRowKey, 0, 2);
System.arraycopy(rowKey, 0, hbaseRowKey, 2, rowKey.length);
final EntityId originalEid = factory.getEntityIdFromHBaseRowKey(hbaseRowKey);
final JsonEntityIdParser restEid1 = JsonEntityIdParser.create(originalEid, layout);
final JsonEntityIdParser restEid2 = JsonEntityIdParser.create(
String.format("hbase=%s", Bytes.toStringBinary(hbaseRowKey)), layout);
final JsonEntityIdParser restEid3 = JsonEntityIdParser.create(
String.format("hbase_hex=%s", new String(Hex.encodeHex((hbaseRowKey)))), layout);
// Resolved entity id should match origin entity id.
assertEquals(originalEid, restEid1.getEntityId());
assertEquals(originalEid, restEid2.getEntityId());
assertEquals(originalEid, restEid3.getEntityId());
// Component representation of entities should work.
final JsonEntityIdParser restEid4 = JsonEntityIdParser.create(SINGLE_COMPONENT_EID, layout);
final EntityId resolvedEid = restEid4.getEntityId();
final String recoveredComponent = Bytes.toString(
Bytes.toBytesBinary(
resolvedEid.toShellString().substring(
ToolUtils.KIJI_ROW_KEY_SPEC_PREFIX.length())));
assertEquals(UNUSUAL_STRING_EID, recoveredComponent);
assertEquals(resolvedEid, restEid4.getEntityId());
}