assertArrayEquals(withDotsBytes, idGenerator.fromString(withDots).toBytes());
}
@Test
public void testUUIDWithVariantSingleProperty() {
IdGenerator idGenerator = new IdGeneratorImpl();
RecordId masterRecordId = idGenerator.newRecordId();
Map<String, String> variantProperties = new HashMap<String, String>();
variantProperties.put("dim1", "dimvalue1");
RecordId variantRecordId = idGenerator.newRecordId(masterRecordId, variantProperties);
// Test it is recognized as variant
assertFalse(variantRecordId.isMaster());
// Test string representation is what it is supposed to be
String variantRecordIdString = masterRecordId.toString() + ".dim1=dimvalue1";
assertEquals(variantRecordIdString, variantRecordId.toString());
assertEquals(variantRecordId, idGenerator.fromString(variantRecordIdString));
// Test round-trip string & bytes conversion
assertEquals(variantRecordId, idGenerator.fromString(variantRecordId.toString()));
assertEquals(variantRecordId, idGenerator.fromBytes(variantRecordId.toBytes()));
// Test bytes representation is really what we expect it to be
byte[] masterIdBytes = new byte[] {
/* uuid type marker */1,
/* uuid bytes */-46, 124, -37, 110, -82, 109, 17, -49, -106, -72, 68, 69, 83, 84, 0, 0 };
byte[] variantIdBytes = new byte[] {
/* uuid type marker */1,
/* uuid bytes */-46, 124, -37, 110, -82, 109, 17, -49, -106, -72, 68, 69, 83, 84, 0, 0
/* length of key (vint) */, 1
/* the key (letter X) */, 88
/* length of value (vint) */, 3
/* the value (ABC) */, 65, 66, 67 };
RecordId variantId = idGenerator.newRecordId(idGenerator.fromBytes(masterIdBytes),
Collections.singletonMap("X", "ABC"));
assertArrayEquals(variantIdBytes, variantId.toBytes());
}