.field(fieldType1.getName(), "foo")
.create();
{
// master scan
final RecordScan scan = new RecordScan();
scan.setRecordFilter(new RecordVariantFilter(master, new HashMap<String, String>()));
RecordScanner scanner = repository.getScanner(scan);
assertEquals(master, scanner.next().getId());
assertNull(scanner.next());
scanner.close();
}
{
// variant scan
final HashMap<String, String> variantProperties = new HashMap<String, String>();
variantProperties.put("foo", null);
variantProperties.put("bar", null);
final RecordScan scan = new RecordScan();
scan.setRecordFilter(new RecordVariantFilter(variant.getMaster(), variantProperties));
RecordScanner scanner = repository.getScanner(scan);
assertNull(scanner.next()); // it doesn't match anything
scanner.close();
}
{
// variant scan for something completely different
final HashMap<String, String> variantProperties = new HashMap<String, String>();
variantProperties.put("key1", null);
variantProperties.put("key2", null);
final RecordScan scan = new RecordScan();
scan.setRecordFilter(new RecordVariantFilter(variant.getMaster(), variantProperties));
RecordScanner scanner = repository.getScanner(scan);
assertEquals(variant, scanner.next().getId());
assertEquals(variantWithOtherValues, scanner.next().getId());
assertNull(scanner.next()); // it doesn't match the extendedVariant!
scanner.close();
}
{
// extended variant scan
final HashMap<String, String> variantProperties = new HashMap<String, String>();
variantProperties.put("key1", null);
variantProperties.put("key2", null);
variantProperties.put("key3", null);
final RecordScan scan = new RecordScan();
scan.setRecordFilter(
new RecordVariantFilter(extendedVariant.getMaster(), variantProperties));
RecordScanner scanner = repository.getScanner(scan);
assertEquals(extendedVariant, scanner.next().getId());
assertNull(scanner.next());
scanner.close();