diff options
author | Jon Bratseth <bratseth@gmail.com> | 2021-12-13 14:25:29 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2021-12-13 14:25:29 +0100 |
commit | 3a2f9ddf6b337673aeffca83b6801f9e4fa96aee (patch) | |
tree | ee4044fca45bf6581e1d044736fde8792cff2c4e /document | |
parent | 644793f437d75d47e38c2a1c2bfb2b8bd2542d07 (diff) |
Test matching in inherited field
Diffstat (limited to 'document')
-rwxr-xr-x | document/src/main/java/com/yahoo/document/DocumentType.java | 6 | ||||
-rw-r--r-- | document/src/test/java/com/yahoo/document/select/DocumentSelectorTestCase.java | 12 |
2 files changed, 15 insertions, 3 deletions
diff --git a/document/src/main/java/com/yahoo/document/DocumentType.java b/document/src/main/java/com/yahoo/document/DocumentType.java index 95a35b74f04..15af1b3360b 100755 --- a/document/src/main/java/com/yahoo/document/DocumentType.java +++ b/document/src/main/java/com/yahoo/document/DocumentType.java @@ -321,7 +321,7 @@ public class DocumentType extends StructuredDataType { /** * Return whether this document type inherits the given document type. * - * @param superType The documenttype to check if it inherits. + * @param superType the documenttype to check if it inherits * @return true if it inherits the superType, false if not */ public boolean inherits(DocumentType superType) { @@ -335,8 +335,8 @@ public class DocumentType extends StructuredDataType { /** * Gets the field matching a given name. * - * @param name the name of a field. - * @return returns the matching field, or null if not found. + * @param name the name of a field + * @return returns the matching field, or null if not found */ public Field getField(String name) { Field field = headerType.getField(name); diff --git a/document/src/test/java/com/yahoo/document/select/DocumentSelectorTestCase.java b/document/src/test/java/com/yahoo/document/select/DocumentSelectorTestCase.java index 266434bf856..74b603cead5 100644 --- a/document/src/test/java/com/yahoo/document/select/DocumentSelectorTestCase.java +++ b/document/src/test/java/com/yahoo/document/select/DocumentSelectorTestCase.java @@ -56,8 +56,12 @@ public class DocumentSelectorTestCase { @Before public void setUp() { + DocumentType parent = new DocumentType("parent"); + parent.addField("parentField", DataType.STRING); + var importedFields = new HashSet<>(List.of("my_imported_field")); DocumentType type = new DocumentType("test", importedFields); + type.inherit(parent); type.addField("hint", DataType.INT); type.addField("hfloat", DataType.FLOAT); type.addField("hstring", DataType.STRING); @@ -79,6 +83,7 @@ public class DocumentSelectorTestCase { ArrayDataType intarray = new ArrayDataType(DataType.INT); type.addField("intarray", intarray); + manager.registerDocumentType(parent); manager.registerDocumentType(type); // Create strange doctypes using identifiers within them, which we @@ -740,6 +745,12 @@ public class DocumentSelectorTestCase { } @Test + public void testInheritance() throws ParseException { + List<DocumentPut> documents = createDocs(); + assertEquals(Result.TRUE, evaluate("test.parentField = \"parentValue\"", documents.get(0))); + } + + @Test public void using_non_commutative_comparison_operator_with_field_value_is_well_defined() throws ParseException { var documents = createDocs(); // Doc 0 contains 24 in `hint` field. @@ -871,6 +882,7 @@ public class DocumentSelectorTestCase { if (hString != null) doc.setFieldValue("hstring", new StringFieldValue(hString)); doc.setFieldValue("content", new StringFieldValue(content)); + doc.setFieldValue("parentField", new StringFieldValue("parentValue")); return new DocumentPut(doc); } |