From 145aa634b4f85849c25b7d16b17adfe50c5ecead Mon Sep 17 00:00:00 2001 From: Arne H Juul Date: Sun, 13 Mar 2022 08:47:59 +0000 Subject: add getDeclaredStructType in DocumentType * getType() in DocumentTypeManager will be deprecated soon, this will be the recommended replacement. --- .../document/DocumentTypeManagerTestCase.java | 44 +++++++++++++++++++++- 1 file changed, 42 insertions(+), 2 deletions(-) (limited to 'document/src/test/java/com/yahoo/document/DocumentTypeManagerTestCase.java') 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 - } -- cgit v1.2.3