Link linkValue = new Link(idGenerator.newRecordId());
Blob blobValue = new Blob(Bytes.toBytes("anotherKey"), "image/jpeg", Long.MIN_VALUE, "images/image.jpg");
URI uriValue = URI.create("http://foo.com/bar");
List<String> listValue = new ArrayList<String>();
listValue.add("abc");
HierarchyPath pathValue = new HierarchyPath("abc");
Record recordValue = repository.recordBuilder().field(stringFieldName, "foo").build();
Record record = repository.recordBuilder()
.field(stringFieldName, stringValue)
.field(integerFieldName, integerValue)
.field(longFieldName, longValue)
.field(doubleFieldName, doubleValue)
.field(decimalFieldName, decimalValue)
.field(booleanFieldName, booleanValue)
.field(dateFieldName, dateValue)
.field(dateTimeFieldName, dateTimeValue)
.field(linkFieldName, linkValue)
.field(blobFieldName, blobValue)
.field(uriFieldName, uriValue)
.field(listFieldName, listValue)
.field(pathFieldName, pathValue)
.field(recordFieldName, recordValue)
.build();
// Clone record
record = record.cloneRecord();
// Change mutable values
listValue.add("def");
pathValue.getElements()[0] = "def";
blobValue.setSize(0L);
recordValue.setField(integerFieldName, 777);
// Validate cloned record does not contain mutations
List<String> list = record.getField(listFieldName);
assertTrue(list.size() == 1);
assertEquals("abc", list.get(0));
HierarchyPath path = record.getField(pathFieldName);
assertEquals("abc", path.getElements()[0]);
Blob blob = record.getField(blobFieldName);
assertTrue(Long.MIN_VALUE == blob.getSize());
Record recordField = record.getField(recordFieldName);