@Test
public void testRecordVTTypeInRecord() throws Exception {
String ns = "testRecordVTTypeInRecord";
// Create a fieldType to be used as a field in a record type to be used as the type for a RecordValueType
FieldType fieldType1 = typeManager.createFieldType(typeManager.newFieldType(typeManager.getValueType("STRING"), new QName(ns, "field1"), Scope.NON_VERSIONED));
// Create a record type to be used as the type for a RecordValueType
RecordType rt1 = typeManager.recordTypeBuilder().name(new QName(ns, "rt1")).field(fieldType1.getId(), false).create();
// Create record types to be used as versioned and versioned-mutable record types, which should be ignored
RecordType vrt = typeManager.recordTypeBuilder().name(new QName(ns, "vrt")).field(fieldType1.getId(), false).create();
RecordType vmrt = typeManager.recordTypeBuilder().name(new QName(ns, "vmrt")).field(fieldType1.getId(), false).create();
// Make a RecordValueType without the record type specified
ValueType recordVT1 = typeManager.getValueType("RECORD");
// Create a fieldType with as value type a RecordValueType
FieldType fieldType2 = typeManager.createFieldType(typeManager.newFieldType(recordVT1, new QName(ns, "field2"), Scope.NON_VERSIONED));
// Create a recordType with a field of this field type
RecordType rt2 = typeManager.recordTypeBuilder()
.name(new QName(ns, "rt2"))
.field(fieldType2.getId(), false)
.create();
// Make a record to be used as field value, specify the record type here
Record recordField = repository.recordBuilder().recordType(new QName(ns, "rt1")).field(new QName(ns, "field1"), "abc").build();
recordField.setRecordType(Scope.VERSIONED, new QName(ns, "vrt"), null); // This record type should be ignored