diff options
author | Arne H Juul <arnej@yahooinc.com> | 2022-03-13 08:47:59 +0000 |
---|---|---|
committer | Arne H Juul <arnej@yahooinc.com> | 2022-03-13 08:58:47 +0000 |
commit | 145aa634b4f85849c25b7d16b17adfe50c5ecead (patch) | |
tree | efcfc7491cbf65f507d6364425cf5f47a89ec057 /document/src/test/java/com/yahoo/document/DocumentTypeManagerTestCase.java | |
parent | 75c18d52ef575b983496df8bf43a0814c5ac2fb5 (diff) |
add getDeclaredStructType in DocumentType
* getType() in DocumentTypeManager will be deprecated soon,
this will be the recommended replacement.
Diffstat (limited to 'document/src/test/java/com/yahoo/document/DocumentTypeManagerTestCase.java')
-rw-r--r-- | document/src/test/java/com/yahoo/document/DocumentTypeManagerTestCase.java | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/document/src/test/java/com/yahoo/document/DocumentTypeManagerTestCase.java b/document/src/test/java/com/yahoo/document/DocumentTypeManagerTestCase.java index b89ed2b6b08..622c7b2237f 100644 --- a/document/src/test/java/com/yahoo/document/DocumentTypeManagerTestCase.java +++ b/document/src/test/java/com/yahoo/document/DocumentTypeManagerTestCase.java @@ -599,10 +599,50 @@ search annotationsimplicitstruct { assertTrue(array.getNestedType() instanceof StructDataType); } + @Test + public void declared_struct_types_available() { + var manager = DocumentTypeManager.fromFile("src/test/document/documentmanager.declstruct.cfg"); + var docType = manager.getDocumentType("foo"); + var struct = docType.getDeclaredStructType("mystructinfoo"); + assertNotNull(struct); + assertNotNull(struct.getField("f1")); + struct = docType.getDeclaredStructType("mystructinbar"); + assertNull(struct); + struct = docType.getDeclaredStructType("mystructinfoobar"); + assertNull(struct); + struct = docType.getDeclaredStructType("mystruct"); + assertNotNull(struct); + assertNotNull(struct.getField("f0")); + + docType = manager.getDocumentType("bar"); + struct = docType.getDeclaredStructType("mystructinfoo"); + assertNull(struct); + struct = docType.getDeclaredStructType("mystructinbar"); + assertNotNull(struct); + assertNotNull(struct.getField("f2")); + struct = docType.getDeclaredStructType("mystructinfoobar"); + assertNull(struct); + struct = docType.getDeclaredStructType("mystruct"); + assertNotNull(struct); + assertNotNull(struct.getField("f0")); + + docType = manager.getDocumentType("foobar"); + struct = docType.getDeclaredStructType("mystructinfoo"); + assertNotNull(struct); + assertNotNull(struct.getField("f1")); + struct = docType.getDeclaredStructType("mystructinbar"); + assertNotNull(struct); + assertNotNull(struct.getField("f2")); + struct = docType.getDeclaredStructType("mystructinfoobar"); + assertNotNull(struct); + assertNotNull(struct.getField("f3")); + struct = docType.getDeclaredStructType("mystruct"); + assertNotNull(struct); + assertNotNull(struct.getField("f0")); + } + // TODO test clone(). Also fieldSets not part of clone()..! // TODO add imported field to equals()/hashCode() for DocumentType? fieldSets not part of this... - // TODO test reference to own doc type - } |